diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index b5c834dd31..56c28f071e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -38,9 +38,9 @@ import com.android.quickstep.RecentsAnimationCallbacks; import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener; import com.android.quickstep.RecentsAnimationController; import com.android.quickstep.SystemUiProxy; +import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.ThumbnailData; - /** * A data source which integrates with a Launcher instance */ @@ -159,8 +159,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController { * automatically reset once the recents animation finishes */ public Animator createAnimToLauncher(@NonNull LauncherState toState, - @NonNull RecentsAnimationCallbacks callbacks, - long duration) { + @NonNull RecentsAnimationCallbacks callbacks, long duration) { TaskbarStashController stashController = mControllers.taskbarStashController; ObjectAnimator animator = mIconAlignmentForGestureState .animateToValue(1) @@ -180,31 +179,15 @@ public class LauncherTaskbarUIController extends TaskbarUIController { stashController.animateToIsStashed(false, duration); } }); - callbacks.addListener(new RecentsAnimationListener() { - @Override - public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) { - endGestureStateOverride(true); - } - @Override - public void onRecentsAnimationFinished(RecentsAnimationController controller) { - endGestureStateOverride(!controller.getFinishTargetIsLauncher()); - } - - private void endGestureStateOverride(boolean finishedToApp) { - callbacks.removeListener(this); - mIsAnimatingToLauncherViaGesture = false; - - mIconAlignmentForGestureState - .animateToValue(0) - .start(); - - if (finishedToApp) { - // We only need this for the exiting live tile case. - stashController.animateToIsStashed(stashController.isStashedInApp()); - } - } + TaskBarRecentsAnimationListener listener = new TaskBarRecentsAnimationListener(callbacks); + callbacks.addListener(listener); + RecentsView recentsView = mLauncher.getOverviewPanel(); + recentsView.setTaskLaunchListener(() -> { + listener.endGestureStateOverride(true); + callbacks.removeListener(listener); }); + return animator; } @@ -249,4 +232,36 @@ public class LauncherTaskbarUIController extends TaskbarUIController { mIconAlphaForHome.setValue(isVisible ? 1 : 0); mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f); } + + private final class TaskBarRecentsAnimationListener implements RecentsAnimationListener { + private final RecentsAnimationCallbacks mCallbacks; + + TaskBarRecentsAnimationListener(RecentsAnimationCallbacks callbacks) { + mCallbacks = callbacks; + } + + @Override + public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) { + endGestureStateOverride(true); + } + + @Override + public void onRecentsAnimationFinished(RecentsAnimationController controller) { + endGestureStateOverride(!controller.getFinishTargetIsLauncher()); + } + + private void endGestureStateOverride(boolean finishedToApp) { + mCallbacks.removeListener(this); + mIsAnimatingToLauncherViaGesture = false; + + mIconAlignmentForGestureState + .animateToValue(0) + .start(); + + TaskbarStashController controller = mControllers.taskbarStashController; + if (finishedToApp) { + controller.animateToIsStashed(controller.isStashedInApp()); + } + } + } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 26664de149..3aed7cc630 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -602,6 +602,7 @@ public abstract class RecentsView mActivity.setLocusContext(id, Bundle.EMPTY)); } + + public interface TaskLaunchListener { + void onTaskLaunched(); + } } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 29810e3a76..2c33b6d30b 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -584,6 +584,7 @@ public class TaskView extends FrameLayout implements Reusable { } }); anim.start(); + recentsView.onTaskLaunchedInLiveTileMode(); } else { launchTaskAnimated(); } @@ -614,12 +615,14 @@ public class TaskView extends FrameLayout implements Reusable { ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null); if (ActivityManagerWrapper.getInstance() .startActivityFromRecents(mTask.key, opts.options)) { - if (ENABLE_QUICKSTEP_LIVE_TILE.get() && - getRecentsView().getRunningTaskViewId() != -1) { + RecentsView recentsView = getRecentsView(); + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskViewId() != -1) { + recentsView.onTaskLaunchedInLiveTileMode(); + // Return a fresh callback in the live tile case, so that it's not accidentally // triggered by QuickstepTransitionManager.AppLaunchAnimationRunner. RunnableList callbackList = new RunnableList(); - getRecentsView().addSideTaskLaunchCallback(callbackList); + recentsView.addSideTaskLaunchCallback(callbackList); return callbackList; } return opts.onEndCallback;