diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java b/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java deleted file mode 100644 index 4038c99437..0000000000 --- a/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.launcher3.uioverrides; - -/** - * State indicating that the Launcher is behind an app. Same as {@link OverviewState} for Go as we - * do not support swipe to overview or swipe to home. - */ -public final class BackgroundAppState extends OverviewState { - public BackgroundAppState(int id) { - super(id); - } -} diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java index 14c3495548..6293b82d84 100644 --- a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java @@ -91,4 +91,13 @@ public class OverviewState extends LauncherState { public static float getDefaultSwipeHeight(DeviceProfile dp) { return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx; } + + + public static OverviewState newBackgroundState(int id) { + return new OverviewState(id); + } + + public static OverviewState newPeekState(int id) { + return new OverviewState(id); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java index a9c8f0dfe9..7b33abb6b2 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java @@ -18,11 +18,18 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT; +import static com.android.launcher3.LauncherState.OVERVIEW_PEEK; +import static com.android.launcher3.LauncherStateManager.ANIM_ALL; +import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_PEEK_COMPONENT; +import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; -import android.animation.ValueAnimator; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.view.HapticFeedbackConstants; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherState; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.quickstep.util.MotionPauseDetector; @@ -33,13 +40,22 @@ import com.android.quickstep.views.RecentsView; */ public class FlingAndHoldTouchController extends PortraitStatesTouchController { + private static final long PEEK_ANIM_DURATION = 100; + private final MotionPauseDetector mMotionPauseDetector; + private AnimatorSet mPeekAnim; + public FlingAndHoldTouchController(Launcher l) { super(l, false /* allowDragToOverview */); mMotionPauseDetector = new MotionPauseDetector(l); } + @Override + protected long getAtomicDuration() { + return 300; + } + @Override public void onDragStart(boolean start) { mMotionPauseDetector.clear(); @@ -50,7 +66,23 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { mMotionPauseDetector.setOnMotionPauseListener(isPaused -> { RecentsView recentsView = mLauncher.getOverviewPanel(); recentsView.setOverviewStateEnabled(isPaused); - maybeUpdateAtomicAnim(NORMAL, OVERVIEW, isPaused ? 1 : 0); + if (mPeekAnim != null) { + mPeekAnim.cancel(); + } + LauncherState fromState = isPaused ? NORMAL : OVERVIEW_PEEK; + LauncherState toState = isPaused ? OVERVIEW_PEEK : NORMAL; + mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(fromState, toState, + new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT, + PEEK_ANIM_DURATION); + mPeekAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mPeekAnim = null; + } + }); + mPeekAnim.start(); + recentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); }); } } @@ -72,30 +104,21 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { @Override public void onDragEnd(float velocity, boolean fling) { if (mMotionPauseDetector.isPaused() && handlingOverviewAnim()) { - float range = getShiftRange(); - long maxAccuracy = (long) (2 * range); + if (mPeekAnim != null) { + mPeekAnim.cancel(); + } - // Let the state manager know that the animation didn't go to the target state, - // but don't cancel ourselves (we already clean up when the animation completes). - Runnable onCancel = mCurrentAnimation.getOnCancelRunnable(); - mCurrentAnimation.setOnCancelRunnable(null); - mCurrentAnimation.dispatchOnCancel(); - mCurrentAnimation = mLauncher.getStateManager() - .createAnimationToNewWorkspace(OVERVIEW, new AnimatorSetBuilder(), maxAccuracy, - onCancel, NON_ATOMIC_COMPONENT); - - final int logAction = fling ? Touch.FLING : Touch.SWIPE; - mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(OVERVIEW, logAction)); - - - ValueAnimator anim = mCurrentAnimation.getAnimationPlayer(); - maybeUpdateAtomicAnim(NORMAL, OVERVIEW, 1f); - mCurrentAnimation.dispatchOnStartWithVelocity(1, velocity); - - // TODO: Find a better duration - anim.setDuration(100); - anim.start(); - settleAtomicAnimation(1f, anim.getDuration()); + AnimatorSetBuilder builder = new AnimatorSetBuilder(); + builder.setInterpolator(AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS, OVERSHOOT_1_2); + AnimatorSet overviewAnim = mLauncher.getStateManager().createAtomicAnimation( + NORMAL, OVERVIEW, builder, ANIM_ALL, ATOMIC_DURATION); + overviewAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE); + } + }); + overviewAnim.start(); } else { super.onDragEnd(velocity, fling); } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewPeekState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewPeekState.java new file mode 100644 index 0000000000..8f4d697178 --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewPeekState.java @@ -0,0 +1,18 @@ +package com.android.launcher3.uioverrides; + +import com.android.launcher3.Launcher; +import com.android.launcher3.R; + +public class OverviewPeekState extends OverviewState { + public OverviewPeekState(int id) { + super(id); + } + + @Override + public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { + ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher); + result.translationX = NORMAL.getOverviewScaleAndTranslation(launcher).translationX + - launcher.getResources().getDimension(R.dimen.overview_peek_distance); + return result; + } +} diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java index db02c53d1f..1754b8041e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java @@ -151,4 +151,12 @@ public class OverviewState extends LauncherState { super.onBackPressed(launcher); } } + + public static OverviewState newBackgroundState(int id) { + return new BackgroundAppState(id); + } + + public static OverviewState newPeekState(int id) { + return new OverviewPeekState(id); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index 81ff0c7cad..8e62cd3407 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides; import static android.view.View.VISIBLE; - import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; @@ -98,6 +97,10 @@ public abstract class RecentsUiFactory { * @param launcher the launcher activity */ public static void prepareToShowOverview(Launcher launcher) { + if (FeatureFlags.SWIPE_HOME.get()) { + // Overview lives on the side, so doesn't scale in from above. + return; + } RecentsView overview = launcher.getOverviewPanel(); if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) { SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE); diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 9c97c8c905..97f2de7622 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -24,7 +24,7 @@ 2dp 10dp 70dp - 20dp + 32dp diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index 7b8699059e..89093e9914 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -71,7 +71,9 @@ public abstract class BaseRecentsViewStateController @Override public final void setStateWithAnimation(@NonNull final LauncherState toState, @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) { - if (!config.playAtomicComponent()) { + boolean playAtomicOverviewComponent = config.playAtomicOverviewScaleComponent() + || config.playAtomicOverviewPeekComponent(); + if (!playAtomicOverviewComponent) { // The entire recents animation is played atomically. return; } diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java index 8a117c8592..96620bd954 100644 --- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java @@ -71,9 +71,6 @@ public class MotionPauseDetector { */ public void setOnMotionPauseListener(OnMotionPauseListener listener) { mOnMotionPauseListener = listener; - if (mOnMotionPauseListener != null) { - mOnMotionPauseListener.onMotionPauseChanged(mIsPaused); - } } /** diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index b6e00cc8aa..a3d5994e8c 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -18,10 +18,10 @@ package com.android.launcher3; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; - import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL; +import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL; import static com.android.launcher3.anim.Interpolators.ACCEL_2; @@ -29,9 +29,9 @@ import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; import android.view.animation.Interpolator; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.states.SpringLoadedState; import com.android.launcher3.uioverrides.AllAppsState; -import com.android.launcher3.uioverrides.BackgroundAppState; import com.android.launcher3.uioverrides.OverviewState; import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; @@ -92,10 +92,13 @@ public class LauncherState { */ public static final LauncherState SPRING_LOADED = new SpringLoadedState( SPRING_LOADED_STATE_ORDINAL); - public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL); public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL); - public static final LauncherState BACKGROUND_APP = new BackgroundAppState( - BACKGROUND_APP_STATE_ORDINAL); + + public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL); + public static final LauncherState OVERVIEW_PEEK = + OverviewState.newPeekState(OVERVIEW_PEEK_STATE_ORDINAL); + public static final LauncherState BACKGROUND_APP = + OverviewState.newBackgroundState(BACKGROUND_APP_STATE_ORDINAL); public final int ordinal; @@ -193,6 +196,11 @@ public class LauncherState { } public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { + if (FeatureFlags.SWIPE_HOME.get()) { + float offscreenTranslationX = launcher.getDragLayer().getWidth() + - launcher.getOverviewPanel().getPaddingStart(); + return new ScaleAndTranslation(1f, offscreenTranslationX, 0f); + } return new ScaleAndTranslation(1.1f, 0f, 0f); } diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index 97c8f51ccc..19c896fbab 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -18,14 +18,20 @@ package com.android.launcher3; import static android.view.View.VISIBLE; 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.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; +import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.anim.Interpolators.ACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7; +import static com.android.launcher3.anim.Interpolators.INSTANT; +import static com.android.launcher3.anim.Interpolators.NEVER; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; +import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7; import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER; @@ -96,17 +102,21 @@ public class LauncherStateManager { // 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. + // non atomic components as well. Note that each gesture model has exactly one atomic component, + // ATOMIC_OVERVIEW_SCALE_COMPONENT *or* ATOMIC_OVERVIEW_PEEK_COMPONENT. @IntDef(flag = true, value = { NON_ATOMIC_COMPONENT, - ATOMIC_COMPONENT + ATOMIC_OVERVIEW_SCALE_COMPONENT, + ATOMIC_OVERVIEW_PEEK_COMPONENT, }) @Retention(RetentionPolicy.SOURCE) public @interface AnimationComponents {} public static final int NON_ATOMIC_COMPONENT = 1 << 0; - public static final int ATOMIC_COMPONENT = 1 << 1; + public static final int ATOMIC_OVERVIEW_SCALE_COMPONENT = 1 << 1; + public static final int ATOMIC_OVERVIEW_PEEK_COMPONENT = 1 << 2; - public static final int ANIM_ALL = NON_ATOMIC_COMPONENT | ATOMIC_COMPONENT; + public static final int ANIM_ALL = NON_ATOMIC_COMPONENT | ATOMIC_OVERVIEW_SCALE_COMPONENT + | ATOMIC_OVERVIEW_PEEK_COMPONENT; private final AnimationConfig mConfig = new AnimationConfig(); private final Handler mUiHandler; @@ -282,18 +292,20 @@ public class LauncherStateManager { */ public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, AnimatorSetBuilder builder) { - if (fromState == NORMAL && toState.overviewUi) { + if (fromState == NORMAL && toState == OVERVIEW) { builder.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2); builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2); builder.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2); + builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE, OVERSHOOT_1_7); builder.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2); // Start from a higher overview scale, but only if we're invisible so we don't jump. UiFactory.prepareToShowOverview(mLauncher); - } else if (fromState.overviewUi && toState == NORMAL) { + } else if (fromState == OVERVIEW && toState == NORMAL) { builder.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL); builder.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL); builder.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f)); + builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE, ACCEL); builder.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7); Workspace workspace = mLauncher.getWorkspace(); @@ -311,9 +323,25 @@ public class LauncherStateManager { workspace.getHotseat().setScaleX(0.92f); workspace.getHotseat().setScaleY(0.92f); } + } else if (fromState == NORMAL && toState == OVERVIEW_PEEK) { + builder.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT); + } else if (fromState == OVERVIEW_PEEK && toState == NORMAL) { + builder.setInterpolator(ANIM_OVERVIEW_FADE, NEVER); } } + public AnimatorSet createAtomicAnimation(LauncherState fromState, LauncherState toState, + AnimatorSetBuilder builder, @AnimationComponents int atomicComponent, long duration) { + prepareForAtomicAnimation(fromState, toState, builder); + AnimationConfig config = new AnimationConfig(); + config.animComponents = atomicComponent; + config.duration = duration; + for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) { + handler.setStateWithAnimation(toState, builder, config); + } + return builder.build(); + } + /** * Creates a {@link AnimatorPlaybackController} that can be used for a controlled * state transition. The UI is force-set to fromState before creating the controller. @@ -593,8 +621,12 @@ public class LauncherStateManager { mCurrentAnimation.addListener(this); } - public boolean playAtomicComponent() { - return (animComponents & ATOMIC_COMPONENT) != 0; + public boolean playAtomicOverviewScaleComponent() { + return (animComponents & ATOMIC_OVERVIEW_SCALE_COMPONENT) != 0; + } + + public boolean playAtomicOverviewPeekComponent() { + return (animComponents & ATOMIC_OVERVIEW_PEEK_COMPONENT) != 0; } public boolean playNonAtomicComponent() { diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java index 4eb3627566..8b7279ca9a 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -28,8 +28,9 @@ public final class TestProtocol { public static final int NORMAL_STATE_ORDINAL = 0; public static final int SPRING_LOADED_STATE_ORDINAL = 1; public static final int OVERVIEW_STATE_ORDINAL = 2; - public static final int ALL_APPS_STATE_ORDINAL = 3; - public static final int BACKGROUND_APP_STATE_ORDINAL = 4; + public static final int OVERVIEW_PEEK_STATE_ORDINAL = 3; + public static final int ALL_APPS_STATE_ORDINAL = 4; + public static final int BACKGROUND_APP_STATE_ORDINAL = 5; public static final String TEST_INFO_RESPONSE_FIELD = "response"; public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT = diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index bed61a1884..21fdd3df08 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -86,7 +86,7 @@ public class WorkspaceStateTransitionAnimation { int elements = state.getVisibleElements(mLauncher); Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator); - boolean playAtomicComponent = config.playAtomicComponent(); + boolean playAtomicComponent = config.playAtomicOverviewScaleComponent(); Hotseat hotseat = mWorkspace.getHotseat(); if (playAtomicComponent) { Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT); @@ -147,7 +147,7 @@ public class WorkspaceStateTransitionAnimation { propertySetter.setInt(cl.getScrimBackground(), DRAWABLE_ALPHA, drawableAlpha, ZOOM_OUT); } - if (config.playAtomicComponent()) { + if (config.playAtomicOverviewScaleComponent()) { Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator); propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA, diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java index 675e26de05..217b6db2cf 100644 --- a/src/com/android/launcher3/anim/Interpolators.java +++ b/src/com/android/launcher3/anim/Interpolators.java @@ -57,6 +57,9 @@ public class Interpolators { public static final Interpolator EXAGGERATED_EASE; + public static final Interpolator INSTANT = t -> 1; + public static final Interpolator NEVER = t -> 0; + private static final int MIN_SETTLE_DURATION = 200; private static final float OVERSHOOT_FACTOR = 0.9f; @@ -69,6 +72,7 @@ public class Interpolators { } public static final Interpolator OVERSHOOT_1_2 = new OvershootInterpolator(1.2f); + public static final Interpolator OVERSHOOT_1_7 = new OvershootInterpolator(1.7f); public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR = new PathInterpolator(0.3f, 0f, 0.1f, 1f); diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index c125c10d7a..86deb43e04 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -20,7 +20,7 @@ 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_COMPONENT; +import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_SCALE_COMPONENT; import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT; import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; @@ -38,9 +38,6 @@ 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.AnimationConfig; -import com.android.launcher3.LauncherStateManager.StateHandler; -import com.android.launcher3.TestProtocol; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -68,7 +65,7 @@ public abstract class AbstractStateChangeTouchController * Play an atomic recents animation when the progress from NORMAL to OVERVIEW reaches this. */ public static final float ATOMIC_OVERVIEW_ANIM_THRESHOLD = 0.5f; - protected static final long ATOMIC_DURATION = 200; + protected final long ATOMIC_DURATION = getAtomicDuration(); protected final Launcher mLauncher; protected final SwipeDetector mDetector; @@ -110,6 +107,10 @@ public abstract class AbstractStateChangeTouchController mDetector = new SwipeDetector(l, this, dir); } + protected long getAtomicDuration() { + return 200; + } + protected abstract boolean canInterceptTouch(MotionEvent ev); @Override @@ -214,7 +215,7 @@ public abstract class AbstractStateChangeTouchController } if (mAtomicComponentsController != null) { - animComponents &= ~ATOMIC_COMPONENT; + animComponents &= ~ATOMIC_OVERVIEW_SCALE_COMPONENT; } mProgressMultiplier = initCurrentAnimation(animComponents); mCurrentAnimation.dispatchOnStart(); @@ -297,7 +298,7 @@ public abstract class AbstractStateChangeTouchController * When going between normal and overview states, see if we passed the overview threshold and * play the appropriate atomic animation if so. */ - protected void maybeUpdateAtomicAnim(LauncherState fromState, LauncherState toState, + private void maybeUpdateAtomicAnim(LauncherState fromState, LauncherState toState, float progress) { if (!goingBetweenNormalAndOverview(fromState, toState)) { return; @@ -347,14 +348,8 @@ public abstract class AbstractStateChangeTouchController private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState, long duration) { AnimatorSetBuilder builder = getAnimatorSetBuilderForStates(fromState, targetState); - mLauncher.getStateManager().prepareForAtomicAnimation(fromState, targetState, builder); - AnimationConfig config = new AnimationConfig(); - config.animComponents = ATOMIC_COMPONENT; - config.duration = duration; - for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) { - handler.setStateWithAnimation(targetState, builder, config); - } - return builder.build(); + return mLauncher.getStateManager().createAtomicAnimation(fromState, targetState, builder, + ATOMIC_OVERVIEW_SCALE_COMPONENT, duration); } protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState, @@ -434,11 +429,7 @@ public abstract class AbstractStateChangeTouchController mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity); } anim.start(); - settleAtomicAnimation(endProgress, anim.getDuration()); - } - - protected void settleAtomicAnimation(float endProgress, long duration) { - mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, duration); + mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration()); maybeAutoPlayAtomicComponentsAnim(); } diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java index 8def0d3ccc..56e0aa50a3 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java @@ -28,4 +28,12 @@ public class OverviewState extends LauncherState { public OverviewState(int id) { super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, FLAG_DISABLE_RESTORE); } + + public static OverviewState newBackgroundState(int id) { + return new OverviewState(id); + } + + public static OverviewState newPeekState(int id) { + return new OverviewState(id); + } }