Merge "Tune AllApps dismiss animation" into tm-dev am: f1a4296cd0

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17757986

Change-Id: I9e275ebedf5606a97dbfa59183a56c859530fe63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-03 13:26:39 +00:00
committed by Automerger Merge Worker
26 changed files with 62 additions and 50 deletions

View File

@@ -17,6 +17,7 @@ package com.android.launcher3.taskbar;
import static android.view.HapticFeedbackConstants.LONG_PRESS;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.Utilities.appendFlag;
@@ -34,7 +35,6 @@ import android.view.WindowInsets;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.AnimatedFloat;
@@ -564,7 +564,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, false);
if (applyState) {
applyState(TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION);
applyState(ALL_APPS.getTransitionDuration(
mControllers.taskbarActivityContext, false /* isToState */));
}
}

View File

@@ -15,13 +15,16 @@
*/
package com.android.launcher3.taskbar.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.systemui.animation.Interpolators.EMPHASIZED_ACCELERATE;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
@@ -33,9 +36,6 @@ import java.util.Optional;
/** Wrapper for taskbar all apps with slide-in behavior. */
public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllAppsContext>
implements Insettable, DeviceProfile.OnDeviceProfileChangeListener {
static final int DEFAULT_OPEN_DURATION = 500;
public static final int DEFAULT_CLOSE_DURATION = 200;
private TaskbarAllAppsContainerView mAppsView;
private OnCloseListener mOnCloseBeginListener;
private float mShiftRange;
@@ -61,7 +61,8 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp
mOpenCloseAnimator.setValues(
PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE);
mOpenCloseAnimator.setDuration(DEFAULT_OPEN_DURATION).start();
mOpenCloseAnimator.setDuration(
ALL_APPS.getTransitionDuration(mContext, true /* isToState */)).start();
} else {
mTranslationShift = TRANSLATION_SHIFT_OPENED;
}
@@ -80,7 +81,12 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp
@Override
protected void handleClose(boolean animate) {
Optional.ofNullable(mOnCloseBeginListener).ifPresent(OnCloseListener::onSlideInViewClosed);
handleClose(animate, DEFAULT_CLOSE_DURATION);
handleClose(animate, ALL_APPS.getTransitionDuration(mContext, false /* isToState */));
}
@Override
protected Interpolator getIdleInterpolator() {
return EMPHASIZED_ACCELERATE;
}
@Override

View File

@@ -15,8 +15,8 @@
*/
package com.android.launcher3.taskbar.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_ALL_APPS;
import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_OPEN_DURATION;
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
import com.android.launcher3.AbstractFloatingView;
@@ -81,7 +81,8 @@ final class TaskbarAllAppsViewController {
private void setUpTaskbarStashing() {
mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, true);
mTaskbarStashController.applyState(DEFAULT_OPEN_DURATION);
mTaskbarStashController.applyState(
ALL_APPS.getTransitionDuration(mContext, true /* isToState */));
mSlideInView.setOnCloseBeginListener(() -> {
AbstractFloatingView.closeOpenContainer(
mContext, AbstractFloatingView.TYPE_ACTION_POPUP);

View File

@@ -118,7 +118,7 @@ public final class RecentsViewStateController extends
if (toState == OVERVIEW_SPLIT_SELECT) {
// Animation to "dismiss" selected taskView
PendingAnimation splitSelectInitAnimation = mRecentsView.createSplitSelectInitAnimation(
toState.getTransitionDuration(mLauncher));
toState.getTransitionDuration(mLauncher, true /* isToState */));
// Add properties to shift remaining taskViews to get out of placeholder view
splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.first,
toState.getSplitSelectTranslation(mLauncher), LINEAR);

View File

@@ -38,8 +38,8 @@ public class AllAppsState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
return 150;
public int getTransitionDuration(Context context, boolean isToState) {
return isToState ? 500 : 300;
}
@Override

View File

@@ -40,7 +40,7 @@ public class OverviewModalTaskState extends OverviewState {
}
@Override
public int getTransitionDuration(Context launcher) {
public int getTransitionDuration(Context launcher, boolean isToState) {
return 300;
}

View File

@@ -58,7 +58,7 @@ public class OverviewState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
// In gesture modes, overview comes in all the way from the side, so give it more time.
return DisplayController.getNavigationMode(context).hasGestures ? 380 : 250;
}

View File

@@ -42,6 +42,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SC
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.ANIM_SCRIM_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
@@ -50,6 +51,8 @@ import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesT
import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_OPAQUE_THRESHOLD;
import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_VISIBLE_THRESHOLD;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.systemui.animation.Interpolators.EMPHASIZED_ACCELERATE;
import static com.android.systemui.animation.Interpolators.EMPHASIZED_DECELERATE;
import android.animation.ValueAnimator;
@@ -179,12 +182,17 @@ public class QuickstepAtomicAnimationFactory extends
}
config.duration = Math.max(config.duration, mHintToNormalDuration);
} else if (fromState == ALL_APPS && toState == NORMAL) {
config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL,
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
boolean isTablet = mActivity.getDeviceProfile().isTablet;
config.setInterpolator(ANIM_ALL_APPS_FADE,
isTablet ? FINAL_FRAME : Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_ACCELERATE);
} else if (fromState == NORMAL && toState == ALL_APPS) {
config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_DECELERATE);
}
}
}

View File

@@ -180,7 +180,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
// Normally we compute the duration based on the velocity and distance to the given
// state, but since the hint state tracks the entire screen without a clear endpoint, we
// need to manually set the duration to a reasonable value.
animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher));
animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher, true /* isToState */));
}
}

View File

