From adce95394ef508c5603f48f7e2b681aaf228db76 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Thu, 18 May 2023 17:53:24 -0700 Subject: [PATCH] Enable returning to the previous app after Overview -> All Apps. Back gesture from All Apps (history for state): If previous state was background, use quick switch state to return to the previous app. Swipe down from All Apps: Return to previous state (which will be Normal or Quick Switch). This animates from All Apps overview scale/translation to full screen of the previous task. In this case we are animating from 0.5x Overview scale and 0 translation (centered). Video: https://drive.google.com/file/d/1cpQjtFemtJ4zu9aWu7IiUftWWVGFrbtM/view?usp=drive_link&resourcekey=0-1zuMEvYNsk81YBxv8o10hA Note: This is mostly for the gesture/state handling but it would be nice to polish this transition in the future. Bug: 283336332 Test: Manual Flag: ENABLE_ALL_APPS_FROM_OVERVIEW Change-Id: Iec92df933ce6522f181d3d5ca889b6a6469f4cc6 --- .../launcher3/uioverrides/QuickstepLauncher.java | 2 +- .../uioverrides/states/AllAppsState.java | 15 ++++++++++++++- .../PortraitStatesTouchController.java | 5 ++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index de46ba005d..8037a85ca0 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -525,7 +525,7 @@ public class QuickstepLauncher extends Launcher { } case QUICK_SWITCH_STATE_ORDINAL: { RecentsView rv = getOverviewPanel(); - TaskView tasktolaunch = rv.getTaskViewAt(0); + TaskView tasktolaunch = rv.getCurrentPageTaskView(); if (tasktolaunch != null) { tasktolaunch.launchTask(success -> { if (!success) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index a4db375046..f6a25ce761 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -23,6 +23,7 @@ import android.content.Context; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ActivityContext; @@ -110,7 +111,19 @@ public class AllAppsState extends LauncherState { @Override public LauncherState getHistoryForState(LauncherState previousState) { - return previousState == OVERVIEW ? OVERVIEW : NORMAL; + return previousState == BACKGROUND_APP ? QUICK_SWITCH_FROM_HOME + : previousState == OVERVIEW ? OVERVIEW : NORMAL; + } + + @Override + public float[] getOverviewScaleAndOffset(Launcher launcher) { + if (!FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get()) { + return super.getOverviewScaleAndOffset(launcher); + } + // This handles the case of returning to the previous app from Overview -> All Apps gesture. + // This is the start scale/offset of overview that will be used for that transition. + // TODO (b/283336332): Translate in Y direction (ideally with overview resistance). + return new float[] {0.5f /* scale */, NO_OFFSET}; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index bb74a3650a..454a1f5e91 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -29,6 +29,7 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.allapps.AllAppsTransitionController; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.AllAppsSwipeController; @@ -92,7 +93,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { if (fromState == ALL_APPS && !isDragTowardPositive) { - return NORMAL; + return FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get() + ? mLauncher.getStateManager().getLastState() + : NORMAL; } else if (fromState == OVERVIEW) { return isDragTowardPositive ? OVERVIEW : NORMAL; } else if (fromState == NORMAL && isDragTowardPositive) {