From 52240a3aa069ffd97ffe6a85ed6cd452b295fa2d Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 24 Apr 2018 13:42:59 -0700 Subject: Only detect swipe directions that lead to new states This cleans up the code and ensures that the current state animation is always initialized when we get drag events. Also log when we pass through states. Bug: 78017680 Change-Id: I54ab42923ed539940ea708973ad65f5793669c11 --- .../uioverrides/AllAppsSwipeController.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src_ui_overrides/com/android/launcher3') diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java index d1cddc18f..860be5ff7 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java @@ -17,12 +17,17 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; */ public class AllAppsSwipeController extends AbstractStateChangeTouchController { + private MotionEvent mTouchDownEvent; + public AllAppsSwipeController(Launcher l) { super(l, SwipeDetector.VERTICAL); } @Override protected boolean canInterceptTouch(MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + mTouchDownEvent = ev; + } if (mCurrentAnimation != null) { // If we are already animating from a previous state, we can intercept. return true; @@ -40,18 +45,6 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { return true; } - @Override - protected int getSwipeDirection(MotionEvent ev) { - if (mLauncher.isInState(ALL_APPS)) { - mStartContainerType = ContainerType.ALLAPPS; - return SwipeDetector.DIRECTION_NEGATIVE; - } else { - mStartContainerType = mLauncher.getDragLayer().isEventOverHotseat(ev) ? - ContainerType.HOTSEAT : ContainerType.WORKSPACE; - return SwipeDetector.DIRECTION_POSITIVE; - } - } - @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { if (fromState == NORMAL && isDragTowardPositive) { @@ -62,6 +55,12 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { return fromState; } + @Override + protected int getLogContainerTypeForNormalState() { + return mLauncher.getDragLayer().isEventOverHotseat(mTouchDownEvent) ? + ContainerType.HOTSEAT : ContainerType.WORKSPACE; + } + @Override protected float initCurrentAnimation() { float range = getShiftRange(); -- cgit v1.2.3