summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-04-19 12:34:43 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-04-20 20:53:16 +0000
commited2d2bcbb8541eb811615638e6bcf93524c2b333 (patch)
treeae4e24acfe267fd1cdaf6019fd48852d2c73698a
parent69632a46ab975e5410a098425c54d7d39cdc5d16 (diff)
downloadandroid_packages_apps_Trebuchet-ed2d2bcbb8541eb811615638e6bcf93524c2b333.tar.gz
android_packages_apps_Trebuchet-ed2d2bcbb8541eb811615638e6bcf93524c2b333.tar.bz2
android_packages_apps_Trebuchet-ed2d2bcbb8541eb811615638e6bcf93524c2b333.zip
Force finish any pending animations if the insets or orientation change
Some animation might be running from a previous orientation, which can cuase property changes to get skipped. Bug: 77848165 Bug: 77774619 Change-Id: I3e198196192746abdd72a1970ff2ef407bf4aff9
-rw-r--r--quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java3
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherRootView.java8
-rw-r--r--src/com/android/launcher3/LauncherStateManager.java7
-rw-r--r--src/com/android/launcher3/anim/AnimatorPlaybackController.java32
-rw-r--r--src/com/android/launcher3/touch/AbstractStateChangeTouchController.java2
6 files changed, 29 insertions, 25 deletions
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index ce17d257e..353ed8460 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -50,7 +50,6 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
-import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
import android.view.Surface;
@@ -249,7 +248,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
mLauncher.getStateManager()
.createAnimationToNewWorkspace(NORMAL, RECENTS_LAUNCH_DURATION);
controller.dispatchOnStart();
- childStateAnimation = controller.getOriginalTarget();
+ childStateAnimation = controller.getTarget();
launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
windowAnimEndListener = new AnimatorListenerAdapter() {
@Override
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ec0a8ffb3..5e06d9237 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -360,7 +360,7 @@ public class Launcher extends BaseDraggingActivity
dispatchDeviceProfileChanged();
getRootView().dispatchInsets();
- getStateManager().reapplyState();
+ getStateManager().reapplyState(true /* cancelCurrentAnimation */);
// Recreate touch controllers
mDragLayer.setup(mDragController);
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index f204c16e2..ad1456a2d 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -1,5 +1,8 @@
package com.android.launcher3;
+import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
+import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW;
+
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
@@ -13,9 +16,6 @@ import android.view.ViewDebug;
import com.android.launcher3.util.Themes;
-import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
-import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW;
-
public class LauncherRootView extends InsettableFrameLayout {
private final Launcher mLauncher;
@@ -82,7 +82,7 @@ public class LauncherRootView extends InsettableFrameLayout {
}
}
if (resetState) {
- mLauncher.getStateManager().reapplyState();
+ mLauncher.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
}
return true; // I'll take it from here
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index e611af7df..d196c3759 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -157,6 +157,13 @@ public class LauncherStateManager {
}
public void reapplyState() {
+ reapplyState(false);
+ }
+
+ public void reapplyState(boolean cancelCurrentAnimation) {
+ if (cancelCurrentAnimation) {
+ cancelAnimation();
+ }
if (mConfig.mCurrentAnimation == null) {
for (StateHandler handler : getStateHandlers()) {
handler.setState(mState);
diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
index 087752df1..1dba7d665 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -17,6 +17,7 @@ package com.android.launcher3.anim;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
+import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
@@ -52,45 +53,37 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
private final long mDuration;
protected final AnimatorSet mAnim;
- private AnimatorSet mOriginalTarget;
protected float mCurrentFraction;
private Runnable mEndAction;
+ protected boolean mTargetCancelled = false;
+
protected AnimatorPlaybackController(AnimatorSet anim, long duration) {
mAnim = anim;
- mOriginalTarget = mAnim;
mDuration = duration;
mAnimationPlayer = ValueAnimator.ofFloat(0, 1);
mAnimationPlayer.setInterpolator(Interpolators.LINEAR);
mAnimationPlayer.addListener(new OnAnimationEndDispatcher());
mAnimationPlayer.addUpdateListener(this);
+
+ mAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mTargetCancelled = true;
+ }
+ });
}
public AnimatorSet getTarget() {
return mAnim;
}
- public void setOriginalTarget(AnimatorSet anim) {
- mOriginalTarget = anim;
- }
-
- public AnimatorSet getOriginalTarget() {
- return mOriginalTarget;
- }
-
public long getDuration() {
return mDuration;
}
- public AnimatorPlaybackController cloneFor(AnimatorSet anim) {
- AnimatorPlaybackController controller = AnimatorPlaybackController.wrap(anim, mDuration);
- controller.setOriginalTarget(mOriginalTarget);
- controller.setPlayFraction(mCurrentFraction);
- return controller;
- }
-
/**
* Starts playing the animation forward from current position.
*/
@@ -206,6 +199,11 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
@Override
public void setPlayFraction(float fraction) {
mCurrentFraction = fraction;
+ // Let the animator report the progress but don't apply the progress to child
+ // animations if it has been cancelled.
+ if (mTargetCancelled) {
+ return;
+ }
long playPos = clampDuration(fraction);
for (ValueAnimator anim : mChildAnimations) {
anim.setCurrentPlayTime(Math.min(playPos, anim.getDuration()));
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index f1195edf3..4c7ce1fb4 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -279,7 +279,7 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene
@Override
public void onAnimationCancel(Animator animation) {
- if (mCurrentAnimation != null && animation == mCurrentAnimation.getOriginalTarget()) {
+ if (mCurrentAnimation != null && animation == mCurrentAnimation.getTarget()) {
Log.e(TAG, "Who dare cancel the animation when I am in control", new Exception());
clearState();
}