summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2018-04-24 13:42:59 -0700
committerTony Wickham <twickham@google.com>2018-05-03 14:04:25 -0700
commit52240a3aa069ffd97ffe6a85ed6cd452b295fa2d (patch)
tree279ec401bedc41a613c3ee481197e34a5da0447f
parentf325b19de384da8666af558f65933e0243508349 (diff)
downloadpackages_apps_Trebuchet-52240a3aa069ffd97ffe6a85ed6cd452b295fa2d.tar.gz
packages_apps_Trebuchet-52240a3aa069ffd97ffe6a85ed6cd452b295fa2d.tar.bz2
packages_apps_Trebuchet-52240a3aa069ffd97ffe6a85ed6cd452b295fa2d.zip
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
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java11
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java5
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java27
-rw-r--r--src/com/android/launcher3/touch/AbstractStateChangeTouchController.java58
-rw-r--r--src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java23
5 files changed, 72 insertions, 52 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java
index a7cf54531..42f6c74dc 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java
@@ -11,6 +11,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.touch.AbstractStateChangeTouchController;
import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.util.SysuiEventLogger;
@@ -39,17 +40,17 @@ public class LandscapeEdgeSwipeController extends AbstractStateChangeTouchContro
}
@Override
- protected int getSwipeDirection(MotionEvent ev) {
- return SwipeDetector.DIRECTION_BOTH;
- }
-
- @Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
boolean draggingFromNav = mLauncher.getDeviceProfile().isSeascape() != isDragTowardPositive;
return draggingFromNav ? OVERVIEW : NORMAL;
}
@Override
+ protected int getLogContainerTypeForNormalState() {
+ return LauncherLogProto.ContainerType.NAVBAR;
+ }
+
+ @Override
protected float getShiftRange() {
return mLauncher.getDragLayer().getWidth();
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java
index e7816be3a..0f9b57f03 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java
@@ -24,6 +24,7 @@ import android.view.MotionEvent;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.views.RecentsView;
@@ -72,4 +73,8 @@ public class OverviewToAllAppsTouchController extends PortraitStatesTouchControl
return fromState;
}
+ @Override
+ protected int getLogContainerTypeForNormalState() {
+ return LauncherLogProto.ContainerType.WORKSPACE;
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
index 2a603d763..2f0bdc6b3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
@@ -125,26 +125,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
}
@Override
- protected int getSwipeDirection(MotionEvent ev) {
- final int directionsToDetectScroll;
- if (mLauncher.isInState(ALL_APPS)) {
- directionsToDetectScroll = SwipeDetector.DIRECTION_NEGATIVE;
- mStartContainerType = ContainerType.ALLAPPS;
- } else if (mLauncher.isInState(NORMAL)) {
- directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE;
- mStartContainerType = ContainerType.HOTSEAT;
- } else if (mLauncher.isInState(OVERVIEW)) {
- boolean canSwipeDownFromOverview = getTargetState(OVERVIEW, false) != OVERVIEW;
- directionsToDetectScroll = canSwipeDownFromOverview ? SwipeDetector.DIRECTION_BOTH
- : SwipeDetector.DIRECTION_POSITIVE;
- mStartContainerType = ContainerType.TASKSWITCHER;
- } else {
- return 0;
- }
- return directionsToDetectScroll;
- }
-
- @Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
if (fromState == ALL_APPS && !isDragTowardPositive) {
// Should swipe down go to OVERVIEW instead?
@@ -152,12 +132,17 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
mLauncher.getStateManager().getLastState() : NORMAL;
} else if (fromState == OVERVIEW) {
return isDragTowardPositive ? ALL_APPS : NORMAL;
- } else if (isDragTowardPositive) {
+ } else if (fromState == NORMAL && isDragTowardPositive) {
return TouchInteractionService.isConnected() ? OVERVIEW : ALL_APPS;
}
return fromState;
}
+ @Override
+ protected int getLogContainerTypeForNormalState() {
+ return ContainerType.HOTSEAT;
+ }
+
private AnimatorSetBuilder getNormalToOverviewAnimation() {
mAllAppsInterpolatorWrapper.baseInterpolator = mAllAppsDampedInterpolator;
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index d5c0788e1..658af955a 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -15,6 +15,9 @@
*/
package com.android.launcher3.touch;
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
@@ -27,6 +30,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.TouchController;
@@ -65,12 +69,6 @@ public abstract class AbstractStateChangeTouchController
protected abstract boolean canInterceptTouch(MotionEvent ev);
- /**
- * Initializes the {@code mFromState} and {@code mToState} and swipe direction to use for
- * the detector. In case of disabling swipe, return 0.
- */
- protected abstract int getSwipeDirection(MotionEvent ev);
-
@Override
public final boolean onControllerInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
@@ -94,7 +92,7 @@ public abstract class AbstractStateChangeTouchController
ignoreSlopWhenSettling = true;
}
} else {
- directionsToDetectScroll = getSwipeDirection(ev);
+ directionsToDetectScroll = getSwipeDirection();
if (directionsToDetectScroll == 0) {
mNoIntercept = true;
return false;
@@ -112,6 +110,18 @@ public abstract class AbstractStateChangeTouchController
return mDetector.isDraggingOrSettling();
}
+ private int getSwipeDirection() {
+ LauncherState fromState = mLauncher.getStateManager().getState();
+ int swipeDirection = 0;
+ if (getTargetState(fromState, true /* isDragTowardPositive */) != fromState) {
+ swipeDirection |= SwipeDetector.DIRECTION_POSITIVE;
+ }
+ if (getTargetState(fromState, false /* isDragTowardPositive */) != fromState) {
+ swipeDirection |= SwipeDetector.DIRECTION_NEGATIVE;
+ }
+ return swipeDirection;
+ }
+
@Override
public final boolean onControllerTouchEvent(MotionEvent ev) {
return mDetector.onTouchEvent(ev);
@@ -130,6 +140,11 @@ public abstract class AbstractStateChangeTouchController
protected abstract float initCurrentAnimation();
+ /**
+ * Returns the container that the touch started from when leaving NORMAL state.
+ */
+ protected abstract int getLogContainerTypeForNormalState();
+
private boolean reinitCurrentAnimation(boolean reachedToState, boolean isDragTowardPositive) {
LauncherState newFromState = mFromState == null ? mLauncher.getStateManager().getState()
: reachedToState ? mToState : mFromState;
@@ -139,6 +154,17 @@ public abstract class AbstractStateChangeTouchController
return false;
}
+ if (reachedToState) {
+ logReachedState(Touch.SWIPE);
+ }
+ if (newFromState == ALL_APPS) {
+ mStartContainerType = ContainerType.ALLAPPS;
+ } else if (newFromState == NORMAL) {
+ mStartContainerType = getLogContainerTypeForNormalState();
+ } else if (newFromState == OVERVIEW){
+ mStartContainerType = ContainerType.TASKSWITCHER;
+ }
+
mFromState = newFromState;
mToState = newToState;
@@ -261,18 +287,22 @@ public abstract class AbstractStateChangeTouchController
}
if (shouldGoToTargetState) {
if (targetState != mFromState) {
- // Transition complete. log the action
- mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
- getDirectionForLog(),
- mStartContainerType,
- mFromState.containerType,
- mToState.containerType,
- mLauncher.getWorkspace().getCurrentPage());
+ logReachedState(logAction);
}
mLauncher.getStateManager().goToState(targetState, false /* animated */);
}
}
+ private void logReachedState(int logAction) {
+ // Transition complete. log the action
+ mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
+ getDirectionForLog(),
+ mStartContainerType,
+ mFromState.containerType,
+ mToState.containerType,
+ mLauncher.getWorkspace().getCurrentPage());
+ }
+
protected void clearState() {
mCurrentAnimation = null;
mDetector.finishedScrolling();
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;
@@ -41,18 +46,6 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
}
@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) {
return ALL_APPS;
@@ -63,6 +56,12 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
}
@Override
+ protected int getLogContainerTypeForNormalState() {
+ return mLauncher.getDragLayer().isEventOverHotseat(mTouchDownEvent) ?
+ ContainerType.HOTSEAT : ContainerType.WORKSPACE;
+ }
+
+ @Override
protected float initCurrentAnimation() {
float range = getShiftRange();
long maxAccuracy = (long) (2 * range);