Merge "Revert "Snap to last task if swiping down at a greater Y than X velocity."" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-17 07:24:00 +00:00
committed by Android (Google) Code Review
@@ -1032,19 +1032,19 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
return RECENTS; return RECENTS;
} }
final GestureEndTarget endTarget; final GestureEndTarget endTarget;
final boolean canGoToNewTask; final boolean goingToNewTask;
if (mRecentsView != null) { if (mRecentsView != null) {
if (!hasTargets()) { if (!hasTargets()) {
// If there are no running tasks, then we can assume that this is a continuation of // If there are no running tasks, then we can assume that this is a continuation of
// the last gesture, but after the recents animation has finished // the last gesture, but after the recents animation has finished
canGoToNewTask = true; goingToNewTask = true;
} else { } else {
final int runningTaskIndex = mRecentsView.getRunningTaskIndex(); final int runningTaskIndex = mRecentsView.getRunningTaskIndex();
final int taskToLaunch = mRecentsView.getNextPage(); final int taskToLaunch = mRecentsView.getNextPage();
canGoToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex; goingToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex;
} }
} else { } else {
canGoToNewTask = false; goingToNewTask = false;
} }
final boolean reachedOverviewThreshold = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW; final boolean reachedOverviewThreshold = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources() final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
@@ -1053,13 +1053,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
if (isCancel) { if (isCancel) {
endTarget = LAST_TASK; endTarget = LAST_TASK;
} else if (mDeviceState.isFullyGesturalNavMode()) { } else if (mDeviceState.isFullyGesturalNavMode()) {
if (canGoToNewTask && isFlingX) { if (goingToNewTask && isFlingX) {
// Flinging towards new task takes precedence over mIsMotionPaused (which only // Flinging towards new task takes precedence over mIsMotionPaused (which only
// checks y-velocity). // checks y-velocity).
endTarget = NEW_TASK; endTarget = NEW_TASK;
} else if (mIsMotionPaused) { } else if (mIsMotionPaused) {
endTarget = RECENTS; endTarget = RECENTS;
} else if (canGoToNewTask) { } else if (goingToNewTask) {
endTarget = NEW_TASK; endTarget = NEW_TASK;
} else { } else {
endTarget = !reachedOverviewThreshold ? LAST_TASK : HOME; endTarget = !reachedOverviewThreshold ? LAST_TASK : HOME;
@@ -1067,22 +1067,26 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
} else { } else {
endTarget = reachedOverviewThreshold && mGestureStarted endTarget = reachedOverviewThreshold && mGestureStarted
? RECENTS ? RECENTS
: canGoToNewTask : goingToNewTask
? NEW_TASK ? NEW_TASK
: LAST_TASK; : LAST_TASK;
} }
} else { } else {
// If swiping at a diagonal, base end target on the faster velocity. // If swiping at a diagonal, base end target on the faster velocity.
boolean isSwipeUp = endVelocity < 0; boolean isSwipeUp = endVelocity < 0;
boolean willGoToNewTask = boolean willGoToNewTaskOnSwipeUp =
canGoToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity); goingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);
if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) { if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp && !willGoToNewTaskOnSwipeUp) {
endTarget = willGoToNewTask ? NEW_TASK : HOME; endTarget = HOME;
} else if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) {
// If swiping at a diagonal, base end target on the faster velocity.
endTarget = NEW_TASK;
} else if (isSwipeUp) { } else if (isSwipeUp) {
endTarget = (!reachedOverviewThreshold && willGoToNewTask) ? NEW_TASK : RECENTS; endTarget = !reachedOverviewThreshold && willGoToNewTaskOnSwipeUp
? NEW_TASK : RECENTS;
} else { } else {
endTarget = willGoToNewTask ? NEW_TASK : LAST_TASK; // Swipe is downward. endTarget = goingToNewTask ? NEW_TASK : LAST_TASK;
} }
} }
@@ -1167,8 +1171,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
duration = Math.max(duration, mRecentsView.getScroller().getDuration()); duration = Math.max(duration, mRecentsView.getScroller().getDuration());
} }
} }
} else if (endTarget == LAST_TASK && mRecentsView != null) {
mRecentsView.snapToPage(mRecentsView.getCurrentPage(), Math.toIntExact(duration));
} }
// Let RecentsView handle the scrolling to the task, which we launch in startNewTask() // Let RecentsView handle the scrolling to the task, which we launch in startNewTask()