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
This commit is contained in:
Ats Jenk
2023-02-09 16:27:13 -08:00
parent f5f3a80959
commit 78b614f555
4 changed files with 80 additions and 23 deletions
+8 -4
View File
@@ -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>
@@ -24,6 +24,8 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO
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.AttributeSet;
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 @@ public class DesktopTaskView extends TaskView {
private final ArrayList<CancellableTask<?>> mPendingThumbnailRequests = new ArrayList<>();
private ShapeDrawable mBackground;
private View mBackgroundView;
public DesktopTaskView(Context context) {
this(context, null);
@@ -104,14 +108,28 @@ public class DesktopTaskView extends TaskView {
@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 @@ public class DesktopTaskView extends TaskView {
}
@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 @@ public class DesktopTaskView extends TaskView {
setMeasuredDimension(containerWidth, containerHeight);
int thumbnailTopMarginPx = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
containerHeight -= thumbnailTopMarginPx;
int thumbnails = mSnapshotViewMap.size();
if (thumbnails == 0) {
return;
@@ -416,6 +426,8 @@ public class DesktopTaskView extends TaskView {
}
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 @@ public class DesktopTaskView extends TaskView {
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);
@@ -996,6 +996,11 @@ public class TaskView extends FrameLayout implements Reusable {
}
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 @@ public class TaskView extends FrameLayout implements Reusable {
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;
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="6.0"
android:translateY="6.0">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M5.958,37.708Q4.458,37.708 3.354,36.604Q2.25,35.5 2.25,34V18.292Q2.25,16.792 3.354,15.688Q4.458,14.583 5.958,14.583H9.5V5.958Q9.5,4.458 10.625,3.354Q11.75,2.25 13.208,2.25H34Q35.542,2.25 36.646,3.354Q37.75,4.458 37.75,5.958V21.667Q37.75,23.167 36.646,24.271Q35.542,25.375 34,25.375H30.5V34Q30.5,35.5 29.396,36.604Q28.292,37.708 26.792,37.708ZM5.958,34H26.792Q26.792,34 26.792,34Q26.792,34 26.792,34V21.542H5.958V34Q5.958,34 5.958,34Q5.958,34 5.958,34ZM30.5,21.667H34Q34,21.667 34,21.667Q34,21.667 34,21.667V9.208H13.208V14.583H26.833Q28.375,14.583 29.438,15.667Q30.5,16.75 30.5,18.25Z"/>
</group>
</vector>