From 1b231ecc56288fcb4b9638775fc811652bbe6510 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 10 Sep 2019 15:19:05 -0700 Subject: [PATCH] Updating launcher interface for recents animation change Bug: 140626334 Change-Id: Ib8e837c157bb99db429b7936fdf111e05170ac25 --- .../GoLauncherAppTransitionManagerImpl.java | 14 ++-- .../AppToOverviewAnimationProvider.java | 16 ++-- .../LauncherAppTransitionManagerImpl.java | 15 ++-- .../AppToOverviewAnimationProvider.java | 13 +-- .../quickstep/OverviewCommandHelper.java | 6 +- .../android/quickstep/RecentsActivity.java | 24 +++--- .../com/android/quickstep/TaskViewUtils.java | 5 +- .../util/RecentsAnimationListenerSet.java | 4 +- .../util/SwipeAnimationTargetSet.java | 10 +-- .../launcher3/LauncherAnimationRunner.java | 8 +- .../launcher3/LauncherInitListener.java | 4 +- .../QuickstepAppTransitionManagerImpl.java | 84 +++++++++++-------- .../launcher3/uioverrides/UiFactory.java | 5 +- .../util/RemoteAnimationProvider.java | 9 +- .../util/RemoteAnimationTargetSet.java | 5 +- .../util/RemoteFadeOutAnimationListener.java | 5 +- 16 files changed, 127 insertions(+), 100 deletions(-) diff --git a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java index bcb1f5c3b4..3953fd0279 100644 --- a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java +++ b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java @@ -40,7 +40,9 @@ public final class GoLauncherAppTransitionManagerImpl extends QuickstepAppTransi @Override protected void composeRecentsLaunchAnimator(AnimatorSet anim, View v, - RemoteAnimationTargetCompat[] targets, boolean launcherClosing) { + RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, + boolean launcherClosing) { // Stubbed. Recents launch animation will come from the recents view itself and will not // use remote animations. } @@ -74,21 +76,23 @@ public final class GoLauncherAppTransitionManagerImpl extends QuickstepAppTransi } @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) { boolean isGoingToRecents = - taskIsATargetWithMode(targetCompats, mLauncher.getTaskId(), MODE_OPENING) + taskIsATargetWithMode(appTargets, mLauncher.getTaskId(), MODE_OPENING) && (mLauncher.getStateManager().getState() == LauncherState.OVERVIEW); if (isGoingToRecents) { IconRecentsView recentsView = mLauncher.getOverviewPanel(); if (!recentsView.isReadyForRemoteAnim()) { recentsView.setOnReadyForRemoteAnimCallback(() -> - postAsyncCallback(mHandler, () -> onCreateAnimation(targetCompats, result)) + postAsyncCallback(mHandler, () -> onCreateAnimation(appTargets, + wallpaperTargets, result)) ); return; } } - super.onCreateAnimation(targetCompats, result); + super.onCreateAnimation(appTargets, wallpaperTargets, result); } } } diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java index 92900f2168..ddf0fff523 100644 --- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -95,11 +95,12 @@ final class AppToOverviewAnimationProvider imple * Create remote window animation from the currently running app to the overview panel. Should * be called after {@link #onActivityReady}. * - * @param targetCompats the target apps + * @param appTargets the target apps * @return animation from app to overview */ @Override - public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targetCompats) { + public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { if (mAnimationReadyListener != null) { mAnimationReadyListener.onWindowAnimationCreated(); } @@ -113,13 +114,13 @@ final class AppToOverviewAnimationProvider imple } RemoteAnimationTargetSet targetSet = - new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING); + new RemoteAnimationTargetSet(appTargets, wallpaperTargets, MODE_CLOSING); mRecentsView.setTransitionedFromApp(!targetSet.isAnimatingHome()); RemoteAnimationTargetCompat recentsTarget = null; RemoteAnimationTargetCompat closingAppTarget = null; - for (RemoteAnimationTargetCompat target : targetCompats) { + for (RemoteAnimationTargetCompat target : appTargets) { if (target.mode == MODE_OPENING) { recentsTarget = target; } else if (target.mode == MODE_CLOSING && target.taskId == mTargetTaskId) { @@ -157,16 +158,17 @@ final class AppToOverviewAnimationProvider imple false /* startAtFrontOfQueue */) { @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) { IconRecentsView recentsView = mRecentsView; if (!recentsView.isReadyForRemoteAnim()) { recentsView.setOnReadyForRemoteAnimCallback(() -> postAsyncCallback(handler, - () -> onCreateAnimation(targetCompats, result)) + () -> onCreateAnimation(appTargets, wallpaperTargets, result)) ); return; } - result.setAnimation(createWindowAnimation(targetCompats), context); + result.setAnimation(createWindowAnimation(appTargets, wallpaperTargets), context); } }; return ActivityOptionsCompat.makeRemoteAnimation( diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index 711594386f..33843977e6 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -30,6 +30,9 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.SpringAnimationBuilder; @@ -38,9 +41,6 @@ import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - /** * A {@link QuickstepAppTransitionManagerImpl} that also implements recents transitions from * {@link RecentsView}. @@ -64,15 +64,16 @@ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransiti @Override protected void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, - @NonNull RemoteAnimationTargetCompat[] targets, boolean launcherClosing) { + @NonNull RemoteAnimationTargetCompat[] appTargets, + @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, boolean launcherClosing) { RecentsView recentsView = mLauncher.getOverviewPanel(); boolean skipLauncherChanges = !launcherClosing; - TaskView taskView = findTaskViewToLaunch(mLauncher, v, targets); + TaskView taskView = findTaskViewToLaunch(mLauncher, v, appTargets); ClipAnimationHelper helper = new ClipAnimationHelper(mLauncher); - anim.play(getRecentsWindowAnimator(taskView, skipLauncherChanges, targets, helper) - .setDuration(RECENTS_LAUNCH_DURATION)); + anim.play(getRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, + wallpaperTargets, helper).setDuration(RECENTS_LAUNCH_DURATION)); Animator childStateAnimation = null; // Found a visible recents task that matches the opening app, lets launch the app from there diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java index ad90e1686e..b939898e1c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -90,11 +90,12 @@ final class AppToOverviewAnimationProvider imple /** * Create remote window animation from the currently running app to the overview panel. * - * @param targetCompats the target apps + * @param appTargets the target apps * @return animation from app to overview */ @Override - public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targetCompats) { + public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { if (mRecentsView != null) { mRecentsView.setRunningTaskIconScaledDown(true); } @@ -114,8 +115,8 @@ final class AppToOverviewAnimationProvider imple return anim; } - RemoteAnimationTargetSet targetSet = - new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING); + RemoteAnimationTargetSet targetSet = new RemoteAnimationTargetSet(appTargets, + wallpaperTargets, MODE_CLOSING); // Use the top closing app to determine the insets for the animation RemoteAnimationTargetCompat runningTaskTarget = targetSet.findTask(mTargetTaskId); @@ -153,8 +154,8 @@ final class AppToOverviewAnimationProvider imple if (targetSet.isAnimatingHome()) { // If we are animating home, fade in the opening targets - RemoteAnimationTargetSet openingSet = - new RemoteAnimationTargetSet(targetCompats, MODE_OPENING); + RemoteAnimationTargetSet openingSet = new RemoteAnimationTargetSet(appTargets, + wallpaperTargets, MODE_OPENING); TransactionCompat transaction = new TransactionCompat(); valueAnimator.addUpdateListener((v) -> { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java index 79273ead5e..af562265af 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java @@ -212,7 +212,8 @@ public class OverviewCommandHelper { return mAnimationProvider.onActivityReady(activity, wasVisible); } - private AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targetCompats) { + private AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { if (LatencyTrackerCompat.isEnabled(mContext)) { LatencyTrackerCompat.logToggleRecents( (int) (SystemClock.uptimeMillis() - mToggleClickedTime)); @@ -220,7 +221,8 @@ public class OverviewCommandHelper { mListener.unregister(); - AnimatorSet animatorSet = mAnimationProvider.createWindowAnimation(targetCompats); + AnimatorSet animatorSet = mAnimationProvider.createWindowAnimation(appTargets, + wallpaperTargets); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java index 9bdc98bf8d..bebd45daa2 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java @@ -16,12 +16,10 @@ package com.android.quickstep; import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION; -import static com.android.launcher3.QuickstepAppTransitionManagerImpl - .STATUS_BAR_TRANSITION_DURATION; -import static com.android.launcher3.QuickstepAppTransitionManagerImpl - .STATUS_BAR_TRANSITION_PRE_DELAY; -import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator; +import static com.android.launcher3.QuickstepAppTransitionManagerImpl.STATUS_BAR_TRANSITION_DURATION; +import static com.android.launcher3.QuickstepAppTransitionManagerImpl.STATUS_BAR_TRANSITION_PRE_DELAY; import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; +import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import android.animation.Animator; @@ -152,9 +150,10 @@ public final class RecentsActivity extends BaseRecentsActivity { true /* startAtFrontOfQueue */) { @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, - AnimationResult result) { - AnimatorSet anim = composeRecentsLaunchAnimator(taskView, targetCompats); + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) { + AnimatorSet anim = composeRecentsLaunchAnimator(taskView, appTargets, + wallpaperTargets); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -174,12 +173,13 @@ public final class RecentsActivity extends BaseRecentsActivity { * Composes the animations for a launch from the recents list if possible. */ private AnimatorSet composeRecentsLaunchAnimator(TaskView taskView, - RemoteAnimationTargetCompat[] targets) { + RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { AnimatorSet target = new AnimatorSet(); - boolean activityClosing = taskIsATargetWithMode(targets, getTaskId(), MODE_CLOSING); + boolean activityClosing = taskIsATargetWithMode(appTargets, getTaskId(), MODE_CLOSING); ClipAnimationHelper helper = new ClipAnimationHelper(this); - target.play(getRecentsWindowAnimator(taskView, !activityClosing, targets, helper) - .setDuration(RECENTS_LAUNCH_DURATION)); + target.play(getRecentsWindowAnimator(taskView, !activityClosing, appTargets, + wallpaperTargets, helper).setDuration(RECENTS_LAUNCH_DURATION)); // Found a visible recents task that matches the opening app, lets launch the app from there if (activityClosing) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskViewUtils.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskViewUtils.java index 6897c1e7d7..00fa0f2745 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskViewUtils.java @@ -111,14 +111,15 @@ public final class TaskViewUtils { * animation. */ public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges, - RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) { + RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, final ClipAnimationHelper inOutHelper) { SyncRtSurfaceTransactionApplierCompat applier = new SyncRtSurfaceTransactionApplierCompat(v); ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams() .setSyncTransactionApplier(applier); final RemoteAnimationTargetSet targetSet = - new RemoteAnimationTargetSet(targets, MODE_OPENING); + new RemoteAnimationTargetSet(appTargets, wallpaperTargets, MODE_OPENING); targetSet.addDependentTransactionApplier(applier); final RecentsView recentsView = v.getRecentsView(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RecentsAnimationListenerSet.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RecentsAnimationListenerSet.java index 4299d1a84a..71ad8ba8be 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RecentsAnimationListenerSet.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RecentsAnimationListenerSet.java @@ -79,8 +79,8 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener { Rect homeContentInsets, Rect minimizedHomeBounds) { mController = controller; SwipeAnimationTargetSet targetSet = new SwipeAnimationTargetSet(controller, appTargets, - homeContentInsets, minimizedHomeBounds, mShouldMinimizeSplitScreen, - mOnFinishListener); + wallpaperTargets, homeContentInsets, minimizedHomeBounds, + mShouldMinimizeSplitScreen, mOnFinishListener); if (mCancelled) { targetSet.cancelAnimation(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java index 3619d3a0e8..3da6b78e72 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java @@ -41,10 +41,10 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet { public final Rect minimizedHomeBounds; public SwipeAnimationTargetSet(RecentsAnimationControllerCompat controller, - RemoteAnimationTargetCompat[] targets, Rect homeContentInsets, - Rect minimizedHomeBounds, boolean shouldMinimizeSplitScreen, + RemoteAnimationTargetCompat[] apps, RemoteAnimationTargetCompat[] wallpapers, + Rect homeContentInsets, Rect minimizedHomeBounds, boolean shouldMinimizeSplitScreen, Consumer onFinishListener) { - super(targets, MODE_CLOSING); + super(apps, wallpapers, MODE_CLOSING); this.controller = controller; this.homeContentInsets = homeContentInsets; this.minimizedHomeBounds = minimizedHomeBounds; @@ -62,8 +62,8 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet { */ public SwipeAnimationTargetSet cloneWithoutTargets() { return new SwipeAnimationTargetSet(controller, new RemoteAnimationTargetCompat[0], - homeContentInsets, minimizedHomeBounds, mShouldMinimizeSplitScreen, - mOnFinishListener); + new RemoteAnimationTargetCompat[0], homeContentInsets, minimizedHomeBounds, + mShouldMinimizeSplitScreen, mOnFinishListener); } public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint) { diff --git a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java index a7aab6d080..96ac489d80 100644 --- a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java +++ b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java @@ -17,8 +17,7 @@ package com.android.launcher3; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs; -import static com.android.systemui.shared.recents.utilities.Utilities - .postAtFrontOfQueueAsynchronously; +import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -57,7 +56,7 @@ public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCo Runnable r = () -> { finishExistingAnimation(); mAnimationResult = new AnimationResult(runnable); - onCreateAnimation(appTargets, mAnimationResult); + onCreateAnimation(appTargets, wallpaperTargets, mAnimationResult); }; if (mStartAtFrontOfQueue) { postAtFrontOfQueueAsynchronously(mHandler, r); @@ -79,7 +78,8 @@ public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCo */ @UiThread public abstract void onCreateAnimation( - RemoteAnimationTargetCompat[] targetCompats, AnimationResult result); + RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result); @UiThread private void finishExistingAnimation() { diff --git a/quickstep/src/com/android/launcher3/LauncherInitListener.java b/quickstep/src/com/android/launcher3/LauncherInitListener.java index 38f9956203..272d1175b1 100644 --- a/quickstep/src/com/android/launcher3/LauncherInitListener.java +++ b/quickstep/src/com/android/launcher3/LauncherInitListener.java @@ -49,7 +49,7 @@ public class LauncherInitListener extends InternalStateHandler implements Activi // Set a one-time animation provider. After the first call, this will get cleared. // TODO: Probably also check the intended target id. CancellationSignal cancellationSignal = new CancellationSignal(); - appTransitionManager.setRemoteAnimationProvider((targets) -> { + appTransitionManager.setRemoteAnimationProvider((appTargets, wallpaperTargets) -> { // On the first call clear the reference. cancellationSignal.cancel(); @@ -57,7 +57,7 @@ public class LauncherInitListener extends InternalStateHandler implements Activi mRemoteAnimationProvider = null; if (provider != null && launcher.getStateManager().getState().overviewUi) { - return provider.createWindowAnimation(targets); + return provider.createWindowAnimation(appTargets, wallpaperTargets); } return null; }, cancellationSignal); diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index f05fc766d5..7cd87860ac 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -202,17 +202,19 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans true /* startAtFrontOfQueue */) { @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, - AnimationResult result) { + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) { AnimatorSet anim = new AnimatorSet(); boolean launcherClosing = - launcherIsATargetWithMode(targetCompats, MODE_CLOSING); + launcherIsATargetWithMode(appTargets, MODE_CLOSING); - if (isLaunchingFromRecents(v, targetCompats)) { - composeRecentsLaunchAnimator(anim, v, targetCompats, launcherClosing); + if (isLaunchingFromRecents(v, appTargets)) { + composeRecentsLaunchAnimator(anim, v, appTargets, wallpaperTargets, + launcherClosing); } else { - composeIconLaunchAnimator(anim, v, targetCompats, launcherClosing); + composeIconLaunchAnimator(anim, v, appTargets, wallpaperTargets, + launcherClosing); } if (launcherClosing) { @@ -255,36 +257,39 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans * * @param anim the animator set to add to * @param v the launching view - * @param targets the apps that are opening/closing + * @param appTargets the apps that are opening/closing * @param launcherClosing true if the launcher app is closing */ protected abstract void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, - @NonNull RemoteAnimationTargetCompat[] targets, boolean launcherClosing); + @NonNull RemoteAnimationTargetCompat[] appTargets, + @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, boolean launcherClosing); /** * Compose the animations for a launch from the app icon. * * @param anim the animation to add to * @param v the launching view with the icon - * @param targets the list of opening/closing apps + * @param appTargets the list of opening/closing apps * @param launcherClosing true if launcher is closing */ private void composeIconLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, - @NonNull RemoteAnimationTargetCompat[] targets, boolean launcherClosing) { + @NonNull RemoteAnimationTargetCompat[] appTargets, + @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, + boolean launcherClosing) { // Set the state animation first so that any state listeners are called // before our internal listeners. mLauncher.getStateManager().setCurrentAnimation(anim); - Rect windowTargetBounds = getWindowTargetBounds(targets); + Rect windowTargetBounds = getWindowTargetBounds(appTargets); boolean isAllOpeningTargetTrs = true; - for (int i = 0; i < targets.length; i++) { - RemoteAnimationTargetCompat target = targets[i]; + for (int i = 0; i < appTargets.length; i++) { + RemoteAnimationTargetCompat target = appTargets[i]; if (target.mode == MODE_OPENING) { isAllOpeningTargetTrs &= target.isTranslucent; } if (!isAllOpeningTargetTrs) break; } - anim.play(getOpeningWindowAnimators(v, targets, windowTargetBounds, + anim.play(getOpeningWindowAnimators(v, appTargets, wallpaperTargets, windowTargetBounds, !isAllOpeningTargetTrs)); if (launcherClosing) { Pair launcherContentAnimator = @@ -305,10 +310,10 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans * In multiwindow mode, we need to get the final size of the opening app window target to help * figure out where the floating view should animate to. */ - private Rect getWindowTargetBounds(RemoteAnimationTargetCompat[] targets) { + private Rect getWindowTargetBounds(RemoteAnimationTargetCompat[] appTargets) { Rect bounds = new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx); if (mLauncher.isInMultiWindowMode()) { - for (RemoteAnimationTargetCompat target : targets) { + for (RemoteAnimationTargetCompat target : appTargets) { if (target.mode == MODE_OPENING) { bounds.set(target.sourceContainerBounds); bounds.offsetTo(target.position.x, target.position.y); @@ -418,7 +423,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans /** * @return Animator that controls the window of the opening targets. */ - private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets, + private ValueAnimator getOpeningWindowAnimators(View v, + RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, Rect windowTargetBounds, boolean toggleVisibility) { RectF bounds = new RectF(); FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, @@ -426,8 +433,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans Rect crop = new Rect(); Matrix matrix = new Matrix(); - RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(targets, - MODE_OPENING); + RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(appTargets, + wallpaperTargets, MODE_OPENING); SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(floatingView); openingTargets.addDependentTransactionApplier(surfaceApplier); @@ -551,9 +558,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans float croppedHeight = (windowTargetBounds.height() - crop.height()) * scale; float croppedWidth = (windowTargetBounds.width() - crop.width()) * scale; - SurfaceParams[] params = new SurfaceParams[targets.length]; - for (int i = targets.length - 1; i >= 0; i--) { - RemoteAnimationTargetCompat target = targets[i]; + SurfaceParams[] params = new SurfaceParams[appTargets.length]; + for (int i = appTargets.length - 1; i >= 0; i--) { + RemoteAnimationTargetCompat target = appTargets[i]; Rect targetCrop; final float alpha; final float cornerRadius; @@ -619,7 +626,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans /** * Animator that controls the transformations of the windows when unlocking the device. */ - private Animator getUnlockWindowAnimator(RemoteAnimationTargetCompat[] targets) { + private Animator getUnlockWindowAnimator(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(mDragLayer); ValueAnimator unlockAnimator = ValueAnimator.ofFloat(0, 1); @@ -629,9 +637,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans unlockAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - SurfaceParams[] params = new SurfaceParams[targets.length]; - for (int i = targets.length - 1; i >= 0; i--) { - RemoteAnimationTargetCompat target = targets[i]; + SurfaceParams[] params = new SurfaceParams[appTargets.length]; + for (int i = appTargets.length - 1; i >= 0; i--) { + RemoteAnimationTargetCompat target = appTargets[i]; params[i] = new SurfaceParams(target.leash, 1f, null, target.sourceContainerBounds, RemoteAnimationProvider.getLayer(target, MODE_OPENING), cornerRadius); @@ -645,7 +653,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans /** * Animator that controls the transformations of the windows the targets that are closing. */ - private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) { + private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(mDragLayer); Matrix matrix = new Matrix(); @@ -661,9 +670,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans @Override public void onUpdate(float percent) { - SurfaceParams[] params = new SurfaceParams[targets.length]; - for (int i = targets.length - 1; i >= 0; i--) { - RemoteAnimationTargetCompat target = targets[i]; + SurfaceParams[] params = new SurfaceParams[appTargets.length]; + for (int i = appTargets.length - 1; i >= 0; i--) { + RemoteAnimationTargetCompat target = appTargets[i]; final float alpha; final float cornerRadius; if (target.mode == MODE_CLOSING) { @@ -764,11 +773,12 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans } @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, LauncherAnimationRunner.AnimationResult result) { if (mLauncher.isDestroyed()) { AnimatorSet anim = new AnimatorSet(); - anim.play(getClosingWindowAnimators(targetCompats)); + anim.play(getClosingWindowAnimators(appTargets, wallpaperTargets)); result.setAnimation(anim, mLauncher.getApplicationContext()); return; } @@ -777,7 +787,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans // If launcher is not resumed, wait until new async-frame after resume mLauncher.addOnResumeCallback(() -> postAsyncCallback(mHandler, () -> - onCreateAnimation(targetCompats, result))); + onCreateAnimation(appTargets, wallpaperTargets, result))); return; } @@ -789,14 +799,14 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans AnimatorSet anim = null; RemoteAnimationProvider provider = mRemoteAnimationProvider; if (provider != null) { - anim = provider.createWindowAnimation(targetCompats); + anim = provider.createWindowAnimation(appTargets, wallpaperTargets); } if (anim == null) { anim = new AnimatorSet(); anim.play(mFromUnlock - ? getUnlockWindowAnimator(targetCompats) - : getClosingWindowAnimators(targetCompats)); + ? getUnlockWindowAnimator(appTargets, wallpaperTargets) + : getClosingWindowAnimators(appTargets, wallpaperTargets)); // Normally, we run the launcher content animation when we are transitioning // home, but if home is already visible, then we don't want to animate the @@ -806,7 +816,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans // targets list because it is already visible). In that case, we force // invisibility on touch down, and only reset it after the animation to home // is initialized. - if (launcherIsATargetWithMode(targetCompats, MODE_OPENING) + if (launcherIsATargetWithMode(appTargets, MODE_OPENING) || mLauncher.isForceInvisible()) { // Only register the content animation for cancellation when state changes mLauncher.getStateManager().setCurrentAnimation(anim); diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index c02df9386c..b0b5dcf751 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -165,13 +165,14 @@ public class UiFactory extends RecentsUiFactory { CancellationSignal cancellationSignal) { QuickstepAppTransitionManagerImpl appTransitionManager = (QuickstepAppTransitionManagerImpl) launcher.getAppTransitionManager(); - appTransitionManager.setRemoteAnimationProvider((targets) -> { + appTransitionManager.setRemoteAnimationProvider((appTargets, wallpaperTargets) -> { // On the first call clear the reference. cancellationSignal.cancel(); ValueAnimator fadeAnimation = ValueAnimator.ofFloat(1, 0); - fadeAnimation.addUpdateListener(new RemoteFadeOutAnimationListener(targets)); + fadeAnimation.addUpdateListener(new RemoteFadeOutAnimationListener(appTargets, + wallpaperTargets)); AnimatorSet anim = new AnimatorSet(); anim.play(fadeAnimation); return anim; diff --git a/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java b/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java index 4503a43542..6210fc2008 100644 --- a/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java +++ b/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java @@ -31,16 +31,17 @@ public interface RemoteAnimationProvider { static final int Z_BOOST_BASE = 800570000; - AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targets); + AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets); default ActivityOptions toActivityOptions(Handler handler, long duration, Context context) { LauncherAnimationRunner runner = new LauncherAnimationRunner(handler, false /* startAtFrontOfQueue */) { @Override - public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, - AnimationResult result) { - result.setAnimation(createWindowAnimation(targetCompats), context); + public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) { + result.setAnimation(createWindowAnimation(appTargets, wallpaperTargets), context); } }; return ActivityOptionsCompat.makeRemoteAnimation( diff --git a/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java b/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java index 1229293e6e..d769248b2b 100644 --- a/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java +++ b/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java @@ -32,10 +32,12 @@ public class RemoteAnimationTargetSet { public final RemoteAnimationTargetCompat[] unfilteredApps; public final RemoteAnimationTargetCompat[] apps; + public final RemoteAnimationTargetCompat[] wallpapers; public final int targetMode; public final boolean hasRecents; - public RemoteAnimationTargetSet(RemoteAnimationTargetCompat[] apps, int targetMode) { + public RemoteAnimationTargetSet(RemoteAnimationTargetCompat[] apps, + RemoteAnimationTargetCompat[] wallpapers, int targetMode) { ArrayList filteredApps = new ArrayList<>(); boolean hasRecents = false; if (apps != null) { @@ -51,6 +53,7 @@ public class RemoteAnimationTargetSet { this.unfilteredApps = apps; this.apps = filteredApps.toArray(new RemoteAnimationTargetCompat[filteredApps.size()]); + this.wallpapers = wallpapers; this.targetMode = targetMode; this.hasRecents = hasRecents; } diff --git a/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java b/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java index 40dd74bbb5..1d0851c493 100644 --- a/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java +++ b/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java @@ -32,8 +32,9 @@ public class RemoteFadeOutAnimationListener implements AnimatorUpdateListener { private final RemoteAnimationTargetSet mTarget; private boolean mFirstFrame = true; - public RemoteFadeOutAnimationListener(RemoteAnimationTargetCompat[] targets) { - mTarget = new RemoteAnimationTargetSet(targets, MODE_CLOSING); + public RemoteFadeOutAnimationListener(RemoteAnimationTargetCompat[] appTargets, + RemoteAnimationTargetCompat[] wallpaperTargets) { + mTarget = new RemoteAnimationTargetSet(appTargets, wallpaperTargets, MODE_CLOSING); } @Override