1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.quickstep.views;
17 
18 import android.annotation.Nullable;
19 import android.graphics.drawable.Drawable;
20 import android.view.View;
21 import android.view.ViewGroup;
22 
23 import com.android.quickstep.util.RecentsOrientedState;
24 
25 /**
26  * Interface defining an object which can be used as a TaskView's icon.
27  */
28 public interface TaskViewIcon {
29 
30     /**
31      * Returns the width of this icon view.
32      */
getWidth()33     int getWidth();
34 
35     /**
36      * Returns the height of this icon view.
37      */
getHeight()38     int getHeight();
39 
40     /**
41      * Sets the opacity of the view.
42      */
setContentAlpha(float alpha)43     void setContentAlpha(float alpha);
44 
45     /**
46      * Sets the opacity of the view for modal state.
47      */
setModalAlpha(float alpha)48     void setModalAlpha(float alpha);
49 
50     /**
51      * Returns this icon view's drawable.
52      */
getDrawable()53     @Nullable Drawable getDrawable();
54 
55     /**
56      * Sets a {@link Drawable} to be displayed.
57      */
setDrawable(@ullable Drawable icon)58     void setDrawable(@Nullable Drawable icon);
59 
60     /**
61      * Register a callback to be invoked when this view is clicked.
62      */
setOnClickListener(@ullable View.OnClickListener l)63     void setOnClickListener(@Nullable View.OnClickListener l);
64 
65     /**
66      * Register a callback to be invoked when this view is clicked and held.
67      */
setOnLongClickListener(@ullable View.OnLongClickListener l)68     void setOnLongClickListener(@Nullable View.OnLongClickListener l);
69 
70     /**
71      * Returns the LayoutParams associated with this view.
72      */
getLayoutParams()73     ViewGroup.LayoutParams getLayoutParams();
74 
75     /**
76      * Sets the layout parameters associated with this view.
77      */
setLayoutParams(ViewGroup.LayoutParams params)78     void setLayoutParams(ViewGroup.LayoutParams params);
79 
80     /**
81      * Sets the degrees that the view is rotated around the pivot point.
82      */
setRotation(float rotation)83     void setRotation(float rotation);
84 
85     /**
86      * Sets the size of the icon drawable.
87      */
setDrawableSize(int iconWidth, int iconHeight)88     void setDrawableSize(int iconWidth, int iconHeight);
89 
90     /**
91      * Sets the orientation of this icon view based on the provided orientationState.
92      */
setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask)93     void setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask);
94 
95     /**
96      * Sets the visibility state of this view.
97      */
setVisibility(int visibility)98     void setVisibility(int visibility);
99 
100     /**
101      * Sets the tint color of the icon, useful for scrimming or dimming.
102      *
103      * @param color to blend in.
104      * @param amount [0,1] 0 no tint, 1 full tint
105      */
setIconColorTint(int color, float amount)106     void setIconColorTint(int color, float amount);
107 
108     /**
109      * Gets the opacity of the view.
110      */
getAlpha()111     float getAlpha();
112 
113     /**
114      * Returns the width of this icon view's drawable.
115      */
getDrawableWidth()116     int getDrawableWidth();
117 
118     /**
119      * Returns the height of this icon view's drawable.
120      */
getDrawableHeight()121     int getDrawableHeight();
122 
123     /**
124      * Directly calls any attached OnClickListener.
125      */
callOnClick()126     boolean callOnClick();
127 
128     /**
129      * Calls this view's OnLongClickListener.
130      */
performLongClick()131     boolean performLongClick();
132 
133     /**
134      * Sets the text for this icon view if any text view is associated.
135      */
setText(CharSequence text)136     default void setText(CharSequence text) {}
137 
138     /**
139      * Returns this icon view cast as a View.
140      */
asView()141     View asView();
142 }
143