Allow quick switch from 3P launcher home in 2 button mode

Only the FallbackSwipeHandler supports quickswitch mode on the
home screen, but we only used that handler for fully gestural
mode. Now we also use that handler for 2-button mode if both
of these conditions are met:
- User is on the home screen
- User swipes right on the nav region (instead of up)

Also fix issues with continuous quick switch gestures by setting
the appropriate end target NEW_TASK instead of HOME.

Bug: 140467002
Change-Id: I8f327638b48cf4c0acb1ebe265b7846afac6759b
This commit is contained in:
Tony Wickham
2019-12-09 19:11:09 -08:00
parent 56c9c86fe9
commit a06ad834d0
2 changed files with 24 additions and 4 deletions
@@ -266,7 +266,7 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
@Override
public void onConsumerAboutToBeSwitched() {
if (mInQuickSwitchMode && mGestureState.getEndTarget() != null) {
mGestureState.setEndTarget(HOME);
mGestureState.setEndTarget(NEW_TASK);
mCanceled = true;
mCurrentShift.cancelAnimation();
@@ -559,10 +559,13 @@ public class TouchInteractionService extends Service implements PluginListener<O
final boolean shouldDefer;
final BaseSwipeUpHandler.Factory factory;
if (mDeviceState.isFullyGesturalNavMode()
&& !mOverviewComponentObserver.isHomeAndOverviewSame()) {
if (!mOverviewComponentObserver.isHomeAndOverviewSame()) {
shouldDefer = previousGestureState.getFinishingRecentsAnimationTaskId() < 0;
factory = mFallbackSwipeHandlerFactory;
if (mDeviceState.isFullyGesturalNavMode()) {
factory = mFallbackSwipeHandlerFactory;
} else {
factory = this::determineFallbackTwoButtonSwipeHandler;
}
} else {
shouldDefer = gestureState.getActivityInterface().deferStartingActivity(mDeviceState,
event);
@@ -575,6 +578,23 @@ public class TouchInteractionService extends Service implements PluginListener<O
mInputMonitorCompat, disableHorizontalSwipe, factory);
}
/**
* Determines whether to use the LauncherSwipeHandler or FallbackSwipeHandler at runtime.
* We need to use the FallbackSwipeHandler to handle quick switch from home, otherwise the
* normal LauncherSwipeHandler works.
*/
private BaseSwipeUpHandler determineFallbackTwoButtonSwipeHandler(GestureState gestureState,
long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
boolean runningOverHome = gestureState.getRunningTask() == null
|| ActivityManagerWrapper.isHomeTask(gestureState.getRunningTask());
boolean isQuickSwitchMode = isLikelyToStartNewTask || continuingLastGesture;
BaseSwipeUpHandler.Factory factory = runningOverHome && isQuickSwitchMode
? mFallbackSwipeHandlerFactory
: mLauncherSwipeHandlerFactory;
return factory.newHandler(gestureState, touchTimeMs, continuingLastGesture,
isLikelyToStartNewTask);
}
private InputConsumer createDeviceLockedInputConsumer(GestureState gestureState) {
if (mDeviceState.isFullyGesturalNavMode() && gestureState.getRunningTask() != null) {
return new DeviceLockedInputConsumer(this, mDeviceState, mTaskAnimationManager,