mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Unify the source of truth for NORMAL <> ALL_APPS transitions.
Bug: 231682175 Bug: 234812580 Test: manual Change-Id: I5b66735474915d7a59bda337f67df37ff397908a
This commit is contained in:
@@ -47,48 +47,88 @@ import com.android.launcher3.states.StateAnimationConfig;
|
||||
*/
|
||||
public class AllAppsSwipeController extends AbstractStateChangeTouchController {
|
||||
|
||||
private static final float ALLAPPS_STAGGERED_FADE_THRESHOLD = 0.5f;
|
||||
private static final float ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD = 0.8f;
|
||||
private static final float ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD = 0.5f;
|
||||
private static final float ALL_APPS_SCRIM_VISIBLE_THRESHOLD = 0.1f;
|
||||
private static final float ALL_APPS_STAGGERED_FADE_THRESHOLD = 0.5f;
|
||||
|
||||
// Custom timing for NORMAL -> ALL_APPS on phones only.
|
||||
private static final float WORKSPACE_MOTION_START = 0.1667f;
|
||||
private static final float ALL_APPS_STATE_TRANSITION = 0.305f;
|
||||
private static final float ALL_APPS_FADE_END = 0.4717f;
|
||||
public static final Interpolator ALL_APPS_SCRIM_RESPONDER =
|
||||
Interpolators.clampToProgress(
|
||||
LINEAR, ALL_APPS_SCRIM_VISIBLE_THRESHOLD, ALL_APPS_STAGGERED_FADE_THRESHOLD);
|
||||
public static final Interpolator ALL_APPS_CLAMPING_RESPONDER =
|
||||
Interpolators.clampToProgress(
|
||||
LINEAR,
|
||||
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
|
||||
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD);
|
||||
|
||||
// ---- Custom interpolators for NORMAL -> ALL_APPS on phones only. ----
|
||||
|
||||
private static final float WORKSPACE_MOTION_START_ATOMIC = 0.1667f;
|
||||
private static final float ALL_APPS_STATE_TRANSITION_ATOMIC = 0.305f;
|
||||
private static final float ALL_APPS_STATE_TRANSITION_MANUAL = 0.4f;
|
||||
private static final float ALL_APPS_FADE_END_ATOMIC = 0.4717f;
|
||||
private static final float ALL_APPS_FULL_DEPTH_PROGRESS = 0.5f;
|
||||
|
||||
public static final Interpolator ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER =
|
||||
Interpolators.clampToProgress(LINEAR, 0, ALLAPPS_STAGGERED_FADE_THRESHOLD);
|
||||
public static final Interpolator ALLAPPS_STAGGERED_FADE_LATE_RESPONDER =
|
||||
Interpolators.clampToProgress(LINEAR, ALLAPPS_STAGGERED_FADE_THRESHOLD, 1f);
|
||||
private static final Interpolator LINEAR_EARLY_MANUAL =
|
||||
Interpolators.clampToProgress(LINEAR, 0f, ALL_APPS_STATE_TRANSITION_MANUAL);
|
||||
private static final Interpolator STEP_TRANSITION_ATOMIC =
|
||||
Interpolators.clampToProgress(FINAL_FRAME, 0f, ALL_APPS_STATE_TRANSITION_ATOMIC);
|
||||
private static final Interpolator STEP_TRANSITION_MANUAL =
|
||||
Interpolators.clampToProgress(FINAL_FRAME, 0f, ALL_APPS_STATE_TRANSITION_MANUAL);
|
||||
|
||||
// Custom interpolators for NORMAL -> ALL_APPS on phones only.
|
||||
// The blur to All Apps is set to be complete when the interpolator is at 0.5.
|
||||
public static final Interpolator BLUR =
|
||||
private static final Interpolator BLUR_ADJUSTED =
|
||||
Interpolators.mapToProgress(LINEAR, 0f, ALL_APPS_FULL_DEPTH_PROGRESS);
|
||||
public static final Interpolator BLUR_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
Interpolators.mapToProgress(
|
||||
LINEAR, 0f, ALL_APPS_FULL_DEPTH_PROGRESS),
|
||||
WORKSPACE_MOTION_START, ALL_APPS_STATE_TRANSITION);
|
||||
public static final Interpolator WORKSPACE_FADE =
|
||||
Interpolators.clampToProgress(FINAL_FRAME, 0f, ALL_APPS_STATE_TRANSITION);
|
||||
public static final Interpolator WORKSPACE_SCALE =
|
||||
BLUR_ADJUSTED, WORKSPACE_MOTION_START_ATOMIC, ALL_APPS_STATE_TRANSITION_ATOMIC);
|
||||
public static final Interpolator BLUR_MANUAL =
|
||||
Interpolators.clampToProgress(BLUR_ADJUSTED, 0f, ALL_APPS_STATE_TRANSITION_MANUAL);
|
||||
|
||||
public static final Interpolator WORKSPACE_FADE_ATOMIC = STEP_TRANSITION_ATOMIC;
|
||||
public static final Interpolator WORKSPACE_FADE_MANUAL = STEP_TRANSITION_MANUAL;
|
||||
|
||||
public static final Interpolator WORKSPACE_SCALE_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
EMPHASIZED_ACCELERATE, WORKSPACE_MOTION_START, ALL_APPS_STATE_TRANSITION);
|
||||
public static final Interpolator HOTSEAT_FADE = WORKSPACE_FADE;
|
||||
public static final Interpolator HOTSEAT_SCALE = HOTSEAT_FADE;
|
||||
public static final Interpolator HOTSEAT_TRANSLATE =
|
||||
EMPHASIZED_ACCELERATE, WORKSPACE_MOTION_START_ATOMIC,
|
||||
ALL_APPS_STATE_TRANSITION_ATOMIC);
|
||||
public static final Interpolator WORKSPACE_SCALE_MANUAL = LINEAR_EARLY_MANUAL;
|
||||
|
||||
public static final Interpolator HOTSEAT_FADE_ATOMIC = STEP_TRANSITION_ATOMIC;
|
||||
public static final Interpolator HOTSEAT_FADE_MANUAL = STEP_TRANSITION_MANUAL;
|
||||
|
||||
public static final Interpolator HOTSEAT_SCALE_ATOMIC = STEP_TRANSITION_ATOMIC;
|
||||
public static final Interpolator HOTSEAT_SCALE_MANUAL = LINEAR_EARLY_MANUAL;
|
||||
|
||||
public static final Interpolator HOTSEAT_TRANSLATE_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
EMPHASIZED_ACCELERATE, WORKSPACE_MOTION_START, ALL_APPS_STATE_TRANSITION);
|
||||
public static final Interpolator SCRIM_FADE =
|
||||
EMPHASIZED_ACCELERATE, WORKSPACE_MOTION_START_ATOMIC,
|
||||
ALL_APPS_STATE_TRANSITION_ATOMIC);
|
||||
public static final Interpolator HOTSEAT_TRANSLATE_MANUAL = STEP_TRANSITION_MANUAL;
|
||||
|
||||
public static final Interpolator SCRIM_FADE_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
Interpolators.mapToProgress(LINEAR, 0f, 0.8f),
|
||||
WORKSPACE_MOTION_START, ALL_APPS_STATE_TRANSITION);
|
||||
public static final Interpolator ALL_APPS_FADE =
|
||||
WORKSPACE_MOTION_START_ATOMIC, ALL_APPS_STATE_TRANSITION_ATOMIC);
|
||||
public static final Interpolator SCRIM_FADE_MANUAL = LINEAR_EARLY_MANUAL;
|
||||
|
||||
public static final Interpolator ALL_APPS_FADE_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
Interpolators.mapToProgress(DECELERATED_EASE, 0.2f, 1.0f),
|
||||
ALL_APPS_STATE_TRANSITION, ALL_APPS_FADE_END);
|
||||
public static final Interpolator ALL_APPS_VERTICAL_PROGRESS =
|
||||
Interpolators.mapToProgress(DECELERATED_EASE, 0.2f, 1f),
|
||||
ALL_APPS_STATE_TRANSITION_ATOMIC, ALL_APPS_FADE_END_ATOMIC);
|
||||
public static final Interpolator ALL_APPS_FADE_MANUAL =
|
||||
Interpolators.clampToProgress(LINEAR, ALL_APPS_STATE_TRANSITION_MANUAL, 1f);
|
||||
|
||||
public static final Interpolator ALL_APPS_VERTICAL_PROGRESS_ATOMIC =
|
||||
Interpolators.clampToProgress(
|
||||
Interpolators.mapToProgress(EMPHASIZED_DECELERATE, 0.4f, 1.0f),
|
||||
ALL_APPS_STATE_TRANSITION, 1.0f);
|
||||
Interpolators.mapToProgress(EMPHASIZED_DECELERATE, 0.4f, 1f),
|
||||
ALL_APPS_STATE_TRANSITION_ATOMIC, 1f);
|
||||
public static final Interpolator ALL_APPS_VERTICAL_PROGRESS_MANUAL =
|
||||
Interpolators.clampToProgress(
|
||||
Interpolators.mapToProgress(LINEAR, ALL_APPS_STATE_TRANSITION_MANUAL, 1f),
|
||||
ALL_APPS_STATE_TRANSITION_MANUAL, 1f);
|
||||
|
||||
// --------
|
||||
|
||||
public AllAppsSwipeController(Launcher l) {
|
||||
super(l, SingleAxisSwipeDetector.VERTICAL);
|
||||
@@ -141,6 +181,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
|
||||
protected StateAnimationConfig getConfigForStates(LauncherState fromState,
|
||||
LauncherState toState) {
|
||||
StateAnimationConfig config = super.getConfigForStates(fromState, toState);
|
||||
config.userControlled = true;
|
||||
if (fromState == NORMAL && toState == ALL_APPS) {
|
||||
applyNormalToAllAppsAnimConfig(mLauncher, config);
|
||||
} else if (fromState == ALL_APPS && toState == NORMAL) {
|
||||
@@ -150,36 +191,75 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies Animation config values for transition from all apps to home
|
||||
* Applies Animation config values for transition from all apps to home.
|
||||
*/
|
||||
public static void applyAllAppsToNormalConfig(Launcher launcher, StateAnimationConfig config) {
|
||||
boolean isTablet = launcher.getDeviceProfile().isTablet;
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
|
||||
? FINAL_FRAME : ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
|
||||
if (!isTablet) {
|
||||
config.setInterpolator(ANIM_WORKSPACE_FADE, INSTANT);
|
||||
if (launcher.getDeviceProfile().isTablet) {
|
||||
config.setInterpolator(ANIM_SCRIM_FADE,
|
||||
Interpolators.reverse(ALL_APPS_SCRIM_RESPONDER));
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, FINAL_FRAME);
|
||||
if (!config.userControlled) {
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_ACCELERATE);
|
||||
}
|
||||
} else {
|
||||
if (config.userControlled) {
|
||||
config.setInterpolator(ANIM_DEPTH, Interpolators.reverse(BLUR_MANUAL));
|
||||
config.setInterpolator(ANIM_WORKSPACE_FADE,
|
||||
Interpolators.reverse(WORKSPACE_FADE_MANUAL));
|
||||
config.setInterpolator(ANIM_WORKSPACE_SCALE,
|
||||
Interpolators.reverse(WORKSPACE_SCALE_MANUAL));
|
||||
config.setInterpolator(ANIM_HOTSEAT_FADE,
|
||||
Interpolators.reverse(HOTSEAT_FADE_MANUAL));
|
||||
config.setInterpolator(ANIM_HOTSEAT_SCALE,
|
||||
Interpolators.reverse(HOTSEAT_SCALE_MANUAL));
|
||||
config.setInterpolator(ANIM_HOTSEAT_TRANSLATE,
|
||||
Interpolators.reverse(HOTSEAT_TRANSLATE_MANUAL));
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.reverse(SCRIM_FADE_MANUAL));
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE,
|
||||
Interpolators.reverse(ALL_APPS_FADE_MANUAL));
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS,
|
||||
Interpolators.reverse(ALL_APPS_VERTICAL_PROGRESS_MANUAL));
|
||||
} else {
|
||||
config.setInterpolator(ANIM_SCRIM_FADE,
|
||||
Interpolators.reverse(ALL_APPS_SCRIM_RESPONDER));
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, ALL_APPS_CLAMPING_RESPONDER);
|
||||
config.setInterpolator(ANIM_WORKSPACE_FADE, INSTANT);
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_ACCELERATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies Animation config values for transition from home to all apps
|
||||
* Applies Animation config values for transition from home to all apps.
|
||||
*/
|
||||
public static void applyNormalToAllAppsAnimConfig(Launcher launcher,
|
||||
StateAnimationConfig config) {
|
||||
public static void applyNormalToAllAppsAnimConfig(
|
||||
Launcher launcher, StateAnimationConfig config) {
|
||||
if (launcher.getDeviceProfile().isTablet) {
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, INSTANT);
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, ALL_APPS_SCRIM_RESPONDER);
|
||||
if (!config.userControlled) {
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_DECELERATE);
|
||||
}
|
||||
} else {
|
||||
config.setInterpolator(ANIM_DEPTH, BLUR);
|
||||
config.setInterpolator(ANIM_WORKSPACE_FADE, WORKSPACE_FADE);
|
||||
config.setInterpolator(ANIM_WORKSPACE_SCALE, WORKSPACE_SCALE);
|
||||
config.setInterpolator(ANIM_HOTSEAT_FADE, HOTSEAT_FADE);
|
||||
config.setInterpolator(ANIM_HOTSEAT_SCALE, HOTSEAT_SCALE);
|
||||
config.setInterpolator(ANIM_HOTSEAT_TRANSLATE, HOTSEAT_TRANSLATE);
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, SCRIM_FADE);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, ALL_APPS_FADE);
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, ALL_APPS_VERTICAL_PROGRESS);
|
||||
config.setInterpolator(ANIM_DEPTH, config.userControlled ? BLUR_MANUAL : BLUR_ATOMIC);
|
||||
config.setInterpolator(ANIM_WORKSPACE_FADE,
|
||||
config.userControlled ? WORKSPACE_FADE_MANUAL : WORKSPACE_FADE_ATOMIC);
|
||||
config.setInterpolator(ANIM_WORKSPACE_SCALE,
|
||||
config.userControlled ? WORKSPACE_SCALE_MANUAL : WORKSPACE_SCALE_ATOMIC);
|
||||
config.setInterpolator(ANIM_HOTSEAT_FADE,
|
||||
config.userControlled ? HOTSEAT_FADE_MANUAL : HOTSEAT_FADE_ATOMIC);
|
||||
config.setInterpolator(ANIM_HOTSEAT_SCALE,
|
||||
config.userControlled ? HOTSEAT_SCALE_MANUAL : HOTSEAT_SCALE_ATOMIC);
|
||||
config.setInterpolator(ANIM_HOTSEAT_TRANSLATE,
|
||||
config.userControlled ? HOTSEAT_TRANSLATE_MANUAL : HOTSEAT_TRANSLATE_ATOMIC);
|
||||
config.setInterpolator(ANIM_SCRIM_FADE,
|
||||
config.userControlled ? SCRIM_FADE_MANUAL : SCRIM_FADE_ATOMIC);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE,
|
||||
config.userControlled ? ALL_APPS_FADE_MANUAL : ALL_APPS_FADE_ATOMIC);
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS,
|
||||
config.userControlled
|
||||
? ALL_APPS_VERTICAL_PROGRESS_MANUAL
|
||||
: ALL_APPS_VERTICAL_PROGRESS_ATOMIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user