Make LauncherState transitionDuration overridable at runtime
This follows the pattern of most of the other state properties, and
allows us, for example, to extend the overview transition in 0-button
mode, but keep it shorter for other modes that don't travel as far.
Bug: 143361609
Change-Id: Ibf8142bf3f57bb73be826adb6f4a32c136ff56dc
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 8b80cba..7e06099 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -56,7 +56,7 @@
/**
* Base state for various states used for the Launcher
*/
-public class LauncherState {
+public abstract class LauncherState {
/**
@@ -97,9 +97,15 @@
* TODO: Create a separate class for NORMAL state.
*/
public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL,
- ContainerType.WORKSPACE, 0,
+ ContainerType.WORKSPACE,
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
- FLAG_HAS_SYS_UI_SCRIM);
+ FLAG_HAS_SYS_UI_SCRIM) {
+ @Override
+ public int getTransitionDuration(Launcher launcher) {
+ // Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
+ return 0;
+ }
+ };
/**
* Various Launcher states arranged in the increasing order of UI layers
@@ -147,8 +153,6 @@
*/
public final boolean hasWorkspacePageBackground;
- public final int transitionDuration;
-
/**
* True if the state allows workspace icons to be dragged.
*/
@@ -178,9 +182,8 @@
public final boolean hasSysUiScrim;
- public LauncherState(int id, int containerType, int transitionDuration, int flags) {
+ public LauncherState(int id, int containerType, int flags) {
this.containerType = containerType;
- this.transitionDuration = transitionDuration;
this.hasWorkspacePageBackground = (flags & FLAG_PAGE_BACKGROUNDS) != 0;
this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
@@ -203,6 +206,12 @@
return Arrays.copyOf(sAllStates, sAllStates.length);
}
+ /**
+ * @return How long the animation to this state should take (or from this state to NORMAL).
+ * @param launcher
+ */
+ public abstract int getTransitionDuration(Launcher launcher);
+
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
return new ScaleAndTranslation(1, 0, 0);
}