Add icon to desktop tile in overview
Copied over icon from caption desktop button in WMShell. Temporary icon
for now.
Refactored some logic in TaskView to better support for custom
orientation handling in subclasses. Subclasses can override setting
orientation for icon or thumbnail.
Bug: 267326722
Test: manual, enable desktop windowing proto 2 and go to overview
Change-Id: Id66d48fa52a418a07b954a384b2c3ea22f091b1f
diff --git a/quickstep/res/layout/task_desktop.xml b/quickstep/res/layout/task_desktop.xml
index 2a9674f..96aabb4 100644
--- a/quickstep/res/layout/task_desktop.xml
+++ b/quickstep/res/layout/task_desktop.xml
@@ -24,6 +24,11 @@
android:defaultFocusHighlightEnabled="false"
android:focusable="true">
+ <View
+ android:id="@+id/background"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
<!--
TODO(b249371338): DesktopTaskView extends from TaskView. TaskView expects TaskThumbnailView
and IconView with these ids to be present. Need to refactor RecentsView to accept child
@@ -38,10 +43,9 @@
<com.android.quickstep.views.IconView
android:id="@+id/icon"
- android:layout_width="0dp"
- android:layout_height="0dp"
+ android:layout_width="@dimen/task_thumbnail_icon_size"
+ android:layout_height="@dimen/task_thumbnail_icon_size"
android:focusable="false"
- android:importantForAccessibility="no"
- android:visibility="gone" />
+ android:importantForAccessibility="no" />
</com.android.quickstep.views.DesktopTaskView>
diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
index dc265e4..0ac682f 100644
--- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
@@ -24,6 +24,8 @@
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.SystemProperties;
@@ -31,14 +33,16 @@
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
+import android.view.View;
+import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.RunnableList;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SystemUiProxy;
@@ -87,7 +91,7 @@
private final ArrayList<CancellableTask<?>> mPendingThumbnailRequests = new ArrayList<>();
- private ShapeDrawable mBackground;
+ private View mBackgroundView;
public DesktopTaskView(Context context) {
this(context, null);
@@ -104,14 +108,28 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+
+ mBackgroundView = findViewById(R.id.background);
+
+ int topMarginPx =
+ mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
+ FrameLayout.LayoutParams params = (LayoutParams) mBackgroundView.getLayoutParams();
+ params.topMargin = topMarginPx;
+ mBackgroundView.setLayoutParams(params);
+
float[] outerRadii = new float[8];
Arrays.fill(outerRadii, getTaskCornerRadius());
RoundRectShape shape = new RoundRectShape(outerRadii, null, null);
- mBackground = new ShapeDrawable(shape);
- mBackground.setTint(getResources().getColor(android.R.color.system_neutral2_300,
+ ShapeDrawable background = new ShapeDrawable(shape);
+ background.setTint(getResources().getColor(android.R.color.system_neutral2_300,
getContext().getTheme()));
// TODO(b/244348395): this should be wallpaper
- setBackground(mBackground);
+ mBackgroundView.setBackground(background);
+
+ Drawable icon = getResources().getDrawable(R.drawable.ic_desktop, getContext().getTheme());
+ Drawable iconBackground = getResources().getDrawable(R.drawable.bg_circle,
+ getContext().getTheme());
+ mIconView.setDrawable(new LayerDrawable(new Drawable[]{iconBackground, icon}));
}
@Override
@@ -252,20 +270,9 @@
}
@Override
- public void setOrientationState(RecentsOrientedState orientationState) {
- // TODO(b/249371338): this copies logic from TaskView
- PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
- boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
+ protected void setThumbnailOrientation(RecentsOrientedState orientationState) {
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
-
- LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
-
int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
- int taskIconHeight = deviceProfile.overviewTaskIconSizePx;
- int taskMargin = deviceProfile.overviewTaskMarginPx;
-
- orientationHandler.setTaskIconParams(iconParams, taskMargin, taskIconHeight,
- thumbnailTopMargin, isRtl);
LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
snapshotParams.topMargin = thumbnailTopMargin;
@@ -374,6 +381,9 @@
setMeasuredDimension(containerWidth, containerHeight);
+ int thumbnailTopMarginPx = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
+ containerHeight -= thumbnailTopMarginPx;
+
int thumbnails = mSnapshotViewMap.size();
if (thumbnails == 0) {
return;
@@ -416,6 +426,8 @@
}
int taskX = (int) (positionInParent.x * scaleWidth);
int taskY = (int) (positionInParent.y * scaleHeight);
+ // move task down by margin size
+ taskY += thumbnailTopMarginPx;
thumbnailView.setX(taskX);
thumbnailView.setY(taskY);
@@ -439,9 +451,9 @@
mFullscreenProgress = progress;
if (mFullscreenProgress > 0) {
// Don't show background while we are transitioning to/from fullscreen
- setBackground(null);
+ mBackgroundView.setVisibility(INVISIBLE);
} else {
- setBackground(mBackground);
+ mBackgroundView.setVisibility(VISIBLE);
}
for (int i = 0; i < mSnapshotViewMap.size(); i++) {
TaskThumbnailView thumbnailView = mSnapshotViewMap.valueAt(i);
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 829e72c..d3c7778 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -996,6 +996,11 @@
}
public void setOrientationState(RecentsOrientedState orientationState) {
+ setIconOrientation(orientationState);
+ setThumbnailOrientation(orientationState);
+ }
+
+ protected void setIconOrientation(RecentsOrientedState orientationState) {
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
@@ -1016,6 +1021,11 @@
int iconDrawableSize = isGridTask ? deviceProfile.overviewTaskIconDrawableSizeGridPx
: deviceProfile.overviewTaskIconDrawableSizePx;
mIconView.setDrawableSize(iconDrawableSize, iconDrawableSize);
+ }
+
+ protected void setThumbnailOrientation(RecentsOrientedState orientationState) {
+ DeviceProfile deviceProfile = mActivity.getDeviceProfile();
+ int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
snapshotParams.topMargin = thumbnailTopMargin;