Merge "Taskbar should animate immediately when tapping a live tile" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index b5c834d..56c28f0 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.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 @@
* 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 @@
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 @@
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 26664de..3aed7cc 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -602,6 +602,7 @@
};
private RunnableList mSideTaskLaunchCallback;
+ private TaskLaunchListener mTaskLaunchListener;
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr,
BaseActivityInterface sizeStrategy) {
@@ -882,6 +883,21 @@
mSideTaskLaunchCallback.add(callback::executeAllAndDestroy);
}
+ /**
+ * This is a one-time callback when touching in live tile mode. It's reset to null right
+ * after it's called.
+ */
+ public void setTaskLaunchListener(TaskLaunchListener taskLaunchListener) {
+ mTaskLaunchListener = taskLaunchListener;
+ }
+
+ public void onTaskLaunchedInLiveTileMode() {
+ if (mTaskLaunchListener != null) {
+ mTaskLaunchListener.onTaskLaunched();
+ mTaskLaunchListener = null;
+ }
+ }
+
private void executeSideTaskLaunchCallback() {
if (mSideTaskLaunchCallback != null) {
mSideTaskLaunchCallback.executeAllAndDestroy();
@@ -4210,4 +4226,8 @@
// Set locus context is a binder call, don't want it to happen during a transition
UI_HELPER_EXECUTOR.post(() -> 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 29810e3..2c33b6d 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -584,6 +584,7 @@
}
});
anim.start();
+ recentsView.onTaskLaunchedInLiveTileMode();
} else {
launchTaskAnimated();
}
@@ -614,12 +615,14 @@
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;