From 18694a2545eadc30e02fe2353315de7797b2918f Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Fri, 11 Dec 2020 20:41:18 -0800 Subject: [PATCH] Updates quickswitch animation from Launcher. - Workspace/All Apps/Hotseat no longer translate down - Fading of these elements and scaling of Workspace are tied to the wallpaper depth animation - At any point in the drag, you can still swipe up to enter Overview This makes it feel like the apps are tied to the wallpaper and avoids moving them orthogonally to the finger. It also makes the "No recent items" animation more elegant. Demo: https://drive.google.com/file/d/1phuRCqb69vuMp3ijS6PR5lTEcBHScjie/view?usp=sharing&resourcekey=0-2HXtMLUhQ-YU53hYlYV-fQ Demo with no recent apps: https://drive.google.com/file/d/1wjexqznxs9ZhiUtCDW4-ZK6c7hKDRaXn/view?usp=sharing&resourcekey=0-GugbpJK8_cnFbUBB2Ar30w Fixes: 174228745 Test: Manual Change-Id: I1574ff89a0f382b7e63bf03cf4300ec7c695cfec --- .../uioverrides/states/QuickSwitchState.java | 8 +++++++- .../NoButtonQuickSwitchTouchController.java | 13 +++++++------ src/com/android/launcher3/anim/Interpolators.java | 1 - 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java index 965f474b51..53afd211a9 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java @@ -35,7 +35,13 @@ public class QuickSwitchState extends BackgroundAppState { float shiftRange = launcher.getAllAppsController().getShiftRange(); float shiftProgress = getVerticalProgress(launcher) - NORMAL.getVerticalProgress(launcher); float translationY = shiftProgress * shiftRange; - return new ScaleAndTranslation(1, 0, translationY); + return new ScaleAndTranslation(0.9f, 0, translationY); + } + + @Override + public float getVerticalProgress(Launcher launcher) { + // Don't move all apps shelf while quick-switching (just let it fade). + return 1f; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 697516d113..77b0804dd5 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -23,7 +23,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS; import static com.android.launcher3.LauncherState.QUICK_SWITCH; import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD; import static com.android.launcher3.anim.Interpolators.ACCEL_0_75; -import static com.android.launcher3.anim.Interpolators.DEACCEL_5; +import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; @@ -31,9 +31,10 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEUP; import static com.android.launcher3.logging.StatsLogManager.getLauncherAtomEvent; import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE; +import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH; import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE; +import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.states.StateAnimationConfig.SKIP_ALL_ANIMATIONS; import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT; @@ -80,9 +81,8 @@ import com.android.quickstep.views.LauncherRecentsView; public class NoButtonQuickSwitchTouchController implements TouchController, BothAxesSwipeDetector.Listener { - /** The minimum progress of the scale/translationY animation until drag end. */ private static final float Y_ANIM_MIN_PROGRESS = 0.25f; - private static final Interpolator FADE_OUT_INTERPOLATOR = DEACCEL_5; + private static final Interpolator FADE_OUT_INTERPOLATOR = DEACCEL_3; private static final Interpolator TRANSLATE_OUT_INTERPOLATOR = ACCEL_0_75; private static final Interpolator SCALE_DOWN_INTERPOLATOR = LINEAR; private static final long ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW = 300; @@ -187,7 +187,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController, StateAnimationConfig nonOverviewBuilder = new StateAnimationConfig(); nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_FADE, FADE_OUT_INTERPOLATOR); nonOverviewBuilder.setInterpolator(ANIM_ALL_APPS_FADE, FADE_OUT_INTERPOLATOR); - nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, TRANSLATE_OUT_INTERPOLATOR); + nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_SCALE, FADE_OUT_INTERPOLATOR); + nonOverviewBuilder.setInterpolator(ANIM_DEPTH, FADE_OUT_INTERPOLATOR); nonOverviewBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, TRANSLATE_OUT_INTERPOLATOR); updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder); mNonOverviewAnim.dispatchOnStart(); @@ -207,7 +208,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, /** Create state animation to control non-overview components. */ private void updateNonOverviewAnim(LauncherState toState, StateAnimationConfig config) { config.duration = (long) (Math.max(mXRange, mYRange) * 2); - config.animFlags = config.animFlags | SKIP_OVERVIEW; + config.animFlags |= SKIP_OVERVIEW; mNonOverviewAnim = mLauncher.getStateManager() .createAnimationToNewWorkspace(toState, config); mNonOverviewAnim.getTarget().addListener(mClearStateOnCancelListener); diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java index 7980138370..7a389374dc 100644 --- a/src/com/android/launcher3/anim/Interpolators.java +++ b/src/com/android/launcher3/anim/Interpolators.java @@ -46,7 +46,6 @@ public class Interpolators { public static final Interpolator DEACCEL_2 = new DecelerateInterpolator(2); public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f); public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f); - public static final Interpolator DEACCEL_5 = new DecelerateInterpolator(5f); public static final Interpolator ACCEL_DEACCEL = new AccelerateDecelerateInterpolator();