From f0a1b2ccd89911a7294dc6555041fdf5574a07ad Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 24 Jun 2020 20:52:26 -0700 Subject: [PATCH] Fix tracking window being slightly off when swiping from an app Test: swipe up from an app in landscape, seascape, and portrait, and verify the window tracks with the finger 1:1 until pullback Bug: 149934536 Change-Id: Ia469877e7152c8135e0b9153f69c191ba86cbd14 --- quickstep/src/com/android/quickstep/util/LayoutUtils.java | 2 +- .../launcher3/touch/LandscapePagedViewHandler.java | 8 ++++++++ .../android/launcher3/touch/PagedOrientationHandler.java | 1 + .../android/launcher3/touch/PortraitPagedViewHandler.java | 6 ++++++ .../android/launcher3/touch/SeascapePagedViewHandler.java | 7 +++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index ae19d73719..f7bd1e29d8 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -49,7 +49,7 @@ public class LayoutUtils { Rect taskSize = new Rect(); LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize, orientationHandler); - return (dp.heightPx - taskSize.height()) / 2; + return orientationHandler.getDistanceToBottomOfRect(dp, taskSize); } int shelfHeight = dp.hotseatBarSizePx + dp.getInsets().bottom; int spaceBetweenShelfAndRecents = (int) context.getResources().getDimension( diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 48c773413f..c2bfb167a2 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -17,6 +17,7 @@ package com.android.launcher3.touch; import static android.widget.ListPopupWindow.WRAP_CONTENT; + import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL; @@ -33,6 +34,7 @@ import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.LinearLayout; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.PagedView; import com.android.launcher3.Utilities; import com.android.launcher3.util.OverScroller; @@ -260,4 +262,10 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } return new ChildBounds(childHeight, childWidth, childBottom, childLeft); } + + @SuppressWarnings("SuspiciousNameCombination") + @Override + public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) { + return rect.left; + } } diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index 65b1a7a77e..b650526fe1 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -96,6 +96,7 @@ public interface PagedOrientationHandler { int getTaskMenuWidth(View view); int getTaskMenuLayoutOrientation(LinearLayout taskMenuLayout); void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp); + int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect); /** * Maps the velocity from the coordinate plane of the foreground app to that diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 79e5c87785..e87c887d33 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -32,6 +32,7 @@ import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.LinearLayout; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.PagedView; import com.android.launcher3.Utilities; import com.android.launcher3.util.OverScroller; @@ -257,4 +258,9 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } return new ChildBounds(childWidth, childHeight, childRight, childTop); } + + @Override + public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) { + return dp.heightPx - rect.bottom; + } } diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java index d5ae2dcb16..e91f16d71a 100644 --- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java @@ -18,9 +18,11 @@ package com.android.launcher3.touch; import android.content.res.Resources; import android.graphics.PointF; +import android.graphics.Rect; import android.view.Surface; import android.view.View; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; public class SeascapePagedViewHandler extends LandscapePagedViewHandler { @@ -77,4 +79,9 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { view.setTranslationX(0); view.setTranslationY(translation); } + + @Override + public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) { + return dp.widthPx - rect.right; + } }