diff --git a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java index 43dc882400..671aab00d9 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java @@ -40,7 +40,7 @@ public class BackButtonAlphaHandler implements LauncherStateManager.StateHandler @Override public void setStateWithAnimation(LauncherState toState, AnimatorSetBuilder builder, LauncherStateManager.AnimationConfig config) { - if (!config.playNonAtomicComponent()) { + if (config.onlyPlayAtomicComponent()) { return; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/BackgroundBlurController.java b/quickstep/src/com/android/launcher3/uioverrides/BackgroundBlurController.java index 9e4ada7cff..022a5f7f8a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BackgroundBlurController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BackgroundBlurController.java @@ -20,6 +20,7 @@ import static com.android.launcher3.anim.Interpolators.LINEAR; import android.util.IntProperty; import android.view.View; + import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; @@ -134,7 +135,7 @@ public class BackgroundBlurController implements LauncherStateManager.StateHandl @Override public void setStateWithAnimation(LauncherState toState, AnimatorSetBuilder builder, LauncherStateManager.AnimationConfig config) { - if (mSurface == null || !config.playNonAtomicComponent()) { + if (mSurface == null || config.onlyPlayAtomicComponent()) { return; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index cb9e87ab08..94e67f06c7 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -88,11 +88,11 @@ public abstract class BaseRecentsViewStateController @Override public final void setStateWithAnimation(@NonNull final LauncherState toState, @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) { - if (!config.hasAnimationComponent(PLAY_ATOMIC_OVERVIEW_PEEK | PLAY_ATOMIC_OVERVIEW_SCALE)) { + if (!config.hasAnimationFlag(PLAY_ATOMIC_OVERVIEW_PEEK | PLAY_ATOMIC_OVERVIEW_SCALE)) { // The entire recents animation is played atomically. return; } - if (config.hasAnimationComponent(SKIP_OVERVIEW)) { + if (config.hasAnimationFlag(SKIP_OVERVIEW)) { return; } setStateWithAnimationInternal(toState, builder, config); diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index 8233cdd20a..04134f29aa 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -313,10 +313,10 @@ public class LauncherStateManager { } public AnimatorSet createAtomicAnimation(LauncherState fromState, LauncherState toState, - AnimatorSetBuilder builder, @AnimationFlags int atomicComponent, long duration) { + AnimatorSetBuilder builder, @AnimationFlags int animFlags, long duration) { prepareForAtomicAnimation(fromState, toState, builder); AnimationConfig config = new AnimationConfig(); - config.animComponents = atomicComponent; + config.mAnimFlags = animFlags; config.duration = duration; for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) { handler.setStateWithAnimation(toState, builder, config); @@ -371,7 +371,7 @@ public class LauncherStateManager { @AnimationFlags int animComponents) { mConfig.reset(); mConfig.userControlled = true; - mConfig.animComponents = animComponents; + mConfig.mAnimFlags = animComponents; mConfig.duration = duration; mConfig.playbackController = AnimatorPlaybackController.wrap( createAnimationToNewWorkspaceInternal(state, builder, null), duration) @@ -585,7 +585,7 @@ public class LauncherStateManager { public long duration; public boolean userControlled; public AnimatorPlaybackController playbackController; - public @AnimationFlags int animComponents = ANIM_ALL_COMPONENTS; + private @AnimationFlags int mAnimFlags = ANIM_ALL_COMPONENTS; private PropertySetter mPropertySetter; private AnimatorSet mCurrentAnimation; @@ -599,7 +599,7 @@ public class LauncherStateManager { public void reset() { duration = 0; userControlled = false; - animComponents = ANIM_ALL_COMPONENTS; + mAnimFlags = ANIM_ALL_COMPONENTS; mPropertySetter = null; mTargetState = null; @@ -640,19 +640,39 @@ public class LauncherStateManager { mCurrentAnimation.addListener(this); } + /** + * @return Whether Overview is scaling as part of this animation. If this is the only + * component (i.e. NON_ATOMIC_COMPONENT isn't included), then this scaling is happening + * atomically, rather than being part of a normal state animation. StateHandlers can use + * this to designate part of their animation that should scale with Overview. + */ public boolean playAtomicOverviewScaleComponent() { - return hasAnimationComponent(PLAY_ATOMIC_OVERVIEW_SCALE); + return hasAnimationFlag(PLAY_ATOMIC_OVERVIEW_SCALE); } - public boolean playNonAtomicComponent() { - return hasAnimationComponent(PLAY_NON_ATOMIC); + /** + * @return Whether this animation will play atomically at the same time as a different, + * user-controlled state transition. StateHandlers, which contribute to both animations, can + * use this to avoid animating the same properties in both animations, since they'd conflict + * with one another. + */ + public boolean onlyPlayAtomicComponent() { + return getAnimComponents() == PLAY_ATOMIC_OVERVIEW_SCALE + || getAnimComponents() == PLAY_ATOMIC_OVERVIEW_PEEK; } /** * Returns true if the config and any of the provided component flags */ - public boolean hasAnimationComponent(@AnimationFlags int a) { - return (animComponents & a) != 0; + public boolean hasAnimationFlag(@AnimationFlags int a) { + return (mAnimFlags & a) != 0; + } + + /** + * @return Only the flags that determine which animation components to play. + */ + public @AnimationFlags int getAnimComponents() { + return mAnimFlags & ANIM_ALL_COMPONENTS; } } diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 388d07486d..6653426b91 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -120,7 +120,7 @@ public class WorkspaceStateTransitionAnimation { hotseatIconsAlpha, fadeInterpolator); } - if (!config.playNonAtomicComponent()) { + if (config.onlyPlayAtomicComponent()) { // Only the alpha and scale, handled above, are included in the atomic animation. return; } @@ -175,7 +175,8 @@ public class WorkspaceStateTransitionAnimation { float pageAlpha = pageAlphaProvider.getPageAlpha(childIndex); int drawableAlpha = Math.round(pageAlpha * (state.hasWorkspacePageBackground ? 255 : 0)); - if (config.playNonAtomicComponent()) { + if (!config.onlyPlayAtomicComponent()) { + // Don't update the scrim during the atomic animation. propertySetter.setInt(cl.getScrimBackground(), DRAWABLE_ALPHA, drawableAlpha, ZOOM_OUT); } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 0e60f5bda8..744f4eb96b 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -162,7 +162,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil return; } - if (!config.playNonAtomicComponent()) { + if (config.onlyPlayAtomicComponent()) { // There is no atomic component for the all apps transition, so just return early. return; }