Merge "Override INTERPOLATOR_WITHIN_ALL_APPS when app restarts." into udc-dev

This commit is contained in:
Holly Jiuyu Sun
2023-04-21 17:13:03 +00:00
committed by Android (Google) Code Review
2 changed files with 23 additions and 3 deletions
@@ -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;
}
}