diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index a4f8b8135c..38775625b8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -28,6 +28,7 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS; +import static com.android.launcher3.util.ScrollableLayoutManager.PREDICTIVE_BACK_MIN_SCALE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.animation.AnimatorSet; @@ -44,7 +45,6 @@ import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.compat.AccessibilityManagerCompat; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.launcher3.util.DisplayController; @@ -157,10 +157,16 @@ public class NavBarToHomeTouchController implements TouchController, AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_TASK_MENU); } else if (mStartState == ALL_APPS) { AllAppsTransitionController allAppsController = mLauncher.getAllAppsController(); - builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_TRANSLATION, - -mPullbackDistance, PULLBACK_INTERPOLATOR); - builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_ALPHA, - 0.5f, PULLBACK_INTERPOLATOR); + if (mLauncher.getDeviceProfile().shouldShowAllAppsOnSheet()) { + allAppsController.setShouldScaleHeader(true); + builder.addAnimatedFloat(allAppsController.getAllAppScale(), 1f, + PREDICTIVE_BACK_MIN_SCALE, PULLBACK_INTERPOLATOR); + } else { + builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_TRANSLATION, + -mPullbackDistance, PULLBACK_INTERPOLATOR); + builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_ALPHA, + 0.5f, PULLBACK_INTERPOLATOR); + } } AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher); if (topView != null) { diff --git a/quickstep/src/com/android/quickstep/util/BaseDepthController.java b/quickstep/src/com/android/quickstep/util/BaseDepthController.java index eecfba710c..de725682a6 100644 --- a/quickstep/src/com/android/quickstep/util/BaseDepthController.java +++ b/quickstep/src/com/android/quickstep/util/BaseDepthController.java @@ -144,7 +144,7 @@ public class BaseDepthController { } public void pauseBlursOnWindows(boolean pause) { - if (pause == mPauseBlurs) { + if (mPauseBlurs == pause) { return; } mPauseBlurs = pause; diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index ac9159eb3b..fbee05a78a 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -442,7 +442,11 @@ public abstract class LauncherState implements BaseState { } /** Called when predictive back gesture is started. */ - public void onBackStarted(Launcher launcher) {} + public void onBackStarted(Launcher launcher) { + StateManager lsm = launcher.getStateManager(); + LauncherState toState = lsm.getLastState(); + lsm.onBackStarted(toState); + } /** * Called when back action is invoked. This can happen when: diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 9ea58e64ec..b844c46b47 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -557,6 +557,13 @@ public class ActivityAllAppsContainerView return mIsSearching; } + /** + * @return {@code true} if back gesture should exit search rather than change launcher state. + */ + public boolean shouldBackExitSearch() { + return isSearching(); + } + @Override public void onActivePageChanged(int currentActivePage) { if (mSearchTransitionController.isRunning()) { diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 350f763939..7224b1cfdf 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -187,6 +187,8 @@ public class AllAppsTransitionController private boolean mHasScaleEffect; private final MSDLPlayerWrapper mMSDLPlayerWrapper; + // Indicates whether this transition should scale the allapps header in addition to its content. + private boolean mShouldScaleHeader; public AllAppsTransitionController(Launcher l) { mLauncher = l; @@ -273,6 +275,11 @@ public class AllAppsTransitionController setAlphas(state, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER); } + @Override + public void onBackStarted(LauncherState toState) { + setShouldScaleHeader(!mLauncher.getAppsView().shouldBackExitSearch()); + } + @Override public void onBackProgressed( LauncherState toState, @FloatRange(from = 0.0, to = 1.0) float backProgress) { @@ -290,8 +297,8 @@ public class AllAppsTransitionController private void onScaleProgressChanged() { final float scaleProgress = mAllAppScale.value; SCALE_PROPERTY.set(mLauncher.getAppsView(), scaleProgress); - if (!mLauncher.getAppsView().isSearching() - || !mLauncher.getDeviceProfile().shouldShowAllAppsOnSheet()) { + + if (mShouldScaleHeader || !mShouldShowAllAppsOnSheet) { mLauncher.getScrimView().setScrimHeaderScale(scaleProgress); } @@ -313,6 +320,21 @@ public class AllAppsTransitionController } } + /** + * @return AnimatedFloat for all apps scale. This will scale the allapps content by default. + * @see #setShouldScaleHeader(boolean) + */ + public AnimatedFloat getAllAppScale() { + return mAllAppScale; + } + + /** + * Specify whether this transition should scale the allapps header in addition to its content. + */ + public void setShouldScaleHeader(boolean shouldScaleHeader) { + mShouldScaleHeader = shouldScaleHeader; + } + /** Set {@link Animator.AnimatorListener} for scaling all apps scale to 1 animation. */ public void setAllAppsSearchBackAnimationListener(Animator.AnimatorListener listener) { mAllAppsSearchBackAnimationListener = listener; @@ -324,7 +346,7 @@ public class AllAppsTransitionController */ public void animateAllAppsToNoScale() { if (mAllAppScale.isAnimating()) { - return; + mAllAppScale.cancelAnimation(); } Animator animator = mAllAppScale.animateToValue(1f) .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS); diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java index a125331865..bbb46a35fa 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -226,6 +226,13 @@ public class StateManager, T extends StatefulContainer } } + /** Handles back started in predictive back gesture by passing it to state handlers. */ + public void onBackStarted(S toState) { + for (StateHandler handler : getStateHandlers()) { + handler.onBackStarted(toState); + } + } + /** Handles backProgress in predictive back gesture by passing it to state handlers. */ public void onBackProgressed( S toState, @FloatRange(from = 0.0, to = 1.0) float backProgress) { @@ -687,6 +694,9 @@ public class StateManager, T extends StatefulContainer void setStateWithAnimation( STATE_TYPE toState, StateAnimationConfig config, PendingAnimation animation); + /** Handles back started in predictive back gesture for target state. */ + default void onBackStarted(STATE_TYPE toState) {} + /** Handles backProgress in predictive back gesture for target state. */ default void onBackProgressed( STATE_TYPE toState, @FloatRange(from = 0.0, to = 1.0) float backProgress) {}