From 7877060d683b0e46d7e3ecb2f15a405ec1ed8b47 Mon Sep 17 00:00:00 2001 From: Holly Sun Date: Fri, 17 Mar 2023 12:09:52 -0700 Subject: [PATCH] Override INTERPOLATOR_WITHIN_ALL_APPS when app restarts. Bug: 225185551 Test: manual. See video https://drive.google.com/corp/drive/u/0/folders/1g-YlbzdHh49SH0f4xLli4BmVqPCP6K49 Flag: the flash issue is only for QS Tile under ENABLE_QS_TILES(OFF) Change-Id: Ib282148bc0a4943c91b5ebd3c78b7128d5d66c9d --- .../allapps/ActivityAllAppsContainerView.java | 5 +++++ .../allapps/SearchTransitionController.java | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 8ea2bfe840..1219c01274 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -1254,6 +1254,11 @@ public class ActivityAllAppsContainerView rv.addOnScrollListener(mScrollListener); } + /** Returns the instance of @{code SearchTransitionController}. */ + public SearchTransitionController getSearchTransitionController() { + return mSearchTransitionController; + } + /** Holds a {@link BaseAllAppsAdapter} and related fields. */ public class AdapterHolder { public static final int MAIN = 0; diff --git a/src/com/android/launcher3/allapps/SearchTransitionController.java b/src/com/android/launcher3/allapps/SearchTransitionController.java index 50567822a6..49dadb54ea 100644 --- a/src/com/android/launcher3/allapps/SearchTransitionController.java +++ b/src/com/android/launcher3/allapps/SearchTransitionController.java @@ -28,6 +28,7 @@ import static com.android.launcher3.anim.Interpolators.INSTANT; import static com.android.launcher3.anim.Interpolators.clampToProgress; import android.animation.ObjectAnimator; +import android.animation.TimeInterpolator; import android.graphics.drawable.Drawable; import android.util.FloatProperty; import android.util.Log; @@ -79,6 +80,7 @@ public class SearchTransitionController { private ObjectAnimator mSearchToAzAnimator = null; private float mSearchToAzProgress = 1f; + private boolean mSkipNextAnimationWithinAllApps; public SearchTransitionController(ActivityAllAppsContainerView allAppsContainerView) { mAllAppsContainerView = allAppsContainerView; @@ -108,11 +110,16 @@ public class SearchTransitionController { mSearchToAzAnimator = ObjectAnimator.ofFloat(this, SEARCH_TO_AZ_PROGRESS, targetProgress); boolean inAllApps = mAllAppsContainerView.isInAllApps(); - if (!inAllApps) { + TimeInterpolator timeInterpolator = + inAllApps ? INTERPOLATOR_WITHIN_ALL_APPS : INTERPOLATOR_TRANSITIONING_TO_ALL_APPS; + if (mSkipNextAnimationWithinAllApps) { + timeInterpolator = INSTANT; + mSkipNextAnimationWithinAllApps = false; + } + if (timeInterpolator == INSTANT) { duration = 0; // Don't want to animate when coming from QSB. } - mSearchToAzAnimator.setDuration(duration).setInterpolator( - inAllApps ? INTERPOLATOR_WITHIN_ALL_APPS : INTERPOLATOR_TRANSITIONING_TO_ALL_APPS); + mSearchToAzAnimator.setDuration(duration).setInterpolator(timeInterpolator); mSearchToAzAnimator.addListener(forEndCallback(() -> mSearchToAzAnimator = null)); if (!goingToSearch) { mSearchToAzAnimator.addListener(forSuccessCallback(() -> { @@ -337,4 +344,12 @@ public class SearchTransitionController { private float getSearchToAzProgress() { return mSearchToAzProgress; } + + /** + * This should only be called from {@code LauncherSearchSessionManager} when app restarts due to + * theme changes. + */ + public void setSkipAnimationWithinAllApps(boolean skip) { + mSkipNextAnimationWithinAllApps = skip; + } }