Registering app transition animations with the internal stateManager,
so that the animation is reset when we start a state animation from
launcher
Bug: 74975768
Bug: 75290288
Change-Id: If7f71f087d7bb64fb25c085c476a6fcbc86518e2
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ee6dd59..9a3e8a2 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -400,10 +400,6 @@
return mStateManager;
}
- public LauncherAppTransitionManager getAppTransitionManager() {
- return mAppTransitionManager;
- }
-
protected void overrideTheme(boolean isDark, boolean supportsDarkText) {
if (isDark) {
setTheme(R.style.LauncherThemeDark);
@@ -1254,7 +1250,11 @@
// In all these cases, only animate if we're already on home
AbstractFloatingView.closeAllOpenViews(this, isStarted());
- mStateManager.goToState(NORMAL);
+ if (!isInState(NORMAL)) {
+ // Only change state, if not already the same. This prevents cancelling any
+ // animations running as part of resume
+ mStateManager.goToState(NORMAL);
+ }
// Reset the apps view
if (!alreadyOnHome && mAppsView != null) {
diff --git a/src/com/android/launcher3/LauncherAppTransitionManager.java b/src/com/android/launcher3/LauncherAppTransitionManager.java
index 19fa3d4..04f9b3a 100644
--- a/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -62,13 +62,4 @@
public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) {
return getDefaultActivityLaunchOptions(launcher, v);
}
-
- /** Cancels the current Launcher transition animation */
- public void finishLauncherAnimation() {
- }
-
- public boolean isAnimating() {
- // We don't know when the activity options are being used.
- return false;
- }
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 950a8ac..0463bb1 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -183,7 +183,6 @@
mConfig.reset();
if (!animated) {
- preOnStateTransitionStart();
onStateTransitionStart(state);
for (StateHandler handler : getStateHandlers()) {
handler.setState(state);
@@ -237,7 +236,6 @@
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
AnimatorSetBuilder builder, final Runnable onCompleteRunnable) {
- preOnStateTransitionStart();
for (StateHandler handler : getStateHandlers()) {
builder.startTag(handler);
@@ -277,15 +275,6 @@
return mConfig.mCurrentAnimation;
}
- private void preOnStateTransitionStart() {
- // If we are still animating to launcher from an app,
- // finish it and let this state animation take over.
- LauncherAppTransitionManager transitionManager = mLauncher.getAppTransitionManager();
- if (transitionManager != null) {
- transitionManager.finishLauncherAnimation();
- }
- }
-
private void onStateTransitionStart(LauncherState state) {
mState.onStateDisabled(mLauncher);
mState = state;
@@ -351,6 +340,15 @@
mConfig.reset();
}
+ /**
+ * Sets the animation as the current state animation, i.e., canceled when
+ * starting another animation and may block some launcher interactions while running.
+ */
+ public void setCurrentAnimation(AnimatorSet anim) {
+ cancelAnimation();
+ mConfig.setAnimation(anim);
+ }
+
private class StartAnimRunnable implements Runnable {
private final AnimatorSet mAnim;