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 * Sets the opacity of the view for flex split state. 52 */ setFlexSplitAlpha(float alpha)53 void setFlexSplitAlpha(float alpha); 54 55 /** 56 * Returns this icon view's drawable. 57 */ getDrawable()58 @Nullable Drawable getDrawable(); 59 60 /** 61 * Sets a {@link Drawable} to be displayed. 62 */ setDrawable(@ullable Drawable icon)63 void setDrawable(@Nullable Drawable icon); 64 65 /** 66 * Register a callback to be invoked when this view is clicked. 67 */ setOnClickListener(@ullable View.OnClickListener l)68 void setOnClickListener(@Nullable View.OnClickListener l); 69 70 /** 71 * Register a callback to be invoked when this view is clicked and held. 72 */ setOnLongClickListener(@ullable View.OnLongClickListener l)73 void setOnLongClickListener(@Nullable View.OnLongClickListener l); 74 75 /** 76 * Returns the LayoutParams associated with this view. 77 */ getLayoutParams()78 ViewGroup.LayoutParams getLayoutParams(); 79 80 /** 81 * Sets the layout parameters associated with this view. 82 */ setLayoutParams(ViewGroup.LayoutParams params)83 void setLayoutParams(ViewGroup.LayoutParams params); 84 85 /** 86 * Sets the degrees that the view is rotated around the pivot point. 87 */ setRotation(float rotation)88 void setRotation(float rotation); 89 90 /** 91 * Sets the size of the icon drawable. 92 */ setDrawableSize(int iconWidth, int iconHeight)93 void setDrawableSize(int iconWidth, int iconHeight); 94 95 /** 96 * Sets the orientation of this icon view based on the provided orientationState. 97 */ setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask)98 void setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask); 99 100 /** 101 * Sets the visibility state of this view. 102 */ setVisibility(int visibility)103 void setVisibility(int visibility); 104 105 /** 106 * Sets the tint color of the icon, useful for scrimming or dimming. 107 * 108 * @param color to blend in. 109 * @param amount [0,1] 0 no tint, 1 full tint 110 */ setIconColorTint(int color, float amount)111 void setIconColorTint(int color, float amount); 112 113 /** 114 * Gets the opacity of the view. 115 */ getAlpha()116 float getAlpha(); 117 118 /** 119 * Returns the width of this icon view's drawable. 120 */ getDrawableWidth()121 int getDrawableWidth(); 122 123 /** 124 * Returns the height of this icon view's drawable. 125 */ getDrawableHeight()126 int getDrawableHeight(); 127 128 /** 129 * Directly calls any attached OnClickListener. 130 */ callOnClick()131 boolean callOnClick(); 132 133 /** 134 * Calls this view's OnLongClickListener. 135 */ performLongClick()136 boolean performLongClick(); 137 138 /** 139 * Sets the text for this icon view if any text view is associated. 140 */ setText(CharSequence text)141 default void setText(CharSequence text) {} 142 143 /** 144 * Returns this icon view cast as a View. 145 */ asView()146 View asView(); 147 } 148