diff --git a/quickstep/src/com/android/launcher3/statehandlers/BackButtonAlphaHandler.java b/quickstep/src/com/android/launcher3/statehandlers/BackButtonAlphaHandler.java index ce9430515c..1f268cc9d9 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/BackButtonAlphaHandler.java +++ b/quickstep/src/com/android/launcher3/statehandlers/BackButtonAlphaHandler.java @@ -48,10 +48,6 @@ public class BackButtonAlphaHandler implements StateHandler { @Override public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config, PendingAnimation animation) { - if (config.onlyPlayAtomicComponent()) { - return; - } - if (SysUINavigationMode.getMode(mLauncher) != TWO_BUTTONS) { return; } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index fe8f0c653d..249ef3a3b0 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -193,7 +193,6 @@ public class DepthController implements StateHandler, public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config, PendingAnimation animation) { if (mSurface == null - || config.onlyPlayAtomicComponent() || config.hasAnimationFlag(SKIP_DEPTH_CONTROLLER) || mIgnoreStateChangesDuringMultiWindowAnimation) { return; diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index d65c59e067..d36af09d89 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -26,8 +26,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SC import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCRIM_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_PEEK; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE; import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET; import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS; @@ -83,10 +81,6 @@ public abstract class BaseRecentsViewStateController @Override public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config, PendingAnimation builder) { - if (!config.hasAnimationFlag(PLAY_ATOMIC_OVERVIEW_PEEK | PLAY_ATOMIC_OVERVIEW_SCALE)) { - // The entire recents animation is played atomically. - return; - } if (config.hasAnimationFlag(SKIP_OVERVIEW)) { return; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 6c71995f9b..fcb211be39 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -108,8 +108,8 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch } @Override - protected float initCurrentAnimation(int animComponents) { - float progressMultiplier = super.initCurrentAnimation(animComponents); + protected float initCurrentAnimation() { + float progressMultiplier = super.initCurrentAnimation(); if (mToState == HINT_STATE) { // Track the drag across the entire height of the screen. progressMultiplier = -1 / getShiftRange(); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index facfb9ddd8..1af9685f4f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -23,17 +23,9 @@ import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.Interpolators.ACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL; -import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS; import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS; -import android.animation.TimeInterpolator; -import android.animation.ValueAnimator; -import android.util.Log; import android.view.MotionEvent; -import android.view.animation.Interpolator; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -41,8 +33,6 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.states.StateAnimationConfig; -import com.android.launcher3.states.StateAnimationConfig.AnimationFlags; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.launcher3.uioverrides.states.OverviewState; @@ -70,11 +60,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr private final PortraitOverviewStateTouchHelper mOverviewPortraitStateTouchHelper; - private final InterpolatorWrapper mAllAppsInterpolatorWrapper = new InterpolatorWrapper(); - - // If true, we will finish the current animation instantly on second touch. - private boolean mFinishFastOnSecondTouch; - public PortraitStatesTouchController(Launcher l) { super(l, SingleAxisSwipeDetector.VERTICAL); mOverviewPortraitStateTouchHelper = new PortraitOverviewStateTouchHelper(l); @@ -85,10 +70,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr // If we are swiping to all apps instead of overview, allow it from anywhere. boolean interceptAnywhere = mLauncher.isInState(NORMAL); if (mCurrentAnimation != null) { - if (mFinishFastOnSecondTouch) { - mCurrentAnimation.getAnimationPlayer().end(); - } - AllAppsTransitionController allAppsController = mLauncher.getAllAppsController(); if (ev.getY() >= allAppsController.getShiftRange() * allAppsController.getProgress() || interceptAnywhere) { @@ -96,11 +77,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr // the touch is below the current all apps progress (to allow for double swipe). return true; } - // Otherwise, make sure everything is settled and don't intercept so they can scroll - // recents, dismiss a task, etc. - if (mAtomicAnim != null) { - mAtomicAnim.end(); - } + // Otherwise, don't intercept so they can scroll recents, dismiss a task, etc. return false; } if (mLauncher.isInState(ALL_APPS)) { @@ -136,32 +113,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr return fromState; } - private StateAnimationConfig getNormalToOverviewAnimation() { - mAllAppsInterpolatorWrapper.baseInterpolator = LINEAR; - - StateAnimationConfig builder = new StateAnimationConfig(); - builder.setInterpolator(ANIM_VERTICAL_PROGRESS, mAllAppsInterpolatorWrapper); - return builder; - } - - private static StateAnimationConfig getOverviewToAllAppsAnimation() { - StateAnimationConfig builder = new StateAnimationConfig(); - builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, - 0, ALL_APPS_CONTENT_FADE_THRESHOLD)); - builder.setInterpolator(ANIM_OVERVIEW_FADE, Interpolators.clampToProgress(DEACCEL, - RECENTS_FADE_THRESHOLD, 1)); - return builder; - } - - private StateAnimationConfig getAllAppsToOverviewAnimation() { - StateAnimationConfig builder = new StateAnimationConfig(); - builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL, - 1 - ALL_APPS_CONTENT_FADE_THRESHOLD, 1)); - builder.setInterpolator(ANIM_OVERVIEW_FADE, Interpolators.clampToProgress(ACCEL, - 0f, 1 - RECENTS_FADE_THRESHOLD)); - return builder; - } - private StateAnimationConfig getNormalToAllAppsAnimation() { StateAnimationConfig builder = new StateAnimationConfig(); builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, @@ -180,13 +131,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr protected StateAnimationConfig getConfigForStates( LauncherState fromState, LauncherState toState) { final StateAnimationConfig config; - if (fromState == NORMAL && toState == OVERVIEW) { - config = getNormalToOverviewAnimation(); - } else if (fromState == OVERVIEW && toState == ALL_APPS) { - config = getOverviewToAllAppsAnimation(); - } else if (fromState == ALL_APPS && toState == OVERVIEW) { - config = getAllAppsToOverviewAnimation(); - } else if (fromState == NORMAL && toState == ALL_APPS) { + if (fromState == NORMAL && toState == ALL_APPS) { config = getNormalToAllAppsAnimation(); } else if (fromState == ALL_APPS && toState == NORMAL) { config = getAllAppsToNormalAnimation(); @@ -197,7 +142,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr } @Override - protected float initCurrentAnimation(@AnimationFlags int animFlags) { + protected float initCurrentAnimation() { float range = getShiftRange(); long maxAccuracy = (long) (2 * range); @@ -208,7 +153,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr final StateAnimationConfig config = totalShift == 0 ? new StateAnimationConfig() : getConfigForStates(mFromState, mToState); - config.animFlags = animFlags; config.duration = maxAccuracy; if (mCurrentAnimation != null) { @@ -242,35 +186,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr return 1 / totalShift; } - @Override - protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration, - LauncherState targetState, float velocity, boolean isFling) { - super.updateSwipeCompleteAnimation(animator, expectedDuration, targetState, - velocity, isFling); - handleFirstSwipeToOverview(animator, expectedDuration, targetState, velocity, isFling); - } - - private void handleFirstSwipeToOverview(final ValueAnimator animator, - final long expectedDuration, final LauncherState targetState, final float velocity, - final boolean isFling) { - if (UNSTABLE_SPRINGS.get() && mFromState == OVERVIEW && mToState == ALL_APPS - && targetState == OVERVIEW) { - mFinishFastOnSecondTouch = true; - } else if (mFromState == NORMAL && mToState == OVERVIEW && targetState == OVERVIEW) { - mFinishFastOnSecondTouch = true; - if (isFling && expectedDuration != 0) { - // Update all apps interpolator to add a bit of overshoot starting from currFraction - final float currFraction = mCurrentAnimation.getProgressFraction(); - mAllAppsInterpolatorWrapper.baseInterpolator = Interpolators.clampToProgress( - Interpolators.overshootInterpolatorForVelocity(velocity), currFraction, 1); - animator.setDuration(Math.min(expectedDuration, ATOMIC_DURATION)) - .setInterpolator(LINEAR); - } - } else { - mFinishFastOnSecondTouch = false; - } - } - @Override protected void onSwipeInteractionCompleted(LauncherState targetState) { super.onSwipeInteractionCompleted(targetState); @@ -296,16 +211,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr return launcher.getDragLayer().getHeight() - hotseatHeight; } - private static class InterpolatorWrapper implements Interpolator { - - public TimeInterpolator baseInterpolator = LINEAR; - - @Override - public float getInterpolation(float v) { - return baseInterpolator.getInterpolation(v); - } - } - @Override public boolean onControllerInterceptTouchEvent(MotionEvent ev) { switch (ev.getAction()) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index fc9e1bbfe5..85422092f8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -101,7 +101,7 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll } @Override - protected float initCurrentAnimation(int animComponents) { + protected float initCurrentAnimation() { StateAnimationConfig config = new StateAnimationConfig(); setupInterpolators(config); config.duration = (long) (getShiftRange() * 2); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java index 0ed529184e..8f9c01441e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java @@ -32,8 +32,8 @@ public class TransposedQuickSwitchTouchController extends QuickSwitchTouchContro } @Override - protected float initCurrentAnimation(int animComponents) { - float multiplier = super.initCurrentAnimation(animComponents); + protected float initCurrentAnimation() { + float multiplier = super.initCurrentAnimation(); return mLauncher.getDeviceProfile().isSeascape() ? multiplier : -multiplier; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TwoButtonNavbarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TwoButtonNavbarTouchController.java index 5781469861..3f7190f017 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TwoButtonNavbarTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TwoButtonNavbarTouchController.java @@ -29,7 +29,6 @@ import android.view.MotionEvent; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.states.StateAnimationConfig.AnimationFlags; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.quickstep.SystemUiProxy; @@ -121,11 +120,11 @@ public class TwoButtonNavbarTouchController extends AbstractStateChangeTouchCont } @Override - protected float initCurrentAnimation(@AnimationFlags int animComponent) { + protected float initCurrentAnimation() { float range = getShiftRange(); long maxAccuracy = (long) (2 * range); mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState, - maxAccuracy, animComponent); + maxAccuracy); return (mLauncher.getDeviceProfile().isSeascape() ? 1 : -1) / range; } diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java index 82bfa9b9a9..03a0b4ec6b 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java @@ -20,8 +20,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_MO import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_PEEK; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE; import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET; import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS; @@ -63,10 +61,6 @@ public class FallbackRecentsStateController implements StateHandler> { */ public AnimatorPlaybackController createAnimationToNewWorkspace( STATE_TYPE state, long duration) { - return createAnimationToNewWorkspace(state, duration, ANIM_ALL_COMPONENTS); + return createAnimationToNewWorkspace(state, duration, PLAY_ANIMATION); } public AnimatorPlaybackController createAnimationToNewWorkspace( @@ -312,7 +312,7 @@ public class StateManager> { private PendingAnimation createAnimationToNewWorkspaceInternal(final STATE_TYPE state) { PendingAnimation builder = new PendingAnimation(mConfig.duration); - if (mConfig.getAnimComponents() != 0) { + if (mConfig.hasAnimationFlag(PLAY_ANIMATION)) { for (StateHandler handler : getStateHandlers()) { handler.setStateWithAnimation(state, mConfig, builder); } diff --git a/src/com/android/launcher3/states/StateAnimationConfig.java b/src/com/android/launcher3/states/StateAnimationConfig.java index cd74390418..20457334c3 100644 --- a/src/com/android/launcher3/states/StateAnimationConfig.java +++ b/src/com/android/launcher3/states/StateAnimationConfig.java @@ -27,32 +27,22 @@ import java.lang.annotation.RetentionPolicy; */ public class StateAnimationConfig { - // We separate the state animations into "atomic" and "non-atomic" components. The atomic - // 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, - // PLAY_ATOMIC_OVERVIEW_SCALE *or* PLAY_ATOMIC_OVERVIEW_PEEK. @IntDef(flag = true, value = { - PLAY_NON_ATOMIC, - PLAY_ATOMIC_OVERVIEW_SCALE, - PLAY_ATOMIC_OVERVIEW_PEEK, + PLAY_ANIMATION, SKIP_OVERVIEW, SKIP_DEPTH_CONTROLLER, }) @Retention(RetentionPolicy.SOURCE) 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 SKIP_DEPTH_CONTROLLER = 1 << 4; + // TODO: make this the default; invert this to be SKIP_ALL_ANIMATIONS + public static final int PLAY_ANIMATION = 1 << 0; + public static final int SKIP_OVERVIEW = 1 << 1; + public static final int SKIP_DEPTH_CONTROLLER = 1 << 2; public long duration; public boolean userControlled; - public @AnimationFlags int animFlags = ANIM_ALL_COMPONENTS; + public @AnimationFlags int animFlags = PLAY_ANIMATION; - public static final int ANIM_ALL_COMPONENTS = PLAY_NON_ATOMIC | PLAY_ATOMIC_OVERVIEW_SCALE - | PLAY_ATOMIC_OVERVIEW_PEEK; // Various types of animation state transition @IntDef(value = { @@ -126,38 +116,10 @@ public class StateAnimationConfig { mInterpolators[animId] = interpolator; } - /** - * @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 hasAnimationFlag(StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE); - } - - /** - * @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() == StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE - || getAnimComponents() == StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_PEEK; - } - /** * Returns true if the config and any of the provided component flags */ public boolean hasAnimationFlag(@AnimationFlags int a) { return (animFlags & a) != 0; } - - /** - * @return Only the flags that determine which animation components to play. - */ - public @AnimationFlags int getAnimComponents() { - return animFlags & StateAnimationConfig.ANIM_ALL_COMPONENTS; - } } diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 516fc74ba6..2889801a8b 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -27,30 +27,20 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEDOWN; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEUP; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_COMPONENTS; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE; -import static com.android.launcher3.states.StateAnimationConfig.PLAY_NON_ATOMIC; import static com.android.launcher3.util.DisplayController.getSingleFrameMs; -import android.animation.Animator; import android.animation.Animator.AnimatorListener; -import android.animation.AnimatorListenerAdapter; -import android.animation.AnimatorSet; import android.animation.ValueAnimator; -import android.os.SystemClock; -import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; -import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.logger.LauncherAtom; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.states.StateAnimationConfig; -import com.android.launcher3.states.StateAnimationConfig.AnimationFlags; import com.android.launcher3.util.FlingBlockCheck; import com.android.launcher3.util.TouchController; @@ -60,13 +50,6 @@ import com.android.launcher3.util.TouchController; public abstract class AbstractStateChangeTouchController implements TouchController, SingleAxisSwipeDetector.Listener { - /** - * Play an atomic recents animation when the progress from NORMAL to OVERVIEW reaches this. - * TODO: Remove the atomic animation altogether and just go to OVERVIEW directly (b/175137718). - */ - public static final float ATOMIC_OVERVIEW_ANIM_THRESHOLD = 1f; - protected final long ATOMIC_DURATION = getAtomicDuration(); - protected final Launcher mLauncher; protected final SingleAxisSwipeDetector mDetector; protected final SingleAxisSwipeDetector.Direction mSwipeDirection; @@ -89,23 +72,7 @@ public abstract class AbstractStateChangeTouchController private float mProgressMultiplier; private float mDisplacementShift; private boolean mCanBlockFling; - private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck(); - - protected AnimatorSet mAtomicAnim; - // True if we want to resume playing atomic components when mAtomicAnim completes. - private boolean mScheduleResumeAtomicComponent; - private AutoPlayAtomicAnimationInfo mAtomicAnimAutoPlayInfo; - - private boolean mPassedOverviewAtomicThreshold; - // mAtomicAnim plays the atomic components of the state animations when we pass the threshold. - // However, if we reinit to transition to a new state (e.g. OVERVIEW -> ALL_APPS) before the - // atomic animation finishes, we only control the non-atomic components so that we don't - // interfere with the atomic animation. When the atomic animation ends, we start controlling - // the atomic components as well, using this controller. - private AnimatorPlaybackController mAtomicComponentsController; - private LauncherState mAtomicComponentsTargetState = NORMAL; - - private float mAtomicComponentsStartProgress; + private final FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck(); public AbstractStateChangeTouchController(Launcher l, SingleAxisSwipeDetector.Direction dir) { mLauncher = l; @@ -113,10 +80,6 @@ public abstract class AbstractStateChangeTouchController mSwipeDirection = dir; } - protected long getAtomicDuration() { - return 200; - } - protected abstract boolean canInterceptTouch(MotionEvent ev); @Override @@ -182,7 +145,7 @@ public abstract class AbstractStateChangeTouchController protected abstract LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive); - protected abstract float initCurrentAnimation(@AnimationFlags int animComponents); + protected abstract float initCurrentAnimation(); private boolean reinitCurrentAnimation(boolean reachedToState, boolean isDragTowardPositive) { LauncherState newFromState = mFromState == null ? mLauncher.getStateManager().getState() @@ -199,28 +162,10 @@ public abstract class AbstractStateChangeTouchController mToState = newToState; mStartProgress = 0; - mPassedOverviewAtomicThreshold = false; if (mCurrentAnimation != null) { mCurrentAnimation.getTarget().removeListener(mClearStateOnCancelListener); } - int animComponents = goingBetweenNormalAndOverview(mFromState, mToState) - ? PLAY_NON_ATOMIC : ANIM_ALL_COMPONENTS; - mScheduleResumeAtomicComponent = false; - if (mAtomicAnim != null) { - animComponents = PLAY_NON_ATOMIC; - // Control the non-atomic components until the atomic animation finishes, then control - // the atomic components as well. - mScheduleResumeAtomicComponent = true; - } - if (goingBetweenNormalAndOverview(mFromState, mToState) - || mAtomicComponentsTargetState != mToState) { - cancelAtomicComponentsController(); - } - - if (mAtomicComponentsController != null) { - animComponents &= ~PLAY_ATOMIC_OVERVIEW_SCALE; - } - mProgressMultiplier = initCurrentAnimation(animComponents); + mProgressMultiplier = initCurrentAnimation(); mCurrentAnimation.dispatchOnStart(); return true; } @@ -231,13 +176,6 @@ public abstract class AbstractStateChangeTouchController protected void onReachedFinalState(LauncherState newToState) { } - protected boolean goingBetweenNormalAndOverview(LauncherState fromState, - LauncherState toState) { - return (fromState == NORMAL || fromState == OVERVIEW) - && (toState == NORMAL || toState == OVERVIEW) - && mGoingBetweenStates; - } - @Override public void onDragStart(boolean start, float startDisplacement) { mStartState = mLauncher.getStateManager().getState(); @@ -252,11 +190,6 @@ public abstract class AbstractStateChangeTouchController } else { mCurrentAnimation.pause(); mStartProgress = mCurrentAnimation.getProgressFraction(); - - mAtomicAnimAutoPlayInfo = null; - if (mAtomicComponentsController != null) { - mAtomicComponentsController.pause(); - } } mCanBlockFling = mFromState == NORMAL; mFlingBlockCheck.unblockFling(); @@ -310,69 +243,6 @@ public abstract class AbstractStateChangeTouchController return; } mCurrentAnimation.setPlayFraction(fraction); - if (mAtomicComponentsController != null) { - // Make sure we don't divide by 0, and have at least a small runway. - float start = Math.min(mAtomicComponentsStartProgress, 0.9f); - mAtomicComponentsController.setPlayFraction((fraction - start) / (1 - start)); - } - maybeUpdateAtomicAnim(mFromState, mToState, fraction); - } - - /** - * When going between normal and overview states, see if we passed the overview threshold and - * play the appropriate atomic animation if so. - */ - private void maybeUpdateAtomicAnim(LauncherState fromState, LauncherState toState, - float progress) { - if (!goingBetweenNormalAndOverview(fromState, toState)) { - return; - } - boolean passedThreshold = progress >= ATOMIC_OVERVIEW_ANIM_THRESHOLD; - if (passedThreshold != mPassedOverviewAtomicThreshold) { - LauncherState atomicFromState = passedThreshold ? fromState: toState; - LauncherState atomicToState = passedThreshold ? toState : fromState; - mPassedOverviewAtomicThreshold = passedThreshold; - if (mAtomicAnim != null) { - mAtomicAnim.cancel(); - } - mAtomicAnim = createAtomicAnimForState(atomicFromState, atomicToState, ATOMIC_DURATION); - mAtomicAnim.addListener(new AnimationSuccessListener() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - mAtomicAnim = null; - mScheduleResumeAtomicComponent = false; - } - - @Override - public void onAnimationSuccess(Animator animator) { - if (!mScheduleResumeAtomicComponent) { - return; - } - cancelAtomicComponentsController(); - - if (mCurrentAnimation != null) { - mAtomicComponentsStartProgress = mCurrentAnimation.getProgressFraction(); - long duration = (long) (getShiftRange() * 2); - mAtomicComponentsController = AnimatorPlaybackController.wrap( - createAtomicAnimForState(mFromState, mToState, duration), duration); - mAtomicComponentsController.dispatchOnStart(); - mAtomicComponentsTargetState = mToState; - maybeAutoPlayAtomicComponentsAnim(); - } - } - }); - mAtomicAnim.start(); - mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); - } - } - - private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState, - long duration) { - StateAnimationConfig config = getConfigForStates(fromState, targetState); - config.animFlags = PLAY_ATOMIC_OVERVIEW_SCALE; - config.duration = duration; - return mLauncher.getStateManager().createAtomicAnimation(fromState, targetState, config); } /** @@ -451,59 +321,12 @@ public abstract class AbstractStateChangeTouchController mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(targetState)); ValueAnimator anim = mCurrentAnimation.getAnimationPlayer(); anim.setFloatValues(startProgress, endProgress); - maybeUpdateAtomicAnim(mFromState, targetState, targetState == mToState ? 1f : 0f); - updateSwipeCompleteAnimation(anim, Math.max(duration, getRemainingAtomicDuration()), - targetState, velocity, fling); + updateSwipeCompleteAnimation(anim, duration, targetState, velocity, fling); mCurrentAnimation.dispatchOnStart(); if (fling && targetState == LauncherState.ALL_APPS && !UNSTABLE_SPRINGS.get()) { mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity); } anim.start(); - mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration()); - maybeAutoPlayAtomicComponentsAnim(); - } - - /** - * Animates the atomic components from the current progress to the final progress. - * - * Note that this only applies when we are controlling the atomic components separately from - * the non-atomic components, which only happens if we reinit before the atomic animation - * finishes. - */ - private void maybeAutoPlayAtomicComponentsAnim() { - if (mAtomicComponentsController == null || mAtomicAnimAutoPlayInfo == null) { - return; - } - - final AnimatorPlaybackController controller = mAtomicComponentsController; - ValueAnimator atomicAnim = controller.getAnimationPlayer(); - atomicAnim.setFloatValues(controller.getProgressFraction(), - mAtomicAnimAutoPlayInfo.toProgress); - long duration = mAtomicAnimAutoPlayInfo.endTime - SystemClock.elapsedRealtime(); - mAtomicAnimAutoPlayInfo = null; - if (duration <= 0) { - atomicAnim.start(); - atomicAnim.end(); - mAtomicComponentsController = null; - } else { - atomicAnim.setDuration(duration); - atomicAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - if (mAtomicComponentsController == controller) { - mAtomicComponentsController = null; - } - } - }); - atomicAnim.start(); - } - } - - private long getRemainingAtomicDuration() { - if (mAtomicAnim == null) { - return 0; - } - return mAtomicAnim.getTotalDuration() - mAtomicAnim.getCurrentPlayTime(); } protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration, @@ -513,10 +336,6 @@ public abstract class AbstractStateChangeTouchController } protected void onSwipeInteractionCompleted(LauncherState targetState) { - if (mAtomicComponentsController != null) { - mAtomicComponentsController.getAnimationPlayer().end(); - mAtomicComponentsController = null; - } onReachedFinalState(mToState); clearState(); boolean shouldGoToTargetState = mGoingBetweenStates || (mToState != targetState); @@ -556,37 +375,12 @@ public abstract class AbstractStateChangeTouchController protected void clearState() { cancelAnimationControllers(); - if (mAtomicAnim != null) { - mAtomicAnim.cancel(); - mAtomicAnim = null; - } mGoingBetweenStates = true; - mScheduleResumeAtomicComponent = false; mDetector.finishedScrolling(); mDetector.setDetectableScrollConditions(0, false); } private void cancelAnimationControllers() { mCurrentAnimation = null; - cancelAtomicComponentsController(); - } - - private void cancelAtomicComponentsController() { - if (mAtomicComponentsController != null) { - mAtomicComponentsController.getAnimationPlayer().cancel(); - mAtomicComponentsController = null; - } - mAtomicAnimAutoPlayInfo = null; - } - - private static class AutoPlayAtomicAnimationInfo { - - public final float toProgress; - public final long endTime; - - AutoPlayAtomicAnimationInfo(float toProgress, long duration) { - this.toProgress = toProgress; - this.endTime = duration + SystemClock.elapsedRealtime(); - } } } diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java index f9dcf2d2e9..ab2652ab5e 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -23,24 +23,18 @@ import android.view.MotionEvent; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.states.StateAnimationConfig.AnimationFlags; /** * TouchController to switch between NORMAL and ALL_APPS state. */ public class AllAppsSwipeController extends AbstractStateChangeTouchController { - private MotionEvent mTouchDownEvent; - public AllAppsSwipeController(Launcher l) { super(l, SingleAxisSwipeDetector.VERTICAL); } @Override protected boolean canInterceptTouch(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mTouchDownEvent = ev; - } if (mCurrentAnimation != null) { // If we are already animating from a previous state, we can intercept. return true; @@ -69,11 +63,11 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { } @Override - protected float initCurrentAnimation(@AnimationFlags int animComponents) { + protected float initCurrentAnimation() { float range = getShiftRange(); long maxAccuracy = (long) (2 * range); mCurrentAnimation = mLauncher.getStateManager() - .createAnimationToNewWorkspace(mToState, maxAccuracy, animComponents); + .createAnimationToNewWorkspace(mToState, maxAccuracy); float startVerticalShift = mFromState.getVerticalProgress(mLauncher) * range; float endVerticalShift = mToState.getVerticalProgress(mLauncher) * range; float totalShift = endVerticalShift - startVerticalShift;