From be7ce023dee823c99e26031a9cad9db850f29047 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 17 Nov 2021 19:05:29 -0800 Subject: [PATCH] Use split thumbnail width/height directly * When swiping to QS from home, the bounds for the rect on screen are incorrect because it's technically off-screen when it's being queried Fixes: 206155441 Change-Id: Ibb17f2ac291f867b6de06041c980e434ce92cf27 --- .../com/android/quickstep/views/GroupedTaskView.java | 7 +------ .../launcher3/touch/LandscapePagedViewHandler.java | 7 +++---- .../launcher3/touch/PagedOrientationHandler.java | 2 +- .../launcher3/touch/PortraitPagedViewHandler.java | 11 ++++------- .../launcher3/touch/SeascapePagedViewHandler.java | 4 ++-- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index df99d27376..ea83b4deaf 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -4,7 +4,6 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; import android.content.Context; -import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; @@ -50,8 +49,6 @@ public class GroupedTaskView extends TaskView { private final float[] mIcon2CenterCoords = new float[2]; private TransformingTouchDelegate mIcon2TouchDelegate; @Nullable private StagedSplitBounds mSplitBoundsConfig; - private final Rect mPrimaryTempRect = new Rect(); - private final Rect mSecondaryTempRect = new Rect(); public GroupedTaskView(Context context) { super(context); @@ -239,10 +236,8 @@ public class GroupedTaskView extends TaskView { int taskIconHeight = deviceProfile.overviewTaskIconSizePx; boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; - mSnapshotView.getBoundsOnScreen(mPrimaryTempRect); - mSnapshotView2.getBoundsOnScreen(mSecondaryTempRect); getPagedOrientationHandler().setSplitIconParams(mIconView, mIconView2, - taskIconHeight, mPrimaryTempRect, mSecondaryTempRect, + taskIconHeight, mSnapshotView.getWidth(), mSnapshotView.getHeight(), isRtl, deviceProfile, mSplitBoundsConfig); } diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 93e3ea7599..498f6dbc60 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -429,7 +429,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { @Override public void setSplitIconParams(View primaryIconView, View secondaryIconView, - int taskIconHeight, Rect primarySnapshotBounds, Rect secondarySnapshotBounds, + int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight, boolean isRtl, DeviceProfile deviceProfile, StagedSplitBounds splitConfig) { FrameLayout.LayoutParams primaryIconParams = (FrameLayout.LayoutParams) primaryIconView.getLayoutParams(); @@ -439,13 +439,12 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { splitConfig.visualDividerBounds.height() : splitConfig.visualDividerBounds.width()); - int primaryHeight = primarySnapshotBounds.height(); primaryIconParams.gravity = (isRtl ? START : END) | TOP; - primaryIconView.setTranslationY(primaryHeight - primaryIconView.getHeight() / 2f); + primaryIconView.setTranslationY(primarySnapshotHeight - primaryIconView.getHeight() / 2f); primaryIconView.setTranslationX(0); secondaryIconParams.gravity = (isRtl ? START : END) | TOP; - secondaryIconView.setTranslationY(primaryHeight + taskIconHeight + dividerBar); + secondaryIconView.setTranslationY(primarySnapshotHeight + taskIconHeight + dividerBar); secondaryIconView.setTranslationX(0); primaryIconView.setLayoutParams(primaryIconParams); secondaryIconView.setLayoutParams(secondaryIconParams); diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index 2ff2feb4c5..95336cd399 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -152,7 +152,7 @@ public interface PagedOrientationHandler { void setIconAndSnapshotParams(View iconView, int taskIconMargin, int taskIconHeight, FrameLayout.LayoutParams snapshotParams, boolean isRtl); void setSplitIconParams(View primaryIconView, View secondaryIconView, - int taskIconHeight, Rect primarySnapshotBounds, Rect secondarySnapshotBounds, + int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight, boolean isRtl, DeviceProfile deviceProfile, StagedSplitBounds splitConfig); /* diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index ba9d09cfc6..835c2401ae 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -523,7 +523,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { @Override public void setSplitIconParams(View primaryIconView, View secondaryIconView, - int taskIconHeight, Rect primarySnapshotBounds, Rect secondarySnapshotBounds, + int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight, boolean isRtl, DeviceProfile deviceProfile, StagedSplitBounds splitConfig) { FrameLayout.LayoutParams primaryIconParams = (FrameLayout.LayoutParams) primaryIconView.getLayoutParams(); @@ -533,15 +533,12 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { splitConfig.visualDividerBounds.height() : splitConfig.visualDividerBounds.width()); - int primaryWidth = primarySnapshotBounds.width(); if (deviceProfile.isLandscape) { primaryIconParams.gravity = TOP | START; - primaryIconView.setTranslationX(primaryWidth - primaryIconView.getWidth()); + primaryIconView.setTranslationX(primarySnapshotWidth - primaryIconView.getWidth()); primaryIconView.setTranslationY(0); - secondaryIconParams.gravity = TOP | START; - secondaryIconView.setTranslationX(primaryWidth + dividerBar); - secondaryIconView.setTranslationY(0); + secondaryIconView.setTranslationX(primarySnapshotWidth + dividerBar); } else { primaryIconParams.gravity = TOP | CENTER_HORIZONTAL; primaryIconView.setTranslationX(-(primaryIconView.getWidth()) / 2f); @@ -549,8 +546,8 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { secondaryIconParams.gravity = TOP | CENTER_HORIZONTAL; secondaryIconView.setTranslationX(secondaryIconView.getWidth() / 2f); - secondaryIconView.setTranslationY(0); } + secondaryIconView.setTranslationY(0); primaryIconView.setLayoutParams(primaryIconParams); secondaryIconView.setLayoutParams(secondaryIconParams); } diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java index a0dde22d84..539e3f82c5 100644 --- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java @@ -132,10 +132,10 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { @Override public void setSplitIconParams(View primaryIconView, View secondaryIconView, - int taskIconHeight, Rect primarySnapshotBounds, Rect secondarySnapshotBounds, + int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight, boolean isRtl, DeviceProfile deviceProfile, StagedSplitBounds splitConfig) { super.setSplitIconParams(primaryIconView, secondaryIconView, taskIconHeight, - primarySnapshotBounds, secondarySnapshotBounds, isRtl, deviceProfile, splitConfig); + primarySnapshotWidth, primarySnapshotHeight, isRtl, deviceProfile, splitConfig); FrameLayout.LayoutParams primaryIconParams = (FrameLayout.LayoutParams) primaryIconView.getLayoutParams(); FrameLayout.LayoutParams secondaryIconParams =