Loading src/com/android/launcher3/LauncherState.java +45 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; 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.testing.TestProtocol.ALL_APPS_STATE_ORDINAL; Loading Loading @@ -91,6 +92,14 @@ public abstract class LauncherState implements BaseState<LauncherState> { } }; protected static final PageTranslationProvider DEFAULT_PAGE_TRANSLATION_PROVIDER = new PageTranslationProvider(DEACCEL_2) { @Override public float getPageTranslation(int pageIndex) { return 0; } }; private static final LauncherState[] sAllStates = new LauncherState[10]; /** Loading Loading @@ -288,6 +297,25 @@ public abstract class LauncherState implements BaseState<LauncherState> { }; } /** * Gets the translation provider for workspace pages. */ public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) { if (this != SPRING_LOADED || !launcher.getDeviceProfile().isTwoPanels) { return DEFAULT_PAGE_TRANSLATION_PROVIDER; } final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f; return new PageTranslationProvider(DEACCEL_2) { @Override public float getPageTranslation(int pageIndex) { boolean isRtl = launcher.getWorkspace().mIsRtl; boolean isFirstPage = pageIndex % 2 == 0; return ((isFirstPage && !isRtl) || (!isFirstPage && isRtl)) ? -quarterPageSpacing : quarterPageSpacing; } }; } @Override public LauncherState getHistoryForState(LauncherState previousState) { // No history is supported Loading Loading @@ -318,6 +346,23 @@ public abstract class LauncherState implements BaseState<LauncherState> { public abstract float getPageAlpha(int pageIndex); } /** * Provider for the translation and animation interpolation of workspace pages. */ public abstract static class PageTranslationProvider { public final Interpolator interpolator; public PageTranslationProvider(Interpolator interpolator) { this.interpolator = interpolator; } /** * Gets the translation of the workspace page at the provided page index. */ public abstract float getPageTranslation(int pageIndex); } public static class ScaleAndTranslation { public float scale; public float translationX; Loading src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +18 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCA import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_PAGE_TRANSLATE_X; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE; import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM; Loading @@ -49,6 +50,7 @@ import android.view.View; import android.view.animation.Interpolator; import com.android.launcher3.LauncherState.PageAlphaProvider; import com.android.launcher3.LauncherState.PageTranslationProvider; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PropertySetter; Loading Loading @@ -155,6 +157,12 @@ public class WorkspaceStateTransitionAnimation { scaleAndTranslation.translationX, translationInterpolator); propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator); PageTranslationProvider pageTranslationProvider = state.getWorkspacePageTranslationProvider( mLauncher); for (int i = 0; i < childCount; i++) { applyPageTranslation((CellLayout) mWorkspace.getChildAt(i), i, pageTranslationProvider, propertySetter, config); } Interpolator hotseatTranslationInterpolator = config.getInterpolator( ANIM_HOTSEAT_TRANSLATE, translationInterpolator); Loading Loading @@ -202,6 +210,16 @@ public class WorkspaceStateTransitionAnimation { pageAlpha, fadeInterpolator); } private void applyPageTranslation(CellLayout cellLayout, int childIndex, PageTranslationProvider pageTranslationProvider, PropertySetter propertySetter, StateAnimationConfig config) { float pageTranslation = pageTranslationProvider.getPageTranslation(childIndex); Interpolator translationInterpolator = config.getInterpolator( ANIM_WORKSPACE_PAGE_TRANSLATE_X, pageTranslationProvider.interpolator); propertySetter.setFloat(cellLayout, VIEW_TRANSLATE_X, pageTranslation, translationInterpolator); } /** * Returns a spring based animator for the scale property of {@param workspace}. */ Loading src/com/android/launcher3/states/StateAnimationConfig.java +3 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class StateAnimationConfig { ANIM_OVERVIEW_MODAL, ANIM_DEPTH, ANIM_OVERVIEW_ACTIONS_FADE, ANIM_WORKSPACE_PAGE_TRANSLATE_X, }) @Retention(RetentionPolicy.SOURCE) public @interface AnimType {} Loading @@ -80,8 +81,9 @@ public class StateAnimationConfig { public static final int ANIM_OVERVIEW_MODAL = 12; public static final int ANIM_DEPTH = 13; public static final int ANIM_OVERVIEW_ACTIONS_FADE = 14; public static final int ANIM_WORKSPACE_PAGE_TRANSLATE_X = 15; private static final int ANIM_TYPES_COUNT = 15; private static final int ANIM_TYPES_COUNT = 16; protected final Interpolator[] mInterpolators = new Interpolator[ANIM_TYPES_COUNT]; Loading Loading
src/com/android/launcher3/LauncherState.java +45 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; 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.testing.TestProtocol.ALL_APPS_STATE_ORDINAL; Loading Loading @@ -91,6 +92,14 @@ public abstract class LauncherState implements BaseState<LauncherState> { } }; protected static final PageTranslationProvider DEFAULT_PAGE_TRANSLATION_PROVIDER = new PageTranslationProvider(DEACCEL_2) { @Override public float getPageTranslation(int pageIndex) { return 0; } }; private static final LauncherState[] sAllStates = new LauncherState[10]; /** Loading Loading @@ -288,6 +297,25 @@ public abstract class LauncherState implements BaseState<LauncherState> { }; } /** * Gets the translation provider for workspace pages. */ public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) { if (this != SPRING_LOADED || !launcher.getDeviceProfile().isTwoPanels) { return DEFAULT_PAGE_TRANSLATION_PROVIDER; } final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f; return new PageTranslationProvider(DEACCEL_2) { @Override public float getPageTranslation(int pageIndex) { boolean isRtl = launcher.getWorkspace().mIsRtl; boolean isFirstPage = pageIndex % 2 == 0; return ((isFirstPage && !isRtl) || (!isFirstPage && isRtl)) ? -quarterPageSpacing : quarterPageSpacing; } }; } @Override public LauncherState getHistoryForState(LauncherState previousState) { // No history is supported Loading Loading @@ -318,6 +346,23 @@ public abstract class LauncherState implements BaseState<LauncherState> { public abstract float getPageAlpha(int pageIndex); } /** * Provider for the translation and animation interpolation of workspace pages. */ public abstract static class PageTranslationProvider { public final Interpolator interpolator; public PageTranslationProvider(Interpolator interpolator) { this.interpolator = interpolator; } /** * Gets the translation of the workspace page at the provided page index. */ public abstract float getPageTranslation(int pageIndex); } public static class ScaleAndTranslation { public float scale; public float translationX; Loading
src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +18 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCA import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_PAGE_TRANSLATE_X; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE; import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM; Loading @@ -49,6 +50,7 @@ import android.view.View; import android.view.animation.Interpolator; import com.android.launcher3.LauncherState.PageAlphaProvider; import com.android.launcher3.LauncherState.PageTranslationProvider; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PropertySetter; Loading Loading @@ -155,6 +157,12 @@ public class WorkspaceStateTransitionAnimation { scaleAndTranslation.translationX, translationInterpolator); propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator); PageTranslationProvider pageTranslationProvider = state.getWorkspacePageTranslationProvider( mLauncher); for (int i = 0; i < childCount; i++) { applyPageTranslation((CellLayout) mWorkspace.getChildAt(i), i, pageTranslationProvider, propertySetter, config); } Interpolator hotseatTranslationInterpolator = config.getInterpolator( ANIM_HOTSEAT_TRANSLATE, translationInterpolator); Loading Loading @@ -202,6 +210,16 @@ public class WorkspaceStateTransitionAnimation { pageAlpha, fadeInterpolator); } private void applyPageTranslation(CellLayout cellLayout, int childIndex, PageTranslationProvider pageTranslationProvider, PropertySetter propertySetter, StateAnimationConfig config) { float pageTranslation = pageTranslationProvider.getPageTranslation(childIndex); Interpolator translationInterpolator = config.getInterpolator( ANIM_WORKSPACE_PAGE_TRANSLATE_X, pageTranslationProvider.interpolator); propertySetter.setFloat(cellLayout, VIEW_TRANSLATE_X, pageTranslation, translationInterpolator); } /** * Returns a spring based animator for the scale property of {@param workspace}. */ Loading
src/com/android/launcher3/states/StateAnimationConfig.java +3 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class StateAnimationConfig { ANIM_OVERVIEW_MODAL, ANIM_DEPTH, ANIM_OVERVIEW_ACTIONS_FADE, ANIM_WORKSPACE_PAGE_TRANSLATE_X, }) @Retention(RetentionPolicy.SOURCE) public @interface AnimType {} Loading @@ -80,8 +81,9 @@ public class StateAnimationConfig { public static final int ANIM_OVERVIEW_MODAL = 12; public static final int ANIM_DEPTH = 13; public static final int ANIM_OVERVIEW_ACTIONS_FADE = 14; public static final int ANIM_WORKSPACE_PAGE_TRANSLATE_X = 15; private static final int ANIM_TYPES_COUNT = 15; private static final int ANIM_TYPES_COUNT = 16; protected final Interpolator[] mInterpolators = new Interpolator[ANIM_TYPES_COUNT]; Loading