From 6270a0ea18d27952fec20da04d64ca4f7e223849 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 6 Apr 2018 14:22:46 -0700 Subject: [PATCH] When dragging past first or last state, don't reinit target Example bug: 1. Swipe up to overview and let go 2. Swipe all the way to the top of the screen, past where all apps stops 3. Swipe down Before this change, you get reset in NORMAL state instead of OVERVIEW. By ensuring that getTargetState() checks the drag direction before returning a new state, we guarantee we only re-init in the case that the state is actually changing. Otherwise it's possible to change the state to one that is impossible, such as NORMAL when swiping up from ALL APPS. Change-Id: I19913dded9c94228d06289780b6400e99403f378 --- .../uioverrides/LandscapeStatesTouchController.java | 5 +++-- .../uioverrides/PortraitStatesTouchController.java | 2 +- .../touch/AbstractStateChangeTouchController.java | 4 ++++ .../launcher3/uioverrides/AllAppsSwipeController.java | 7 ++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java index 355b88d910..30ceb43f93 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java @@ -60,12 +60,13 @@ public class LandscapeStatesTouchController extends PortraitStatesTouchControlle @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { - if (fromState == ALL_APPS) { + if (fromState == ALL_APPS && !isDragTowardPositive) { // Should swipe down go to OVERVIEW instead? return TouchInteractionService.isConnected() ? mLauncher.getStateManager().getLastState() : NORMAL; - } else { + } else if (isDragTowardPositive) { return ALL_APPS; } + return fromState; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java index 1b65ca0b05..c92264f3a8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java @@ -140,7 +140,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { - if (fromState == ALL_APPS) { + if (fromState == ALL_APPS && !isDragTowardPositive) { // Should swipe down go to OVERVIEW instead? return TouchInteractionService.isConnected() ? mLauncher.getStateManager().getLastState() : NORMAL; diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 9726704ddb..3d85ac3c6d 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -124,6 +124,10 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene return mLauncher.getAllAppsController().getShiftRange(); } + /** + * Returns the state to go to from fromState given the drag direction. If there is no state in + * that direction, returns fromState. + */ protected abstract LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive); diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java index c97c3ccecb..d1cddc18f6 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java @@ -54,7 +54,12 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { - return fromState == ALL_APPS ? NORMAL : ALL_APPS; + if (fromState == NORMAL && isDragTowardPositive) { + return ALL_APPS; + } else if (fromState == ALL_APPS && !isDragTowardPositive) { + return NORMAL; + } + return fromState; } @Override