diff options
author | Vinit Nayak <peanutbutter@google.com> | 2022-05-25 16:42:49 -0700 |
---|---|---|
committer | Vinit Nayak <peanutbutter@google.com> | 2022-05-26 14:43:26 -0700 |
commit | f7b4e7f497437d8ce1df1632bba6dee7b61298c8 (patch) | |
tree | 301d88e0e38dda318e045d50171c0e4c32b61534 | |
parent | f7a48aae655ab5acdfbbe4c675c4d3220c48ca6c (diff) | |
download | Launcher3-f7b4e7f497437d8ce1df1632bba6dee7b61298c8.tar.gz |
Limit starting bounds of swipe to animation start rect
* If the starting point is greater than that of the current
device's width (in either positive or negative direction),
reset the starting rect to be fullscreen task bounds
* More details at b/228829958#comment12
Fixes: 228829958
Test: Reboot device and swipe up from home immediately,
app doesn't fling from the side.
Tested with portrait and landscape launcher.
Tested with fake landscape launcher.
Change-Id: I6ea24e30e9de5716b7830f487b2ed63f56598c50
4 files changed, 33 insertions, 0 deletions
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index 088e1cfc00..966710854f 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -266,6 +266,13 @@ public abstract class SwipeUpAnimationLogic implements RectF cropRectF = new RectF(taskViewSimulator.getCurrentCropRect()); // Move the startRect to Launcher space as floatingIconView runs in Launcher Matrix windowToHomePositionMap = new Matrix(); + + // If the start rect ends up overshooting too much to the left/right offscreen, bring it + // back to fullscreen. This can happen when the recentsScroll value isn't aligned with + // the pageScroll value for a given taskView, see b/228829958#comment12 + mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState().getOrientationHandler() + .fixBoundsForHomeAnimStartRect(startRect, mDp); + homeToWindowPositionMap.invert(windowToHomePositionMap); windowToHomePositionMap.mapRect(startRect); diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 121088a014..b477905dff 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -103,6 +103,17 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } @Override + public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) { + // We don't need to check the "top" value here because the startRect is in the orientation + // of the app, not of the fixed portrait launcher. + if (outStartRect.left > deviceProfile.heightPx) { + outStartRect.offsetTo(0, outStartRect.top); + } else if (outStartRect.left < -deviceProfile.heightPx) { + outStartRect.offsetTo(0, outStartRect.top); + } + } + + @Override public <T> void setPrimary(T target, Int2DAction<T> action, int param) { action.call(target, 0, param); } diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index 4fcf378541..ca46aa8a84 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -226,6 +226,12 @@ public interface PagedOrientationHandler { */ void adjustFloatingIconStartVelocity(PointF velocity); + /** + * Ensures that outStartRect left bound is within the DeviceProfile's visual boundaries + * @param outStartRect The start rect that will directly be modified + */ + void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile); + class ChildBounds { public final int primaryDimension; diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 80a8c19d54..508823c4d0 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -102,6 +102,15 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } @Override + public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) { + if (outStartRect.left > deviceProfile.widthPx) { + outStartRect.offsetTo(0, outStartRect.top); + } else if (outStartRect.left < -deviceProfile.widthPx) { + outStartRect.offsetTo(0, outStartRect.top); + } + } + + @Override public <T> void setPrimary(T target, Int2DAction<T> action, int param) { action.call(target, param, 0); } |