diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 7875daee4a..2625919ec0 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -68,10 +68,13 @@ public class AllAppsState extends LauncherState { @Override public void onBackInvoked(Launcher launcher) { // In predictive back swipe, onBackInvoked() will be called after onBackStarted(). - // Because the 2nd InteractionJankMonitor.begin() will be ignore within timeout, it's safe - // to call InteractionJankMonitorWrapper.begin here. - InteractionJankMonitorWrapper.begin(launcher.getAppsView(), - Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK); + // In 3 button mode, onBackStarted() is not called but onBackInvoked() will be called. + // Thus In onBackInvoked(), we should only begin instrumenting if we didn't call + // onBackStarted() to start instrumenting CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK. + if (!InteractionJankMonitorWrapper.isInstrumenting(Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK)) { + InteractionJankMonitorWrapper.begin( + launcher.getAppsView(), Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK); + } super.onBackInvoked(launcher); } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index cfa8967c90..3273f27731 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -680,7 +680,7 @@ public class Launcher extends StatefulActivity @Override public void onBackCancelled() { - mStateManager.getState().onBackCancelled(Launcher.this); + Launcher.this.onBackCancelled(); } }; } @@ -2086,6 +2086,10 @@ public class Launcher extends StatefulActivity mStateManager.getState().onBackInvoked(this); } + protected void onBackCancelled() { + mStateManager.getState().onBackCancelled(this); + } + protected void onScreenOnChanged(boolean isOn) { // Reset AllApps to its initial state only if we are not in the middle of // processing a multi-step drop diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 4b65b735bb..799b67b13e 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -85,6 +85,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool; import com.android.launcher3.util.ItemInfoMatcher; +import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; @@ -1366,6 +1367,18 @@ public class ActivityAllAppsContainerView invalidateHeader(); } + /** + * Set {@link Animator.AnimatorListener} on {@link mAllAppsTransitionController} to observe + * animation of backing out of all apps search view to all apps view. + */ + public void setAllAppsSearchBackAnimatorListener(Animator.AnimatorListener listener) { + Preconditions.assertNotNull(mAllAppsTransitionController); + if (mAllAppsTransitionController == null) { + return; + } + mAllAppsTransitionController.setAllAppsSearchBackAnimationListener(listener); + } + public void setScrimView(ScrimView scrimView) { mScrimView = scrimView; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 63f6227941..a4d1dc16c3 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -44,6 +44,7 @@ import android.view.View; import android.view.animation.Interpolator; import androidx.annotation.FloatRange; +import androidx.annotation.Nullable; import com.android.app.animation.Interpolators; import com.android.launcher3.DeviceProfile; @@ -167,6 +168,8 @@ public class AllAppsTransitionController private final AnimatedFloat mAllAppScale = new AnimatedFloat(this::onScaleProgressChanged); private final int mNavScrimFlag; + @Nullable private Animator.AnimatorListener mAllAppsSearchBackAnimationListener; + private boolean mIsVerticalLayout; // Animation in this class is controlled by a single variable {@link mProgress}. @@ -312,11 +315,25 @@ public class AllAppsTransitionController } } - /** Animate all apps view to 1f scale. */ + /** Set {@link Animator.AnimatorListener} for scaling all apps scale to 1 animation. */ + public void setAllAppsSearchBackAnimationListener(Animator.AnimatorListener listener) { + mAllAppsSearchBackAnimationListener = listener; + } + + /** + * Animate all apps view to 1f scale. This is called when backing (exiting) from all apps + * search view to all apps view. + */ public void animateAllAppsToNoScale() { - mAllAppScale.animateToValue(1f) - .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS) - .start(); + if (mAllAppScale.isAnimating()) { + return; + } + Animator animator = mAllAppScale.animateToValue(1f) + .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS); + if (mAllAppsSearchBackAnimationListener != null) { + animator.addListener(mAllAppsSearchBackAnimationListener); + } + animator.start(); } /**