blob: 31a7d1827f2f19882fe9a20204ce0cde600d500c [file] [log] [blame]
Sunny Goyal4c7f2152017-10-17 17:17:16 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.launcher3;
17
Sunny Goyal210e1742019-10-17 12:05:38 -070018import static com.android.launcher3.anim.Interpolators.ACCEL_2;
Pat Manningb04dd602022-03-09 14:19:10 +000019import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
Winson Chungf9935182020-10-23 09:26:44 -070020import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
Tony Wickhamc5d168d2021-03-25 09:28:19 -070021import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
vadimtf6ef8792022-07-26 13:54:31 -070022import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL;
23import static com.android.launcher3.testing.shared.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
24import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_ORDINAL;
25import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_TWO_BUTTON_ORDINAL;
26import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
27import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_MODAL_TASK_STATE_ORDINAL;
28import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_SPLIT_SELECT_ORDINAL;
29import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL;
30import static com.android.launcher3.testing.shared.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
31import static com.android.launcher3.testing.shared.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
Sunny Goyal0c723352017-12-12 12:02:29 -080032
Winson Chung8687bc22020-02-27 23:34:24 -080033import android.content.Context;
Zak Cohen4d35ac32021-04-23 16:28:12 -070034import android.graphics.Color;
Sunny Goyal0c723352017-12-12 12:02:29 -080035import android.view.animation.Interpolator;
Sunny Goyalbe93f262017-10-20 17:05:27 -070036
Sunny Goyal35e7d382020-05-08 13:37:58 -070037import com.android.launcher3.statemanager.BaseState;
38import com.android.launcher3.statemanager.StateManager;
Tony Wickham4fdba142019-11-04 16:23:51 -080039import com.android.launcher3.states.HintState;
Sunny Goyalc99cb172017-10-19 16:15:09 -070040import com.android.launcher3.states.SpringLoadedState;
vadimtf6ef8792022-07-26 13:54:31 -070041import com.android.launcher3.testing.shared.TestProtocol;
Tonye06fef42019-03-22 15:44:28 -050042import com.android.launcher3.uioverrides.states.AllAppsState;
43import com.android.launcher3.uioverrides.states.OverviewState;
Sunny Goyal4c7f2152017-10-17 17:17:16 -070044
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -070045import java.util.Arrays;
46
Sunny Goyal4c7f2152017-10-17 17:17:16 -070047/**
Sunny Goyalbe93f262017-10-20 17:05:27 -070048 * Base state for various states used for the Launcher
Sunny Goyal4c7f2152017-10-17 17:17:16 -070049 */
Sunny Goyal35e7d382020-05-08 13:37:58 -070050public abstract class LauncherState implements BaseState<LauncherState> {
Sunny Goyal4c7f2152017-10-17 17:17:16 -070051
Sunny Goyal7185dd62018-03-14 17:51:49 -070052 /**
53 * Set of elements indicating various workspace elements which change visibility across states
54 * Note that workspace is not included here as in that case, we animate individual pages
55 */
56 public static final int NONE = 0;
Tony Wickhambd6f05e2018-03-21 08:16:33 -070057 public static final int HOTSEAT_ICONS = 1 << 0;
Sunny Goyalc373e1c2021-03-09 17:27:53 -080058 public static final int ALL_APPS_CONTENT = 1 << 1;
59 public static final int VERTICAL_SWIPE_INDICATOR = 1 << 2;
60 public static final int OVERVIEW_ACTIONS = 1 << 3;
Tony Wickham7af54402021-12-06 15:54:43 -080061 public static final int CLEAR_ALL_BUTTON = 1 << 4;
62 public static final int WORKSPACE_PAGE_INDICATOR = 1 << 5;
63 public static final int SPLIT_PLACHOLDER_VIEW = 1 << 6;
Zak Cohen43a16152020-02-25 14:29:37 -080064
Sunny Goyal8f965462020-04-23 19:00:36 -070065 // Flag indicating workspace has multiple pages visible.
Sunny Goyal35e7d382020-05-08 13:37:58 -070066 public static final int FLAG_MULTI_PAGE = BaseState.getFlag(0);
Sunny Goyal8f965462020-04-23 19:00:36 -070067 // Flag indicating that workspace and its contents are not accessible
Sunny Goyal35e7d382020-05-08 13:37:58 -070068 public static final int FLAG_WORKSPACE_INACCESSIBLE = BaseState.getFlag(1);
Sunny Goyal8f965462020-04-23 19:00:36 -070069
Sunny Goyal8f965462020-04-23 19:00:36 -070070 // Flag indicating the state allows workspace icons to be dragged.
Sunny Goyal35e7d382020-05-08 13:37:58 -070071 public static final int FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED = BaseState.getFlag(2);
Sunny Goyal8f965462020-04-23 19:00:36 -070072 // Flag to indicate that workspace should draw page background
Sunny Goyal35e7d382020-05-08 13:37:58 -070073 public static final int FLAG_WORKSPACE_HAS_BACKGROUNDS = BaseState.getFlag(3);
Sunny Goyal8f965462020-04-23 19:00:36 -070074 // Flag to indicate if the state would have scrim over sysui region: statu sbar and nav bar
Sunny Goyal1eb11242022-09-09 17:14:45 -070075 public static final int FLAG_HAS_SYS_UI_SCRIM = BaseState.getFlag(4);
Sunny Goyal8f965462020-04-23 19:00:36 -070076 // Flag to inticate that all popups should be closed when this state is enabled.
Sunny Goyal1eb11242022-09-09 17:14:45 -070077 public static final int FLAG_CLOSE_POPUPS = BaseState.getFlag(5);
78 public static final int FLAG_OVERVIEW_UI = BaseState.getFlag(6);
Sunny Goyal8f965462020-04-23 19:00:36 -070079
Anushree Ganjamf6254c52022-04-29 00:46:22 +000080 // Flag indicating that hotseat and its contents are not accessible.
Sunny Goyal1eb11242022-09-09 17:14:45 -070081 public static final int FLAG_HOTSEAT_INACCESSIBLE = BaseState.getFlag(7);
Anushree Ganjamf6254c52022-04-29 00:46:22 +000082
Sunny Goyal6c6c2f42018-03-02 14:57:46 -080083
Sunny Goyalf2393f12020-04-01 20:13:12 -070084 public static final float NO_OFFSET = 0;
85 public static final float NO_SCALE = 1;
86
Sunny Goyal0c723352017-12-12 12:02:29 -080087 protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER =
88 new PageAlphaProvider(ACCEL_2) {
89 @Override
90 public float getPageAlpha(int pageIndex) {
91 return 1;
92 }
93 };
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -070094
Pat Manningb04dd602022-03-09 14:19:10 +000095 protected static final PageTranslationProvider DEFAULT_PAGE_TRANSLATION_PROVIDER =
96 new PageTranslationProvider(DEACCEL_2) {
97 @Override
98 public float getPageTranslation(int pageIndex) {
99 return 0;
100 }
101 };
102
Tony Wickhamc5d168d2021-03-25 09:28:19 -0700103 private static final LauncherState[] sAllStates = new LauncherState[10];
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -0700104
Sunny Goyal75c59ac2018-01-15 14:23:11 -0800105 /**
106 * TODO: Create a separate class for NORMAL state.
107 */
vadimt6895e402019-02-15 16:42:14 -0800108 public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL,
Winson Chungf9935182020-10-23 09:26:44 -0700109 LAUNCHER_STATE_HOME,
Sunny Goyal1eb11242022-09-09 17:14:45 -0700110 FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HAS_SYS_UI_SCRIM) {
Tony Wickhamc7203ad2020-02-03 18:36:06 -0800111 @Override
Alex Chauf39cc122022-04-14 17:51:59 +0100112 public int getTransitionDuration(Context context, boolean isToState) {
Tony Wickhamc7203ad2020-02-03 18:36:06 -0800113 // Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
114 return 0;
115 }
116 };
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -0700117
Sunny Goyal7185dd62018-03-14 17:51:49 -0700118 /**
119 * Various Launcher states arranged in the increasing order of UI layers
120 */
vadimt2a648aa2019-02-14 17:47:11 -0800121 public static final LauncherState SPRING_LOADED = new SpringLoadedState(
122 SPRING_LOADED_STATE_ORDINAL);
vadimt2a648aa2019-02-14 17:47:11 -0800123 public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
Tony Wickham4fdba142019-11-04 16:23:51 -0800124 public static final LauncherState HINT_STATE = new HintState(HINT_STATE_ORDINAL);
Tony Wickhamc5d168d2021-03-25 09:28:19 -0700125 public static final LauncherState HINT_STATE_TWO_BUTTON = new HintState(
126 HINT_STATE_TWO_BUTTON_ORDINAL, LAUNCHER_STATE_OVERVIEW);
Tony1787ee92019-03-20 12:38:35 -0500127
128 public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
Zak Cohena39544d2020-04-27 16:26:55 -0700129 public static final LauncherState OVERVIEW_MODAL_TASK = OverviewState.newModalTaskState(
130 OVERVIEW_MODAL_TASK_STATE_ORDINAL);
Tonye4c2e2b2019-03-25 10:23:39 -0500131 public static final LauncherState QUICK_SWITCH =
132 OverviewState.newSwitchState(QUICK_SWITCH_STATE_ORDINAL);
Tony1787ee92019-03-20 12:38:35 -0500133 public static final LauncherState BACKGROUND_APP =
134 OverviewState.newBackgroundState(BACKGROUND_APP_STATE_ORDINAL);
Vinit Nayakd987a822021-02-22 14:49:27 -0800135 public static final LauncherState OVERVIEW_SPLIT_SELECT =
136 OverviewState.newSplitSelectState(OVERVIEW_SPLIT_SELECT_ORDINAL);
Tony Wickham6becf7c2018-04-19 11:39:34 -0700137
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -0700138 public final int ordinal;
139
Sunny Goyalf9403d92017-10-18 10:55:56 -0700140 /**
Winson Chungf9935182020-10-23 09:26:44 -0700141 * Used for {@link com.android.launcher3.logging.StatsLogManager}
Sunny Goyalf9403d92017-10-18 10:55:56 -0700142 */
Winson Chungf9935182020-10-23 09:26:44 -0700143 public final int statsLogOrdinal;
Sunny Goyal4c7f2152017-10-17 17:17:16 -0700144
Sunny Goyalf9403d92017-10-18 10:55:56 -0700145 /**
Sunny Goyal6c6c2f42018-03-02 14:57:46 -0800146 * True if the state has overview panel visible.
147 */
148 public final boolean overviewUi;
149
Sunny Goyal8f965462020-04-23 19:00:36 -0700150 private final int mFlags;
Sunny Goyal5d1873a2018-05-08 11:10:44 -0700151
Winson Chungf9935182020-10-23 09:26:44 -0700152 public LauncherState(int id, int statsLogOrdinal, int flags) {
153 this.statsLogOrdinal = statsLogOrdinal;
Sunny Goyal8f965462020-04-23 19:00:36 -0700154 this.mFlags = flags;
Sunny Goyal6c6c2f42018-03-02 14:57:46 -0800155 this.overviewUi = (flags & FLAG_OVERVIEW_UI) != 0;
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -0700156 this.ordinal = id;
157 sAllStates[id] = this;
158 }
159
Sunny Goyal8f965462020-04-23 19:00:36 -0700160 /**
161 * Returns if the state has the provided flag
162 */
Sunny Goyal35e7d382020-05-08 13:37:58 -0700163 @Override
Sunny Goyal8f965462020-04-23 19:00:36 -0700164 public final boolean hasFlag(int mask) {
165 return (mFlags & mask) != 0;
166 }
167
Sunny Goyalcd7c0aa2017-10-19 12:36:27 -0700168 public static LauncherState[] values() {
169 return Arrays.copyOf(sAllStates, sAllStates.length);
Sunny Goyal4c7f2152017-10-17 17:17:16 -0700170 }
Sunny Goyalc99cb172017-10-19 16:15:09 -0700171
Tonybc234402019-03-19 13:30:25 -0500172 public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
Sunny Goyalf2393f12020-04-01 20:13:12 -0700173 return new ScaleAndTranslation(NO_SCALE, NO_OFFSET, NO_OFFSET);
Sunny Goyalc99cb172017-10-19 16:15:09 -0700174 }
175
Tonybc234402019-03-19 13:30:25 -0500176 public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) {
Tony Wickham57e489c2019-03-04 14:57:07 -0800177 // For most states, treat the hotseat as if it were part of the workspace.
178 return getWorkspaceScaleAndTranslation(launcher);
Tony4bb4b892019-03-03 15:32:12 -0800179 }
180
Sunny Goyalf2393f12020-04-01 20:13:12 -0700181 /**
Tony Wickham82d5a062021-05-14 14:37:12 -0700182 * Returns an array of two elements.
Samuel Fufa2ea01e42020-12-02 13:48:18 -0600183 * The first specifies the scale for the overview
184 * The second is the factor ([0, 1], 0 => center-screen; 1 => offscreen) by which overview
185 * should be shifted horizontally.
Sunny Goyalf2393f12020-04-01 20:13:12 -0700186 */
187 public float[] getOverviewScaleAndOffset(Launcher launcher) {
188 return launcher.getNormalOverviewScaleAndOffset();
Tony3bb5e8e2018-03-14 12:05:00 +0000189 }
190
Tony54068172019-05-12 13:24:51 -0500191 public float getOverviewFullscreenProgress() {
192 return 0;
193 }
194
Sunny Goyal7185dd62018-03-14 17:51:49 -0700195 public int getVisibleElements(Launcher launcher) {
Tony Wickham7af54402021-12-06 15:54:43 -0800196 return HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR;
Sunny Goyal7185dd62018-03-14 17:51:49 -0700197 }
198
Sunny Goyal228153d2018-01-04 15:35:22 -0800199 /**
Tony Wickhama29a0462021-03-02 12:28:25 -0800200 * A shorthand for checking getVisibleElements() & elements == elements.
201 * @return Whether all of the given elements are visible.
202 */
203 public boolean areElementsVisible(Launcher launcher, int elements) {
204 return (getVisibleElements(launcher) & elements) == elements;
205 }
206
Schneider Victor-tulias3f6c4732022-06-23 11:25:10 -0700207 /**
208 * Returns whether taskbar is stashed and thus should either:
209 * 1) replace hotseat or taskbar icons with a handle in gesture navigation mode or
210 * 2) fade out the hotseat or taskbar icons in 3-button navigation mode.
211 */
Tony Wickham24675d32021-11-24 15:43:52 -0800212 public boolean isTaskbarStashed(Launcher launcher) {
Tracy Zhou308851d2021-09-09 21:18:25 -0700213 return false;
214 }
215
Tony Wickham24675d32021-11-24 15:43:52 -0800216 /** Returns whether taskbar is aligned with the hotseat vs position inside apps */
217 public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
Schneider Victor-tulias3f6c4732022-06-23 11:25:10 -0700218 return true;
Tony Wickham24675d32021-11-24 15:43:52 -0800219 }
220
Tony Wickhama29a0462021-03-02 12:28:25 -0800221 /**
Sunny Goyal228153d2018-01-04 15:35:22 -0800222 * Fraction shift in the vertical translation UI and related properties
223 *
224 * @see com.android.launcher3.allapps.AllAppsTransitionController
225 */
226 public float getVerticalProgress(Launcher launcher) {
227 return 1f;
228 }
229
Sunny Goyalc82916f2021-04-06 13:03:54 -0700230 public float getWorkspaceBackgroundAlpha(Launcher launcher) {
Sunny Goyal927447e2018-05-04 13:19:29 -0700231 return 0;
232 }
233
Zak Cohen4d35ac32021-04-23 16:28:12 -0700234 /**
235 * What color should the workspace scrim be in when at rest in this state.
236 * Return {@link Color#TRANSPARENT} for no scrim.
237 */
238 public int getWorkspaceScrimColor(Launcher launcher) {
239 return Color.TRANSPARENT;
Tony Wickhamc0880512019-07-24 17:32:08 -0700240 }
241
Winson Chung8687bc22020-02-27 23:34:24 -0800242 /**
Zak Cohena39544d2020-04-27 16:26:55 -0700243 * For this state, how modal should over view been shown. 0 modalness means all tasks drawn,
244 * 1 modalness means the current task is show on its own.
245 */
246 public float getOverviewModalness() {
247 return 0;
248 }
249
250 /**
Vinit Nayakf4f0c4d2021-05-05 10:28:05 -0700251 * For this state, how much additional translation there should be for each of the
252 * child TaskViews. Note that the translation can be its primary or secondary dimension.
Vinit Nayakd987a822021-02-22 14:49:27 -0800253 */
Vinit Nayakf4f0c4d2021-05-05 10:28:05 -0700254 public float getSplitSelectTranslation(Launcher launcher) {
Vinit Nayakd987a822021-02-22 14:49:27 -0800255 return 0;
256 }
257
258 /**
Lucas Dupin4918ed32020-03-17 17:11:32 -0700259 * The amount of blur and wallpaper zoom to apply to the background of either the app
260 * or Launcher surface in this state. Should be a number between 0 and 1, inclusive.
261 *
262 * 0 means completely zoomed in, without blurs. 1 is zoomed out, with blurs.
Winson Chung8687bc22020-02-27 23:34:24 -0800263 */
Alex Chau31935222022-09-01 21:24:52 +0100264 public final <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
265 float getDepth(DEVICE_PROFILE_CONTEXT context) {
Jon Miranda36d10152020-06-19 16:35:08 -0700266 return getDepth(context,
267 BaseDraggingActivity.fromContext(context).getDeviceProfile().isMultiWindowMode);
268 }
269
270 /**
271 * Returns the amount of blur and wallpaper zoom for this state with {@param isMultiWindowMode}.
Samuel Fufa2ea01e42020-12-02 13:48:18 -0600272 *
Jon Miranda36d10152020-06-19 16:35:08 -0700273 * @see #getDepth(Context).
274 */
Alex Chau31935222022-09-01 21:24:52 +0100275 public final <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
276 float getDepth(DEVICE_PROFILE_CONTEXT context, boolean isMultiWindowMode) {
Jon Miranda36d10152020-06-19 16:35:08 -0700277 if (isMultiWindowMode) {
Winson Chungb330d6e2020-04-20 11:57:11 -0700278 return 0;
279 }
280 return getDepthUnchecked(context);
281 }
282
Alex Chau31935222022-09-01 21:24:52 +0100283 protected <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
284 float getDepthUnchecked(DEVICE_PROFILE_CONTEXT context) {
Lucas Dupin4918ed32020-03-17 17:11:32 -0700285 return 0f;
Winson Chung8687bc22020-02-27 23:34:24 -0800286 }
287
Sunny Goyal3e3f44c2017-10-23 17:14:52 -0700288 public String getDescription(Launcher launcher) {
289 return launcher.getWorkspace().getCurrentPageDescription();
290 }
291
Sunny Goyalbc683e92017-12-06 10:25:07 -0800292 public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
Jon Mirandae3832222020-07-06 15:38:38 -0700293 if ((this != NORMAL && this != HINT_STATE)
294 || !launcher.getDeviceProfile().shouldFadeAdjacentWorkspaceScreens()) {
Sunny Goyalbc683e92017-12-06 10:25:07 -0800295 return DEFAULT_ALPHA_PROVIDER;
296 }
Sunny Goyal228153d2018-01-04 15:35:22 -0800297 final int centerPage = launcher.getWorkspace().getNextPage();
Sunny Goyal0c723352017-12-12 12:02:29 -0800298 return new PageAlphaProvider(ACCEL_2) {
299 @Override
300 public float getPageAlpha(int pageIndex) {
Samuel Fufa2ea01e42020-12-02 13:48:18 -0600301 return pageIndex != centerPage ? 0 : 1f;
Sunny Goyal0c723352017-12-12 12:02:29 -0800302 }
303 };
Sunny Goyalbc683e92017-12-06 10:25:07 -0800304 }
305
Pat Manningb04dd602022-03-09 14:19:10 +0000306 /**
307 * Gets the translation provider for workspace pages.
308 */
309 public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) {
310 if (this != SPRING_LOADED || !launcher.getDeviceProfile().isTwoPanels) {
311 return DEFAULT_PAGE_TRANSLATION_PROVIDER;
312 }
313 final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f;
314 return new PageTranslationProvider(DEACCEL_2) {
315 @Override
316 public float getPageTranslation(int pageIndex) {
317 boolean isRtl = launcher.getWorkspace().mIsRtl;
318 boolean isFirstPage = pageIndex % 2 == 0;
319 return ((isFirstPage && !isRtl) || (!isFirstPage && isRtl)) ? -quarterPageSpacing
320 : quarterPageSpacing;
321 }
322 };
323 }
324
Sunny Goyal35e7d382020-05-08 13:37:58 -0700325 @Override
Sunny Goyal49bcf342018-01-11 13:59:53 -0800326 public LauncherState getHistoryForState(LauncherState previousState) {
327 // No history is supported
328 return NORMAL;
329 }
330
Sunny Goyal35e7d382020-05-08 13:37:58 -0700331 @Override
332 public String toString() {
Tony Wickhamf844ee92020-05-27 15:41:32 -0500333 return TestProtocol.stateOrdinalToString(ordinal);
Sunny Goyal35e7d382020-05-08 13:37:58 -0700334 }
335
Sunny Goyale39690b2018-08-02 13:35:07 -0700336 public void onBackPressed(Launcher launcher) {
337 if (this != NORMAL) {
Sunny Goyal35e7d382020-05-08 13:37:58 -0700338 StateManager<LauncherState> lsm = launcher.getStateManager();
Sunny Goyale39690b2018-08-02 13:35:07 -0700339 LauncherState lastState = lsm.getLastState();
Sunny Goyale39690b2018-08-02 13:35:07 -0700340 lsm.goToState(lastState);
341 }
342 }
343
Sunny Goyal0c723352017-12-12 12:02:29 -0800344 public static abstract class PageAlphaProvider {
Sunny Goyalbc683e92017-12-06 10:25:07 -0800345
Sunny Goyal0c723352017-12-12 12:02:29 -0800346 public final Interpolator interpolator;
347
348 public PageAlphaProvider(Interpolator interpolator) {
349 this.interpolator = interpolator;
350 }
351
352 public abstract float getPageAlpha(int pageIndex);
Sunny Goyalbc683e92017-12-06 10:25:07 -0800353 }
Tonybc234402019-03-19 13:30:25 -0500354
Pat Manningb04dd602022-03-09 14:19:10 +0000355 /**
356 * Provider for the translation and animation interpolation of workspace pages.
357 */
358 public abstract static class PageTranslationProvider {
359
360 public final Interpolator interpolator;
361
362 public PageTranslationProvider(Interpolator interpolator) {
363 this.interpolator = interpolator;
364 }
365
366 /**
367 * Gets the translation of the workspace page at the provided page index.
368 */
369 public abstract float getPageTranslation(int pageIndex);
370 }
371
Tonybc234402019-03-19 13:30:25 -0500372 public static class ScaleAndTranslation {
373 public float scale;
374 public float translationX;
375 public float translationY;
376
377 public ScaleAndTranslation(float scale, float translationX, float translationY) {
378 this.scale = scale;
379 this.translationX = translationX;
380 this.translationY = translationY;
381 }
382 }
Sunny Goyal4c7f2152017-10-17 17:17:16 -0700383}