@@ -21,10 +21,9 @@ import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType;
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.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
@@ -131,10 +130,10 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? INSTANT
: Interpolators.clampToProgress(ACCEL,
: Interpolators.clampToProgress(LINEAR,
ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD,
ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD));
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(ACCEL,
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
ALL_APPS_SCRIM_VISIBLE_THRESHOLD,
ALL_APPS_SCRIM_OPAQUE_THRESHOLD));
return builder;
@@ -145,10 +144,10 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? FINAL_FRAME
: Interpolators.clampToProgress(DEACCEL,
: Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
return builder;

View File

@@ -112,7 +112,7 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
RecentsState currentState = mActivity.getStateManager().getState();
if (isSplitSelectionState(state) && !isSplitSelectionState(currentState)) {
setter.add(mRecentsView.createSplitSelectInitAnimation(
state.getTransitionDuration(mActivity)).buildAnim());
state.getTransitionDuration(mActivity, true /* isToState */)).buildAnim());
}
Pair<FloatProperty, FloatProperty> taskViewsFloat =

View File

@@ -77,7 +77,7 @@ public class RecentsState implements BaseState<RecentsState> {
}
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
return 250;
}

View File

@@ -82,7 +82,7 @@ public class OverviewToHomeAnim {
// WorkspaceRevealAnim handles the depth, so don't interfere.
config.animFlags |= StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
}
config.duration = startState.getTransitionDuration(mLauncher);
config.duration = startState.getTransitionDuration(mLauncher, false /* isToState */);
AnimatorSet stateAnim = stateManager.createAtomicAnimation(
startState, NORMAL, config);
stateAnim.addListener(new AnimationSuccessListener() {

View File

@@ -4059,7 +4059,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// TODO(194414938) starting bounds seem slightly off, investigate
Rect firstTaskStartingBounds = new Rect();
Rect firstTaskEndingBounds = mTempRect;
int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext(),
false /* isToState */);
PendingAnimation pendingAnimation = new PendingAnimation(duration);
int halfDividerSize = getResources()

View File

@@ -113,7 +113,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
FLAG_HAS_SYS_UI_SCRIM) {
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
// Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
return 0;
}

View File

@@ -2118,7 +2118,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
final Runnable onCompleteCallback = onCompleteRunnable;
mLauncher.getDragController().animateDragViewToOriginalPosition(
/* onComplete= */ callbackList::executeAllAndDestroy, cell,
SPRING_LOADED.getTransitionDuration(mLauncher));
SPRING_LOADED.getTransitionDuration(mLauncher, true /* isToState */));
mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0,
onCompleteCallback == null
? null

View File

@@ -255,8 +255,6 @@ public class AllAppsTransitionController
anim.setInterpolator(verticalProgressInterpolator);
anim.addListener(getProgressAnimatorListener());
builder.add(anim);
// Use ANIM_VERTICAL_PROGRESS's interpolator to determine state transition threshold.
builder.setInterpolator(verticalProgressInterpolator);
setAlphas(toState, config, builder);

View File

@@ -47,13 +47,6 @@ public class Interpolators {
public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f);
public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f);
/**
* The decelerating emphasized interpolator. Used for hero / emphasized movement of content that
* is appearing e.g. when coming from off screen
*/
public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
0.05f, 0.7f, 0.1f, 1f);
public static final Interpolator ACCEL_DEACCEL = new AccelerateDecelerateInterpolator();
public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);

View File

@@ -87,7 +87,8 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
// Total duration for the drop animation to complete.
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
LauncherState.SPRING_LOADED.getTransitionDuration(Launcher.getLauncher(mContext));
LauncherState.SPRING_LOADED.getTransitionDuration(Launcher.getLauncher(mContext),
true /* isToState */);
// Delay the actual accept() call until the drop animation is complete.
return PinRequestHelper.createWorkspaceItemFromPinItemRequest(
mContext, mRequest, duration);

View File

@@ -36,7 +36,7 @@ public interface BaseState<T extends BaseState> {
/**
* @return How long the animation to this state should take (or from this state to NORMAL).
*/
int getTransitionDuration(Context context);
int getTransitionDuration(Context context, boolean isToState);
/**
* Returns the state to go back to from this state

View File

@@ -253,8 +253,8 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
// Since state mBaseState can be reached from multiple states, just assume that the
// transition plays in reverse and use the same duration as previous state.
mConfig.duration = state == mBaseState
? fromState.getTransitionDuration(mActivity)
: state.getTransitionDuration(mActivity);
? fromState.getTransitionDuration(mActivity, false /* isToState */)
: state.getTransitionDuration(mActivity, true /* isToState */);
prepareForAtomicAnimation(fromState, state, mConfig);
AnimatorSet animation = createAnimationToNewWorkspaceInternal(state).buildAnim();
if (listener != null) {

View File

@@ -43,7 +43,7 @@ public class HintState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
return 80;
}

View File

@@ -39,7 +39,7 @@ public class SpringLoadedState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
return 150;
}

View File

@@ -231,13 +231,17 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
if (mSwipeDetector.isIdleState()) {
mOpenCloseAnimator
.setDuration(defaultDuration)
.setInterpolator(Interpolators.ACCEL);
.setInterpolator(getIdleInterpolator());
} else {
mOpenCloseAnimator.setInterpolator(mScrollInterpolator);
}
mOpenCloseAnimator.start();
}
protected Interpolator getIdleInterpolator() {
return Interpolators.ACCEL;
}
protected void onCloseComplete() {
mIsOpen = false;
getPopupContainer().removeView(this);

View File

@@ -39,8 +39,8 @@ public class AllAppsState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
return 320;
public int getTransitionDuration(Context context, boolean isToState) {
return isToState ? 500 : 300;
}
@Override

View File

@@ -34,7 +34,7 @@ public class OverviewState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context) {
public int getTransitionDuration(Context context, boolean isToState) {
return 250;
}