From c043d45c42230d112a1a13d563ede0da59d3a4e8 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Thu, 14 Jul 2022 15:51:23 -0400 Subject: [PATCH] Snap to last task if swiping down at a greater Y than X velocity. If you swipe down slightly diagonally, it will almost always be treated as a swipe to the next task rather than a return to the current task. If we are swiping down and the Y velocity is grater, we should snap to the current task instead. Test: Manually in fully gestural mode. Bug: 222117127 Change-Id: I8c3cd483f7ceefe0de1e24b6e98918b12428ed10 --- .../com/android/quickstep/AbsSwipeUpHandler.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 4ac816f8b4..d16ed5ea83 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1052,15 +1052,16 @@ public abstract class AbsSwipeUpHandler, } private GestureEndTarget calculateEndTargetForFlingY(PointF velocity, float endVelocity) { - final boolean isScrollingToNewTask = isScrollingToNewTask(); + // If swiping at a diagonal, base end target on the faster velocity direction. + final boolean willGoToNewTask = + isScrollingToNewTask() && Math.abs(velocity.x) > Math.abs(endVelocity); final boolean isSwipeUp = endVelocity < 0; if (!isSwipeUp) { - return isScrollingToNewTask ? NEW_TASK : LAST_TASK; + final boolean isCenteredOnNewTask = + mRecentsView.getDestinationPage() != mRecentsView.getRunningTaskIndex(); + return willGoToNewTask || isCenteredOnNewTask ? NEW_TASK : LAST_TASK; } - // If swiping upward at a diagonal, base end target on the faster velocity direction. - boolean willGoToNewTask = - isScrollingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity); if (!mDeviceState.isFullyGesturalNavMode()) { return (!hasReachedOverviewThreshold() && willGoToNewTask) ? NEW_TASK : RECENTS; } @@ -1187,6 +1188,9 @@ public abstract class AbsSwipeUpHandler, duration = Math.max(duration, mRecentsView.getScroller().getDuration()); } } + } else if (endTarget == LAST_TASK && mRecentsView != null + && mRecentsView.getNextPage() != mRecentsView.getRunningTaskIndex()) { + mRecentsView.snapToPage(mRecentsView.getRunningTaskIndex(), Math.toIntExact(duration)); } // Let RecentsView handle the scrolling to the task, which we launch in startNewTask()