Merge "Import translations. DO NOT MERGE ANYWHERE" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 7a50d0b..be5ab55 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -207,59 +207,10 @@
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
AnimatorSet animatorSet = new AnimatorSet();
- if (hasAnyFlag(changedFlags, FLAG_RESUMED)) {
- boolean isResumed = isResumed();
- ObjectAnimator anim = mIconAlignmentForResumedState
- .animateToValue(isResumed && goingToUnstashedLauncherState()
- ? 1 : 0)
- .setDuration(duration);
- anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mIsAnimatingToLauncherViaResume = false;
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- mIsAnimatingToLauncherViaResume = isResumed;
-
- TaskbarStashController stashController = mControllers.taskbarStashController;
- stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
- stashController.applyState(duration);
- }
- });
- animatorSet.play(anim);
- }
-
- if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)) {
- boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
- Animator animator = mIconAlignmentForGestureState
- .animateToValue(isRecentsAnimationRunning && goingToUnstashedLauncherState()
- ? 1 : 0);
- if (isRecentsAnimationRunning) {
- animator.setDuration(duration);
- }
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mIsAnimatingToLauncherViaGesture = false;
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
- }
- });
- animatorSet.play(animator);
- }
-
- if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
- boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
- animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
- .setDuration(duration));
- }
-
+ // Add the state animation first to ensure FLAG_IN_STASHED_LAUNCHER_STATE is set and we can
+ // determine whether goingToUnstashedLauncherStateChanged.
+ boolean wasGoingToUnstashedLauncherState = goingToUnstashedLauncherState();
if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
playStateTransitionAnim(animatorSet, duration, committed);
@@ -270,6 +221,76 @@
applyState(0 /* duration */);
}
}
+ boolean goingToUnstashedLauncherStateChanged = wasGoingToUnstashedLauncherState
+ != goingToUnstashedLauncherState();
+
+ boolean launcherStateChangedDuringAnimToResumeAlignment =
+ mIconAlignmentForResumedState.isAnimating() && goingToUnstashedLauncherStateChanged;
+ if (hasAnyFlag(changedFlags, FLAG_RESUMED)
+ || launcherStateChangedDuringAnimToResumeAlignment) {
+ boolean isResumed = isResumed();
+ float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0;
+ // If we're already animating to the value, just leave it be instead of restarting it.
+ if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
+ ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
+ .animateToValue(toAlignmentForResumedState)
+ .setDuration(duration);
+
+ resumeAlignAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mIsAnimatingToLauncherViaResume = false;
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mIsAnimatingToLauncherViaResume = isResumed;
+
+ TaskbarStashController stashController =
+ mControllers.taskbarStashController;
+ stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
+ stashController.applyState(duration);
+ }
+ });
+ animatorSet.play(resumeAlignAnim);
+ }
+ }
+
+
+ boolean launcherStateChangedDuringAnimToGestureAlignment =
+ mIconAlignmentForGestureState.isAnimating() && goingToUnstashedLauncherStateChanged;
+ if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)
+ || launcherStateChangedDuringAnimToGestureAlignment) {
+ boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
+ float toAlignmentForGestureState = isRecentsAnimationRunning
+ && goingToUnstashedLauncherState() ? 1 : 0;
+ // If we're already animating to the value, just leave it be instead of restarting it.
+ if (!mIconAlignmentForGestureState.isAnimatingToValue(toAlignmentForGestureState)) {
+ Animator gestureAlignAnim = mIconAlignmentForGestureState
+ .animateToValue(toAlignmentForGestureState);
+ if (isRecentsAnimationRunning) {
+ gestureAlignAnim.setDuration(duration);
+ }
+ gestureAlignAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mIsAnimatingToLauncherViaGesture = false;
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
+ }
+ });
+ animatorSet.play(gestureAlignAnim);
+ }
+ }
+
+ if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
+ boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
+ animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
+ .setDuration(duration));
+ }
if (start) {
animatorSet.start();
@@ -310,8 +331,11 @@
animatorSet.play(stashAnimator);
}
- animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
- .setDuration(duration));
+ // If we're already animating to the value, just leave it be instead of restarting it.
+ if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) {
+ animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
+ .setDuration(duration));
+ }
}
private boolean isResumed() {
diff --git a/quickstep/src/com/android/quickstep/AnimatedFloat.java b/quickstep/src/com/android/quickstep/AnimatedFloat.java
index 95c8710..6a7d066 100644
--- a/quickstep/src/com/android/quickstep/AnimatedFloat.java
+++ b/quickstep/src/com/android/quickstep/AnimatedFloat.java
@@ -42,6 +42,8 @@
private final Runnable mUpdateCallback;
private ObjectAnimator mValueAnimator;
+ // Only non-null when an animation is playing to this value.
+ private Float mEndValue;
public float value;
@@ -68,9 +70,17 @@
mValueAnimator = ObjectAnimator.ofFloat(this, VALUE, start, end);
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
+ public void onAnimationStart(Animator animator) {
+ if (mValueAnimator == animator) {
+ mEndValue = end;
+ }
+ }
+
+ @Override
public void onAnimationEnd(Animator animator) {
if (mValueAnimator == animator) {
mValueAnimator = null;
+ mEndValue = null;
}
}
});
@@ -103,4 +113,15 @@
public ObjectAnimator getCurrentAnimation() {
return mValueAnimator;
}
+
+ public boolean isAnimating() {
+ return mValueAnimator != null;
+ }
+
+ /**
+ * Returns whether we are currently animating, and the animation's end value matches the given.
+ */
+ public boolean isAnimatingToValue(float endValue) {
+ return isAnimating() && mEndValue != null && mEndValue == endValue;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 75e8dd1..17baa3a 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -38,6 +38,7 @@
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -271,6 +272,14 @@
scheduleNextTask(cmd);
}
+ public void dump(PrintWriter pw) {
+ pw.println("OverviewCommandHelper:");
+ pw.println(" mPendingCommands=" + mPendingCommands.size());
+ if (!mPendingCommands.isEmpty()) {
+ pw.println(" pendingCommandType=" + mPendingCommands.get(0).type);
+ }
+ }
+
private static class CommandInfo {
public final long createTime = SystemClock.elapsedRealtime();
public final int type;
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 103f350..1dc4933 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -99,6 +99,7 @@
private Handler mUiHandler = new Handler(Looper.getMainLooper());
private static final long HOME_APPEAR_DURATION = 250;
+ private static final long RECENTS_ANIMATION_TIMEOUT = 1000;
private RecentsDragLayer mDragLayer;
private ScrimView mScrimView;
@@ -115,6 +116,11 @@
// Strong refs to runners which are cleared when the activity is destroyed
private RemoteAnimationFactory mActivityLaunchAnimationRunner;
+ // For handling degenerate cases where starting an activity doesn't actually trigger the remote
+ // animation callback
+ private final Handler mHandler = new Handler();
+ private final Runnable mAnimationStartTimeoutRunnable = this::onAnimationStartTimeout;
+
/**
* Init drag layer and overview panel views.
*/
@@ -219,6 +225,16 @@
// TODO(b/137318995) This should go home, but doing so removes freeform windows
}
+ /**
+ * Called if the remote animation callback from #getActivityLaunchOptions() hasn't called back
+ * in a reasonable time due to a conflict with the recents animation.
+ */
+ private void onAnimationStartTimeout() {
+ if (mActivityLaunchAnimationRunner != null) {
+ mActivityLaunchAnimationRunner.onAnimationCancelled();
+ }
+ }
+
@Override
public ActivityOptionsWrapper getActivityLaunchOptions(final View v, @Nullable ItemInfo item) {
if (!(v instanceof TaskView)) {
@@ -233,6 +249,7 @@
public void onCreateAnimation(int transit, RemoteAnimationTargetCompat[] appTargets,
RemoteAnimationTargetCompat[] wallpaperTargets,
RemoteAnimationTargetCompat[] nonAppTargets, AnimationResult result) {
+ mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
AnimatorSet anim = composeRecentsLaunchAnimator(taskView, appTargets,
wallpaperTargets, nonAppTargets);
anim.addListener(resetStateListener());
@@ -242,6 +259,7 @@
@Override
public void onAnimationCancelled() {
+ mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
onEndCallback.executeAllAndDestroy();
}
};
@@ -256,6 +274,7 @@
ActivityOptionsCompat.makeRemoteAnimation(adapterCompat),
onEndCallback);
activityOptions.options.setSplashscreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON);
+ mHandler.postDelayed(mAnimationStartTimeoutRunnable, RECENTS_ANIMATION_TIMEOUT);
return activityOptions;
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 539239d..1f6a974 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -967,6 +967,9 @@
if (mOverviewComponentObserver != null) {
mOverviewComponentObserver.dump(pw);
}
+ if (mOverviewCommandHelper != null) {
+ mOverviewCommandHelper.dump(pw);
+ }
if (mGestureState != null) {
mGestureState.dump(pw);
}