1 package com.android.launcher3; 2 3 import static com.android.launcher3.Utilities.postAsyncCallback; 4 import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE; 5 import static com.android.launcher3.anim.Interpolators.LINEAR; 6 import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; 7 import static com.android.quickstep.views.IconRecentsView.CONTENT_ALPHA; 8 import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; 9 10 import android.animation.AnimatorSet; 11 import android.animation.ObjectAnimator; 12 import android.content.Context; 13 import android.os.Handler; 14 import android.view.View; 15 16 import com.android.quickstep.views.IconRecentsView; 17 import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; 18 import com.android.systemui.shared.system.RemoteAnimationTargetCompat; 19 20 /** 21 * A {@link QuickstepAppTransitionManagerImpl} with recents-specific app transitions based off 22 * {@link com.android.quickstep.views.IconRecentsView}. 23 */ 24 public final class GoLauncherAppTransitionManagerImpl extends QuickstepAppTransitionManagerImpl { 25 GoLauncherAppTransitionManagerImpl(Context context)26 public GoLauncherAppTransitionManagerImpl(Context context) { 27 super(context); 28 } 29 30 @Override isLaunchingFromRecents(View v, RemoteAnimationTargetCompat[] targets)31 protected boolean isLaunchingFromRecents(View v, RemoteAnimationTargetCompat[] targets) { 32 return mLauncher.getStateManager().getState().overviewUi; 33 } 34 35 @Override getWallpaperOpenRunner(boolean fromUnlock)36 RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) { 37 return new GoWallpaperOpenLauncherAnimationRunner(mHandler, 38 false /* startAtFrontOfQueue */, fromUnlock); 39 } 40 41 @Override composeRecentsLaunchAnimator(AnimatorSet anim, View v, RemoteAnimationTargetCompat[] targets, boolean launcherClosing)42 protected void composeRecentsLaunchAnimator(AnimatorSet anim, View v, 43 RemoteAnimationTargetCompat[] targets, boolean launcherClosing) { 44 // Stubbed. Recents launch animation will come from the recents view itself and will not 45 // use remote animations. 46 } 47 48 @Override composeViewContentAnimator(AnimatorSet anim, float[] alphas, float[] trans)49 protected Runnable composeViewContentAnimator(AnimatorSet anim, float[] alphas, float[] trans) { 50 IconRecentsView overview = mLauncher.getOverviewPanel(); 51 ObjectAnimator alpha = ObjectAnimator.ofFloat(overview, 52 CONTENT_ALPHA, alphas); 53 alpha.setDuration(CONTENT_ALPHA_DURATION); 54 alpha.setInterpolator(LINEAR); 55 anim.play(alpha); 56 57 ObjectAnimator transY = ObjectAnimator.ofFloat(overview, View.TRANSLATION_Y, trans); 58 transY.setInterpolator(AGGRESSIVE_EASE); 59 transY.setDuration(CONTENT_TRANSLATION_DURATION); 60 anim.play(transY); 61 62 return mLauncher.getStateManager()::reapplyState; 63 } 64 65 /** 66 * Remote animation runner for animation from app to Launcher. For Go, when going to recents, 67 * we need to ensure that the recents view is ready for remote animation before starting. 68 */ 69 private final class GoWallpaperOpenLauncherAnimationRunner extends 70 WallpaperOpenLauncherAnimationRunner { GoWallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue, boolean fromUnlock)71 public GoWallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue, 72 boolean fromUnlock) { 73 super(handler, startAtFrontOfQueue, fromUnlock); 74 } 75 76 @Override onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, AnimationResult result)77 public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, 78 AnimationResult result) { 79 boolean isGoingToRecents = 80 taskIsATargetWithMode(targetCompats, mLauncher.getTaskId(), MODE_OPENING) 81 && (mLauncher.getStateManager().getState() == LauncherState.OVERVIEW); 82 if (isGoingToRecents) { 83 IconRecentsView recentsView = mLauncher.getOverviewPanel(); 84 if (!recentsView.isReadyForRemoteAnim()) { 85 recentsView.setOnReadyForRemoteAnimCallback(() -> 86 postAsyncCallback(mHandler, () -> onCreateAnimation(targetCompats, result)) 87 ); 88 return; 89 } 90 } 91 super.onCreateAnimation(targetCompats, result); 92 } 93 } 94 } 95