Merge "Override INTERPOLATOR_WITHIN_ALL_APPS when app restarts." into udc-dev am: 7c836923b9

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22432465

Change-Id: I200fe6b2c33ba09aa7e86b0ad46c5cecf5333f37
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Holly Jiuyu Sun
2023-04-21 17:40:06 +00:00
committed by Automerger Merge Worker
2 changed files with 23 additions and 3 deletions
@@ -1270,6 +1270,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
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;
@@ -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(() -> {
@@ -338,4 +345,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;
}
}