diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index 7bc656a570..95198b8e36 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -20,7 +20,7 @@ import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.LauncherStateManager.ANIM_ALL; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL_COMPONENTS; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_HOTSEAT_SCALE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_HOTSEAT_TRANSLATE; @@ -220,7 +220,7 @@ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransiti LauncherStateManager stateManager = mLauncher.getStateManager(); return stateManager.createAtomicAnimation( stateManager.getCurrentStableState(), OVERVIEW, builder, - ANIM_ALL, ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW); + ANIM_ALL_COMPONENTS, ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW); } default: diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index b5d84247a8..65aaf22f49 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -30,6 +30,7 @@ import androidx.annotation.NonNull; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager.AnimationConfig; +import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.PropertySetter; import com.android.quickstep.views.ClearAllButton; @@ -64,20 +65,16 @@ public final class RecentsViewStateController extends @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) { super.setStateWithAnimationInternal(toState, builder, config); - if (!toState.overviewUi) { - builder.addOnFinishRunnable(mRecentsView::resetTaskVisuals); - } - + ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1).setDuration(config.duration); if (toState.overviewUi) { - ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1); - updateAnim.addUpdateListener(valueAnimator -> { - // While animating into recents, update the visible task data as needed - mRecentsView.loadVisibleTaskData(); - }); - updateAnim.setDuration(config.duration); - builder.play(updateAnim); + // While animating into recents, update the visible task data as needed + updateAnim.addUpdateListener(valueAnimator -> mRecentsView.loadVisibleTaskData()); mRecentsView.updateEmptyMessage(); + } else { + updateAnim.addListener( + AnimationSuccessListener.forRunnable(mRecentsView::resetTaskVisuals)); } + builder.play(updateAnim); PropertySetter propertySetter = config.getPropertySetter(builder); setAlphas(propertySetter, toState.getVisibleElements(mLauncher)); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java index 9cbe11acc3..b34701331e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java @@ -21,7 +21,8 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW_PEEK; -import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_PEEK_COMPONENT; +import static com.android.launcher3.LauncherStateManager.PLAY_ATOMIC_OVERVIEW_PEEK; +import static com.android.launcher3.LauncherStateManager.SKIP_OVERVIEW; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_HEADER_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; @@ -43,6 +44,7 @@ import android.view.ViewConfiguration; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppTransitionManagerImpl; import com.android.launcher3.LauncherState; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.Interpolators; @@ -104,7 +106,7 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { LauncherState toState = isPaused ? OVERVIEW_PEEK : NORMAL; long peekDuration = isPaused ? PEEK_IN_ANIM_DURATION : PEEK_OUT_ANIM_DURATION; mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(fromState, toState, - new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT, peekDuration); + new AnimatorSetBuilder(), PLAY_ATOMIC_OVERVIEW_PEEK, peekDuration); mPeekAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -210,7 +212,7 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { super.onAnimationEnd(animation); if (mCancelled) { mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(mFromState, - mToState, new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT, + mToState, new AnimatorSetBuilder(), PLAY_ATOMIC_OVERVIEW_PEEK, PEEK_OUT_ANIM_DURATION); mPeekAnim.start(); } @@ -237,11 +239,14 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { } @Override - protected void updateAnimatorBuilderOnReinit(AnimatorSetBuilder builder) { + @AnimationFlags + protected int updateAnimComponentsOnReinit(@AnimationFlags int animComponents) { if (handlingOverviewAnim()) { // We don't want the state transition to all apps to animate overview, // as that will cause a jump after our atomic animation. - builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW); + return animComponents | SKIP_OVERVIEW; + } else { + return animComponents; } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 7bae211c1a..7cebabe694 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -19,7 +19,7 @@ package com.android.launcher3.uioverrides.touchcontrollers; import static com.android.launcher3.LauncherState.HINT_STATE; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_PEEK_COMPONENT; +import static com.android.launcher3.LauncherStateManager.PLAY_ATOMIC_OVERVIEW_PEEK; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC; @@ -175,7 +175,7 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo long duration = OVERVIEW.getTransitionDuration(mLauncher); AnimatorSet anim = stateManager.createAtomicAnimation( stateManager.getState(), NORMAL, builder, - ATOMIC_OVERVIEW_PEEK_COMPONENT, duration); + PLAY_ATOMIC_OVERVIEW_PEEK, duration); anim.addListener(AnimationSuccessListener.forRunnable( () -> onSwipeInteractionCompleted(NORMAL, Touch.SWIPE))); anim.start(); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 52625dc74f..81a6d9b786 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -21,13 +21,13 @@ import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.QUICK_SWITCH; -import static com.android.launcher3.LauncherStateManager.ANIM_ALL; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL_COMPONENTS; +import static com.android.launcher3.LauncherStateManager.SKIP_OVERVIEW; import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_TRANSLATE; -import static com.android.launcher3.anim.AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW; import static com.android.launcher3.anim.Interpolators.ACCEL_0_75; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL_5; @@ -55,8 +55,8 @@ import android.view.animation.Interpolator; import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager; import com.android.launcher3.LauncherStateManager.AnimationConfig; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.AllAppsTransitionController; @@ -214,7 +214,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, nonOverviewBuilder.setInterpolator(ANIM_ALL_APPS_FADE, FADE_OUT_INTERPOLATOR); nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, TRANSLATE_OUT_INTERPOLATOR); nonOverviewBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, TRANSLATE_OUT_INTERPOLATOR); - updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder, ANIM_ALL); + updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder, ANIM_ALL_COMPONENTS); mNonOverviewAnim.dispatchOnStart(); if (mRecentsView.getTaskViewCount() == 0) { @@ -231,11 +231,10 @@ public class NoButtonQuickSwitchTouchController implements TouchController, /** Create state animation to control non-overview components. */ private void updateNonOverviewAnim(LauncherState toState, AnimatorSetBuilder builder, - @LauncherStateManager.AnimationComponents int animComponents) { - builder.addFlag(FLAG_DONT_ANIMATE_OVERVIEW); + @AnimationFlags int animComponents) { long accuracy = (long) (Math.max(mXRange, mYRange) * 2); mNonOverviewAnim = mLauncher.getStateManager().createAnimationToNewWorkspace(toState, - builder, accuracy, this::clearState, animComponents); + builder, accuracy, this::clearState, animComponents | SKIP_OVERVIEW); } private void setupOverviewAnimators() { diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index d5b221db06..8de1b3acbe 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -17,6 +17,7 @@ package com.android.launcher3.uioverrides.touchcontrollers; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.QUICK_SWITCH; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL_COMPONENTS; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; @@ -39,7 +40,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.touch.AbstractStateChangeTouchController; @@ -112,7 +112,7 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll setupInterpolators(animatorSetBuilder); long accuracy = (long) (getShiftRange() * 2); mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState, - animatorSetBuilder, accuracy, this::clearState, LauncherStateManager.ANIM_ALL); + animatorSetBuilder, accuracy, this::clearState, ANIM_ALL_COMPONENTS); mCurrentAnimation.getAnimationPlayer().addUpdateListener(valueAnimator -> { updateFullscreenProgress((Float) valueAnimator.getAnimatedValue()); }); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index d2805ed431..7e17fbf909 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -18,7 +18,8 @@ package com.android.quickstep.util; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.LauncherState.NORMAL; -import static com.android.launcher3.LauncherStateManager.ANIM_ALL; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL_COMPONENTS; +import static com.android.launcher3.LauncherStateManager.SKIP_OVERVIEW; import static com.android.launcher3.anim.Interpolators.LINEAR; import android.animation.Animator; @@ -32,7 +33,6 @@ import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager; import com.android.launcher3.LauncherStateManager.AnimationConfig; import com.android.launcher3.R; import com.android.launcher3.ShortcutAndWidgetContainer; @@ -143,11 +143,10 @@ public class StaggeredWorkspaceAnim { * Setup workspace with 0 duration to prepare for our staggered animation. */ private void prepareToAnimate(Launcher launcher) { - LauncherStateManager stateManager = launcher.getStateManager(); AnimatorSetBuilder builder = new AnimatorSetBuilder(); // setRecentsAttachedToAppWindow() will animate recents out. - builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW); - stateManager.createAtomicAnimation(BACKGROUND_APP, NORMAL, builder, ANIM_ALL, 0); + launcher.getStateManager().createAtomicAnimation( + BACKGROUND_APP, NORMAL, builder, ANIM_ALL_COMPONENTS | SKIP_OVERVIEW, 0); builder.build().start(); // Stop scrolling so that it doesn't interfere with the translation offscreen. diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index 9b57fb7627..cb9e87ab08 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -20,12 +20,14 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; +import static com.android.launcher3.LauncherStateManager.PLAY_ATOMIC_OVERVIEW_PEEK; +import static com.android.launcher3.LauncherStateManager.PLAY_ATOMIC_OVERVIEW_SCALE; +import static com.android.launcher3.LauncherStateManager.SKIP_OVERVIEW; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCRIM_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_X; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_Y; -import static com.android.launcher3.anim.AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW; import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.graphics.Scrim.SCRIM_PROGRESS; @@ -86,13 +88,11 @@ public abstract class BaseRecentsViewStateController @Override public final void setStateWithAnimation(@NonNull final LauncherState toState, @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) { - boolean playAtomicOverviewComponent = config.playAtomicOverviewScaleComponent() - || config.playAtomicOverviewPeekComponent(); - if (!playAtomicOverviewComponent) { + if (!config.hasAnimationComponent(PLAY_ATOMIC_OVERVIEW_PEEK | PLAY_ATOMIC_OVERVIEW_SCALE)) { // The entire recents animation is played atomically. return; } - if (builder.hasFlag(FLAG_DONT_ANIMATE_OVERVIEW)) { + if (config.hasAnimationComponent(SKIP_OVERVIEW)) { return; } setStateWithAnimationInternal(toState, builder, config); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java index 3cb00885e8..3d0fc561d1 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java @@ -9,7 +9,7 @@ import android.view.MotionEvent; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager.AnimationComponents; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.launcher3.userevent.nano.LauncherLogProto; @@ -56,7 +56,7 @@ public class LandscapeEdgeSwipeController extends AbstractStateChangeTouchContro } @Override - protected float initCurrentAnimation(@AnimationComponents int animComponent) { + protected float initCurrentAnimation(@AnimationFlags int animComponent) { float range = getShiftRange(); long maxAccuracy = (long) (2 * range); mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState, diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index 95e38e38fd..a060d64620 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -37,7 +37,7 @@ import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager.AnimationComponents; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; @@ -207,7 +207,8 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr } @Override - protected float initCurrentAnimation(@AnimationComponents int animComponents) { + protected float initCurrentAnimation(@AnimationFlags int animComponents) { + animComponents = updateAnimComponentsOnReinit(animComponents); float range = getShiftRange(); long maxAccuracy = (long) (2 * range); @@ -218,7 +219,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr final AnimatorSetBuilder builder = totalShift == 0 ? new AnimatorSetBuilder() : getAnimatorSetBuilderForStates(mFromState, mToState); - updateAnimatorBuilderOnReinit(builder); cancelPendingAnim(); @@ -253,7 +253,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr /** * Give subclasses the chance to update the animation when we re-initialize towards a new state. */ - protected void updateAnimatorBuilderOnReinit(AnimatorSetBuilder builder) { + @AnimationFlags + protected int updateAnimComponentsOnReinit(@AnimationFlags int animComponents) { + return animComponents; } private void cancelPendingAnim() { diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index 4267f2bd82..8233cdd20a 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -88,20 +88,22 @@ public class LauncherStateManager { // components may be run atomically - that is, all at once, instead of user-controlled. However, // atomic components are not restricted to this purpose; they can be user-controlled alongside // non atomic components as well. Note that each gesture model has exactly one atomic component, - // ATOMIC_OVERVIEW_SCALE_COMPONENT *or* ATOMIC_OVERVIEW_PEEK_COMPONENT. + // PLAY_ATOMIC_OVERVIEW_SCALE *or* PLAY_ATOMIC_OVERVIEW_PEEK. @IntDef(flag = true, value = { - NON_ATOMIC_COMPONENT, - ATOMIC_OVERVIEW_SCALE_COMPONENT, - ATOMIC_OVERVIEW_PEEK_COMPONENT, + PLAY_NON_ATOMIC, + PLAY_ATOMIC_OVERVIEW_SCALE, + PLAY_ATOMIC_OVERVIEW_PEEK, + SKIP_OVERVIEW, }) @Retention(RetentionPolicy.SOURCE) - public @interface AnimationComponents {} - public static final int NON_ATOMIC_COMPONENT = 1 << 0; - public static final int ATOMIC_OVERVIEW_SCALE_COMPONENT = 1 << 1; - public static final int ATOMIC_OVERVIEW_PEEK_COMPONENT = 1 << 2; + public @interface AnimationFlags {} + public static final int PLAY_NON_ATOMIC = 1 << 0; + public static final int PLAY_ATOMIC_OVERVIEW_SCALE = 1 << 1; + public static final int PLAY_ATOMIC_OVERVIEW_PEEK = 1 << 2; + public static final int SKIP_OVERVIEW = 1 << 3; - public static final int ANIM_ALL = NON_ATOMIC_COMPONENT | ATOMIC_OVERVIEW_SCALE_COMPONENT - | ATOMIC_OVERVIEW_PEEK_COMPONENT; + public static final int ANIM_ALL_COMPONENTS = PLAY_NON_ATOMIC | PLAY_ATOMIC_OVERVIEW_SCALE + | PLAY_ATOMIC_OVERVIEW_PEEK; private final AnimationConfig mConfig = new AnimationConfig(); private final Handler mUiHandler; @@ -311,7 +313,7 @@ public class LauncherStateManager { } public AnimatorSet createAtomicAnimation(LauncherState fromState, LauncherState toState, - AnimatorSetBuilder builder, @AnimationComponents int atomicComponent, long duration) { + AnimatorSetBuilder builder, @AnimationFlags int atomicComponent, long duration) { prepareForAtomicAnimation(fromState, toState, builder); AnimationConfig config = new AnimationConfig(); config.animComponents = atomicComponent; @@ -355,18 +357,18 @@ public class LauncherStateManager { */ public AnimatorPlaybackController createAnimationToNewWorkspace( LauncherState state, long duration) { - return createAnimationToNewWorkspace(state, duration, LauncherStateManager.ANIM_ALL); + return createAnimationToNewWorkspace(state, duration, ANIM_ALL_COMPONENTS); } public AnimatorPlaybackController createAnimationToNewWorkspace( - LauncherState state, long duration, @AnimationComponents int animComponents) { + LauncherState state, long duration, @AnimationFlags int animComponents) { return createAnimationToNewWorkspace(state, new AnimatorSetBuilder(), duration, null, animComponents); } public AnimatorPlaybackController createAnimationToNewWorkspace(LauncherState state, AnimatorSetBuilder builder, long duration, Runnable onCancelRunnable, - @AnimationComponents int animComponents) { + @AnimationFlags int animComponents) { mConfig.reset(); mConfig.userControlled = true; mConfig.animComponents = animComponents; @@ -583,7 +585,7 @@ public class LauncherStateManager { public long duration; public boolean userControlled; public AnimatorPlaybackController playbackController; - public @AnimationComponents int animComponents = ANIM_ALL; + public @AnimationFlags int animComponents = ANIM_ALL_COMPONENTS; private PropertySetter mPropertySetter; private AnimatorSet mCurrentAnimation; @@ -597,7 +599,7 @@ public class LauncherStateManager { public void reset() { duration = 0; userControlled = false; - animComponents = ANIM_ALL; + animComponents = ANIM_ALL_COMPONENTS; mPropertySetter = null; mTargetState = null; @@ -639,15 +641,18 @@ public class LauncherStateManager { } public boolean playAtomicOverviewScaleComponent() { - return (animComponents & ATOMIC_OVERVIEW_SCALE_COMPONENT) != 0; - } - - public boolean playAtomicOverviewPeekComponent() { - return (animComponents & ATOMIC_OVERVIEW_PEEK_COMPONENT) != 0; + return hasAnimationComponent(PLAY_ATOMIC_OVERVIEW_SCALE); } public boolean playNonAtomicComponent() { - return (animComponents & NON_ATOMIC_COMPONENT) != 0; + return hasAnimationComponent(PLAY_NON_ATOMIC); + } + + /** + * Returns true if the config and any of the provided component flags + */ + public boolean hasAnimationComponent(@AnimationFlags int a) { + return (animComponents & a) != 0; } } diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java index cd30dea9c0..d814b19e69 100644 --- a/src/com/android/launcher3/anim/AnimatorSetBuilder.java +++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java @@ -21,7 +21,6 @@ import android.util.SparseArray; import android.view.animation.Interpolator; import java.util.ArrayList; -import java.util.List; /** * Utility class for building animator set @@ -42,36 +41,17 @@ public class AnimatorSetBuilder { public static final int ANIM_OVERVIEW_SCRIM_FADE = 11; public static final int ANIM_ALL_APPS_HEADER_FADE = 12; // e.g. predictions - public static final int FLAG_DONT_ANIMATE_OVERVIEW = 1 << 0; - protected final ArrayList mAnims = new ArrayList<>(); private final SparseArray mInterpolators = new SparseArray<>(); - private List mOnFinishRunnables = new ArrayList<>(); - private int mFlags = 0; public void play(Animator anim) { mAnims.add(anim); } - public void addOnFinishRunnable(Runnable onFinishRunnable) { - mOnFinishRunnables.add(onFinishRunnable); - } - public AnimatorSet build() { AnimatorSet anim = new AnimatorSet(); anim.playTogether(mAnims); - if (!mOnFinishRunnables.isEmpty()) { - anim.addListener(new AnimationSuccessListener() { - @Override - public void onAnimationSuccess(Animator animation) { - for (Runnable onFinishRunnable : mOnFinishRunnables) { - onFinishRunnable.run(); - } - mOnFinishRunnables.clear(); - } - }); - } return anim; } @@ -82,12 +62,4 @@ public class AnimatorSetBuilder { public void setInterpolator(int animId, Interpolator interpolator) { mInterpolators.put(animId, interpolator); } - - public void addFlag(int flag) { - mFlags |= flag; - } - - public boolean hasFlag(int flag) { - return (mFlags & flag) != 0; - } } diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 4e9878105d..c3664c3569 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -19,9 +19,9 @@ import static com.android.launcher3.LauncherAnimUtils.MIN_PROGRESS_TO_ALL_APPS; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.LauncherStateManager.ANIM_ALL; -import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_SCALE_COMPONENT; -import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL_COMPONENTS; +import static com.android.launcher3.LauncherStateManager.PLAY_ATOMIC_OVERVIEW_SCALE; +import static com.android.launcher3.LauncherStateManager.PLAY_NON_ATOMIC; import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS; import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs; @@ -37,7 +37,7 @@ import android.view.MotionEvent; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager.AnimationComponents; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -176,7 +176,7 @@ public abstract class AbstractStateChangeTouchController protected abstract LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive); - protected abstract float initCurrentAnimation(@AnimationComponents int animComponents); + protected abstract float initCurrentAnimation(@AnimationFlags int animComponents); /** * Returns the container that the touch started from when leaving NORMAL state. @@ -201,10 +201,10 @@ public abstract class AbstractStateChangeTouchController mCurrentAnimation.setOnCancelRunnable(null); } int animComponents = goingBetweenNormalAndOverview(mFromState, mToState) - ? NON_ATOMIC_COMPONENT : ANIM_ALL; + ? PLAY_NON_ATOMIC : ANIM_ALL_COMPONENTS; mScheduleResumeAtomicComponent = false; if (mAtomicAnim != null) { - animComponents = NON_ATOMIC_COMPONENT; + animComponents = PLAY_NON_ATOMIC; // Control the non-atomic components until the atomic animation finishes, then control // the atomic components as well. mScheduleResumeAtomicComponent = true; @@ -215,7 +215,7 @@ public abstract class AbstractStateChangeTouchController } if (mAtomicComponentsController != null) { - animComponents &= ~ATOMIC_OVERVIEW_SCALE_COMPONENT; + animComponents &= ~PLAY_ATOMIC_OVERVIEW_SCALE; } mProgressMultiplier = initCurrentAnimation(animComponents); mCurrentAnimation.dispatchOnStart(); @@ -360,7 +360,7 @@ public abstract class AbstractStateChangeTouchController long duration) { AnimatorSetBuilder builder = getAnimatorSetBuilderForStates(fromState, targetState); return mLauncher.getStateManager().createAtomicAnimation(fromState, targetState, builder, - ATOMIC_OVERVIEW_SCALE_COMPONENT, duration); + PLAY_ATOMIC_OVERVIEW_SCALE, duration); } protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState, diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java index 31a5d79fc3..8d5f33da9c 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -23,7 +23,7 @@ import android.view.MotionEvent; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.LauncherStateManager.AnimationComponents; +import com.android.launcher3.LauncherStateManager.AnimationFlags; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; /** @@ -76,7 +76,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { } @Override - protected float initCurrentAnimation(@AnimationComponents int animComponents) { + protected float initCurrentAnimation(@AnimationFlags int animComponents) { float range = getShiftRange(); long maxAccuracy = (long) (2 * range); mCurrentAnimation = mLauncher.getStateManager()