Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3ce2fc5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 8eaf87e7 1f60acd6
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -1032,19 +1032,19 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            return RECENTS;
        }
        final GestureEndTarget endTarget;
        final boolean canGoToNewTask;
        final boolean goingToNewTask;
        if (mRecentsView != null) {
            if (!hasTargets()) {
                // 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
                canGoToNewTask = true;
                goingToNewTask = true;
            } else {
                final int runningTaskIndex = mRecentsView.getRunningTaskIndex();
                final int taskToLaunch = mRecentsView.getNextPage();
                canGoToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex;
                goingToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex;
            }
        } else {
            canGoToNewTask = false;
            goingToNewTask = false;
        }
        final boolean reachedOverviewThreshold = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
        final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
@@ -1053,13 +1053,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            if (isCancel) {
                endTarget = LAST_TASK;
            } else if (mDeviceState.isFullyGesturalNavMode()) {
                if (canGoToNewTask && isFlingX) {
                if (goingToNewTask && isFlingX) {
                    // Flinging towards new task takes precedence over mIsMotionPaused (which only
                    // checks y-velocity).
                    endTarget = NEW_TASK;
                } else if (mIsMotionPaused) {
                    endTarget = RECENTS;
                } else if (canGoToNewTask) {
                } else if (goingToNewTask) {
                    endTarget = NEW_TASK;
                } else {
                    endTarget = !reachedOverviewThreshold ? LAST_TASK : HOME;
@@ -1067,22 +1067,26 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            } else {
                endTarget = reachedOverviewThreshold && mGestureStarted
                        ? RECENTS
                        : canGoToNewTask
                        : goingToNewTask
                                ? NEW_TASK
                                : LAST_TASK;
            }
        } else {
            // If swiping at a diagonal, base end target on the faster velocity.
            boolean isSwipeUp = endVelocity < 0;
            boolean willGoToNewTask =
                    canGoToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);
            boolean willGoToNewTaskOnSwipeUp =
                    goingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);

            if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) {
                endTarget = willGoToNewTask ? NEW_TASK : HOME;
            if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp && !willGoToNewTaskOnSwipeUp) {
                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) {
                endTarget = (!reachedOverviewThreshold && willGoToNewTask) ? NEW_TASK : RECENTS;
                endTarget = !reachedOverviewThreshold && willGoToNewTaskOnSwipeUp
                        ? NEW_TASK : RECENTS;
            } 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());
                }
            }
        } 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()