Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.launcher3; |
| 17 | |
| 18 | import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; |
| 19 | import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 20 | import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; |
vadimt | 2a648aa | 2019-02-14 17:47:11 -0800 | [diff] [blame] | 21 | import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL; |
| 22 | import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL; |
vadimt | 6895e40 | 2019-02-15 16:42:14 -0800 | [diff] [blame] | 23 | import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL; |
Tony | 1787ee9 | 2019-03-20 12:38:35 -0500 | [diff] [blame] | 24 | import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL; |
vadimt | 2a648aa | 2019-02-14 17:47:11 -0800 | [diff] [blame] | 25 | import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL; |
Tony | e4c2e2b | 2019-03-25 10:23:39 -0500 | [diff] [blame] | 26 | import static com.android.launcher3.TestProtocol.QUICK_SWITCH_STATE_ORDINAL; |
vadimt | 2a648aa | 2019-02-14 17:47:11 -0800 | [diff] [blame] | 27 | import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL; |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 28 | import static com.android.launcher3.anim.Interpolators.ACCEL_2; |
Sunny Goyal | 623eddd | 2018-03-02 12:24:41 -0800 | [diff] [blame] | 29 | import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 30 | |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 31 | import android.view.animation.Interpolator; |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 32 | |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 33 | import com.android.launcher3.states.SpringLoadedState; |
Tony | e4c2e2b | 2019-03-25 10:23:39 -0500 | [diff] [blame] | 34 | import com.android.launcher3.uioverrides.UiFactory; |
Tony | e06fef4 | 2019-03-22 15:44:28 -0500 | [diff] [blame] | 35 | import com.android.launcher3.uioverrides.states.AllAppsState; |
| 36 | import com.android.launcher3.uioverrides.states.OverviewState; |
Sunny Goyal | e39690b | 2018-08-02 13:35:07 -0700 | [diff] [blame] | 37 | import com.android.launcher3.userevent.nano.LauncherLogProto.Action; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 38 | import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; |
| 39 | |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 40 | import java.util.Arrays; |
| 41 | |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 44 | * Base state for various states used for the Launcher |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 45 | */ |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 46 | public class LauncherState { |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 47 | |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Set of elements indicating various workspace elements which change visibility across states |
| 51 | * Note that workspace is not included here as in that case, we animate individual pages |
| 52 | */ |
| 53 | public static final int NONE = 0; |
Tony Wickham | bd6f05e | 2018-03-21 08:16:33 -0700 | [diff] [blame] | 54 | public static final int HOTSEAT_ICONS = 1 << 0; |
Sunny Goyal | 81b4c7b | 2018-03-26 12:10:31 -0700 | [diff] [blame] | 55 | public static final int HOTSEAT_SEARCH_BOX = 1 << 1; |
Tony Wickham | bd6f05e | 2018-03-21 08:16:33 -0700 | [diff] [blame] | 56 | public static final int ALL_APPS_HEADER = 1 << 2; |
| 57 | public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions |
| 58 | public static final int ALL_APPS_CONTENT = 1 << 4; |
Sunny Goyal | 56e1019 | 2018-05-22 13:22:25 -0700 | [diff] [blame] | 59 | public static final int VERTICAL_SWIPE_INDICATOR = 1 << 5; |
Tony Wickham | 66d1c2f | 2019-04-24 11:32:59 -0700 | [diff] [blame] | 60 | public static final int RECENTS_CLEAR_ALL_BUTTON = 1 << 6; |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 61 | |
Sunny Goyal | 927447e | 2018-05-04 13:19:29 -0700 | [diff] [blame] | 62 | protected static final int FLAG_MULTI_PAGE = 1 << 0; |
| 63 | protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 1; |
| 64 | protected static final int FLAG_DISABLE_RESTORE = 1 << 2; |
| 65 | protected static final int FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED = 1 << 3; |
| 66 | protected static final int FLAG_DISABLE_PAGE_CLIPPING = 1 << 4; |
| 67 | protected static final int FLAG_PAGE_BACKGROUNDS = 1 << 5; |
| 68 | protected static final int FLAG_DISABLE_INTERACTION = 1 << 6; |
| 69 | protected static final int FLAG_OVERVIEW_UI = 1 << 7; |
| 70 | protected static final int FLAG_HIDE_BACK_BUTTON = 1 << 8; |
Sunny Goyal | 5d1873a | 2018-05-08 11:10:44 -0700 | [diff] [blame] | 71 | protected static final int FLAG_HAS_SYS_UI_SCRIM = 1 << 9; |
Sunny Goyal | 6c6c2f4 | 2018-03-02 14:57:46 -0800 | [diff] [blame] | 72 | |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 73 | protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER = |
| 74 | new PageAlphaProvider(ACCEL_2) { |
| 75 | @Override |
| 76 | public float getPageAlpha(int pageIndex) { |
| 77 | return 1; |
| 78 | } |
| 79 | }; |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 80 | |
Tony | e4c2e2b | 2019-03-25 10:23:39 -0500 | [diff] [blame] | 81 | private static final LauncherState[] sAllStates = new LauncherState[7]; |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 82 | |
Sunny Goyal | 75c59ac | 2018-01-15 14:23:11 -0800 | [diff] [blame] | 83 | /** |
| 84 | * TODO: Create a separate class for NORMAL state. |
| 85 | */ |
vadimt | 6895e40 | 2019-02-15 16:42:14 -0800 | [diff] [blame] | 86 | public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL, |
| 87 | ContainerType.WORKSPACE, 0, |
Sunny Goyal | 5d1873a | 2018-05-08 11:10:44 -0700 | [diff] [blame] | 88 | FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON | |
| 89 | FLAG_HAS_SYS_UI_SCRIM); |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 90 | |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 91 | /** |
| 92 | * Various Launcher states arranged in the increasing order of UI layers |
| 93 | */ |
vadimt | 2a648aa | 2019-02-14 17:47:11 -0800 | [diff] [blame] | 94 | public static final LauncherState SPRING_LOADED = new SpringLoadedState( |
| 95 | SPRING_LOADED_STATE_ORDINAL); |
vadimt | 2a648aa | 2019-02-14 17:47:11 -0800 | [diff] [blame] | 96 | public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL); |
Tony | 1787ee9 | 2019-03-20 12:38:35 -0500 | [diff] [blame] | 97 | |
| 98 | public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL); |
| 99 | public static final LauncherState OVERVIEW_PEEK = |
| 100 | OverviewState.newPeekState(OVERVIEW_PEEK_STATE_ORDINAL); |
Tony | e4c2e2b | 2019-03-25 10:23:39 -0500 | [diff] [blame] | 101 | public static final LauncherState QUICK_SWITCH = |
| 102 | OverviewState.newSwitchState(QUICK_SWITCH_STATE_ORDINAL); |
Tony | 1787ee9 | 2019-03-20 12:38:35 -0500 | [diff] [blame] | 103 | public static final LauncherState BACKGROUND_APP = |
| 104 | OverviewState.newBackgroundState(BACKGROUND_APP_STATE_ORDINAL); |
Tony Wickham | 6becf7c | 2018-04-19 11:39:34 -0700 | [diff] [blame] | 105 | |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 106 | public final int ordinal; |
| 107 | |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher} |
| 110 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 111 | public final int containerType; |
| 112 | |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame] | 113 | /** |
| 114 | * True if the state can be persisted across activity restarts. |
| 115 | */ |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 116 | public final boolean disableRestore; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * True if workspace has multiple pages visible. |
| 120 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 121 | public final boolean hasMultipleVisiblePages; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Accessibility flag for workspace and its pages. |
| 125 | * @see android.view.View#setImportantForAccessibility(int) |
| 126 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 127 | public final int workspaceAccessibilityFlag; |
| 128 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 129 | /** |
| 130 | * Properties related to state transition animation |
| 131 | * |
| 132 | * @see WorkspaceStateTransitionAnimation |
| 133 | */ |
Sunny Goyal | 6639a5d | 2018-02-28 15:09:36 -0800 | [diff] [blame] | 134 | public final boolean hasWorkspacePageBackground; |
Sunny Goyal | 6639a5d | 2018-02-28 15:09:36 -0800 | [diff] [blame] | 135 | |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 136 | public final int transitionDuration; |
| 137 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 138 | /** |
Tony Wickham | 5337067 | 2017-12-05 10:10:55 -0800 | [diff] [blame] | 139 | * True if the state allows workspace icons to be dragged. |
| 140 | */ |
| 141 | public final boolean workspaceIconsCanBeDragged; |
| 142 | |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 143 | /** |
| 144 | * True if the workspace pages should not be clipped relative to the workspace bounds |
| 145 | * for this state. |
| 146 | */ |
| 147 | public final boolean disablePageClipping; |
| 148 | |
Sunny Goyal | 6c6c2f4 | 2018-03-02 14:57:46 -0800 | [diff] [blame] | 149 | /** |
| 150 | * True if launcher can not be directly interacted in this state; |
| 151 | */ |
| 152 | public final boolean disableInteraction; |
| 153 | |
| 154 | /** |
| 155 | * True if the state has overview panel visible. |
| 156 | */ |
| 157 | public final boolean overviewUi; |
| 158 | |
Tony Wickham | 76cf236 | 2018-03-20 14:13:16 -0700 | [diff] [blame] | 159 | /** |
| 160 | * True if the back button should be hidden when in this state (assuming no floating views are |
| 161 | * open, launcher has window focus, etc). |
| 162 | */ |
| 163 | public final boolean hideBackButton; |
| 164 | |
Sunny Goyal | 5d1873a | 2018-05-08 11:10:44 -0700 | [diff] [blame] | 165 | public final boolean hasSysUiScrim; |
| 166 | |
Sunny Goyal | 228153d | 2018-01-04 15:35:22 -0800 | [diff] [blame] | 167 | public LauncherState(int id, int containerType, int transitionDuration, int flags) { |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 168 | this.containerType = containerType; |
| 169 | this.transitionDuration = transitionDuration; |
| 170 | |
Sunny Goyal | 6639a5d | 2018-02-28 15:09:36 -0800 | [diff] [blame] | 171 | this.hasWorkspacePageBackground = (flags & FLAG_PAGE_BACKGROUNDS) != 0; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 172 | this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 173 | this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0 |
| 174 | ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 175 | : IMPORTANT_FOR_ACCESSIBILITY_AUTO; |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 176 | this.disableRestore = (flags & FLAG_DISABLE_RESTORE) != 0; |
Tony Wickham | 5337067 | 2017-12-05 10:10:55 -0800 | [diff] [blame] | 177 | this.workspaceIconsCanBeDragged = (flags & FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED) != 0; |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 178 | this.disablePageClipping = (flags & FLAG_DISABLE_PAGE_CLIPPING) != 0; |
Sunny Goyal | 6c6c2f4 | 2018-03-02 14:57:46 -0800 | [diff] [blame] | 179 | this.disableInteraction = (flags & FLAG_DISABLE_INTERACTION) != 0; |
| 180 | this.overviewUi = (flags & FLAG_OVERVIEW_UI) != 0; |
Tony Wickham | 76cf236 | 2018-03-20 14:13:16 -0700 | [diff] [blame] | 181 | this.hideBackButton = (flags & FLAG_HIDE_BACK_BUTTON) != 0; |
Sunny Goyal | 5d1873a | 2018-05-08 11:10:44 -0700 | [diff] [blame] | 182 | this.hasSysUiScrim = (flags & FLAG_HAS_SYS_UI_SCRIM) != 0; |
Sunny Goyal | cd7c0aa | 2017-10-19 12:36:27 -0700 | [diff] [blame] | 183 | |
| 184 | this.ordinal = id; |
| 185 | sAllStates[id] = this; |
| 186 | } |
| 187 | |
| 188 | public static LauncherState[] values() { |
| 189 | return Arrays.copyOf(sAllStates, sAllStates.length); |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 190 | } |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 191 | |
Tony | bc23440 | 2019-03-19 13:30:25 -0500 | [diff] [blame] | 192 | public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { |
| 193 | return new ScaleAndTranslation(1, 0, 0); |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Tony | bc23440 | 2019-03-19 13:30:25 -0500 | [diff] [blame] | 196 | public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { |
Tony Wickham | 57e489c | 2019-03-04 14:57:07 -0800 | [diff] [blame] | 197 | // For most states, treat the hotseat as if it were part of the workspace. |
| 198 | return getWorkspaceScaleAndTranslation(launcher); |
Tony | 4bb4b89 | 2019-03-03 15:32:12 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Tony | bc23440 | 2019-03-19 13:30:25 -0500 | [diff] [blame] | 201 | public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { |
Sunny Goyal | 9e84e0c | 2019-04-03 16:44:32 -0700 | [diff] [blame] | 202 | return UiFactory.getOverviewScaleAndTranslationForNormalState(launcher); |
Tony | 3bb5e8e | 2018-03-14 12:05:00 +0000 | [diff] [blame] | 203 | } |
| 204 | |
Tony | 5406817 | 2019-05-12 13:24:51 -0500 | [diff] [blame^] | 205 | public float getOverviewFullscreenProgress() { |
| 206 | return 0; |
| 207 | } |
| 208 | |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 209 | public void onStateEnabled(Launcher launcher) { |
| 210 | dispatchWindowStateChanged(launcher); |
| 211 | } |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 212 | |
| 213 | public void onStateDisabled(Launcher launcher) { } |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 214 | |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 215 | public int getVisibleElements(Launcher launcher) { |
Tony Wickham | bd6f05e | 2018-03-21 08:16:33 -0700 | [diff] [blame] | 216 | if (launcher.getDeviceProfile().isVerticalBarLayout()) { |
Sunny Goyal | 56e1019 | 2018-05-22 13:22:25 -0700 | [diff] [blame] | 217 | return HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; |
Tony Wickham | bd6f05e | 2018-03-21 08:16:33 -0700 | [diff] [blame] | 218 | } |
Sunny Goyal | 56e1019 | 2018-05-22 13:22:25 -0700 | [diff] [blame] | 219 | return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR; |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Sunny Goyal | 228153d | 2018-01-04 15:35:22 -0800 | [diff] [blame] | 222 | /** |
| 223 | * Fraction shift in the vertical translation UI and related properties |
| 224 | * |
| 225 | * @see com.android.launcher3.allapps.AllAppsTransitionController |
| 226 | */ |
| 227 | public float getVerticalProgress(Launcher launcher) { |
| 228 | return 1f; |
| 229 | } |
| 230 | |
Sunny Goyal | 927447e | 2018-05-04 13:19:29 -0700 | [diff] [blame] | 231 | public float getWorkspaceScrimAlpha(Launcher launcher) { |
| 232 | return 0; |
| 233 | } |
| 234 | |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 235 | public String getDescription(Launcher launcher) { |
| 236 | return launcher.getWorkspace().getCurrentPageDescription(); |
| 237 | } |
| 238 | |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 239 | public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { |
| 240 | if (this != NORMAL || !launcher.getDeviceProfile().shouldFadeAdjacentWorkspaceScreens()) { |
| 241 | return DEFAULT_ALPHA_PROVIDER; |
| 242 | } |
Sunny Goyal | 228153d | 2018-01-04 15:35:22 -0800 | [diff] [blame] | 243 | final int centerPage = launcher.getWorkspace().getNextPage(); |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 244 | return new PageAlphaProvider(ACCEL_2) { |
| 245 | @Override |
| 246 | public float getPageAlpha(int pageIndex) { |
| 247 | return pageIndex != centerPage ? 0 : 1f; |
| 248 | } |
| 249 | }; |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 250 | } |
| 251 | |
Sunny Goyal | 49bcf34 | 2018-01-11 13:59:53 -0800 | [diff] [blame] | 252 | public LauncherState getHistoryForState(LauncherState previousState) { |
| 253 | // No history is supported |
| 254 | return NORMAL; |
| 255 | } |
| 256 | |
Sunny Goyal | 75c59ac | 2018-01-15 14:23:11 -0800 | [diff] [blame] | 257 | /** |
| 258 | * Called when the start transition ends and the user settles on this particular state. |
| 259 | */ |
| 260 | public void onStateTransitionEnd(Launcher launcher) { |
Hyunyoung Song | 4bd4725 | 2018-06-05 16:26:32 -0700 | [diff] [blame] | 261 | if (this == NORMAL || this == SPRING_LOADED) { |
Sunny Goyal | 75c59ac | 2018-01-15 14:23:11 -0800 | [diff] [blame] | 262 | UiFactory.resetOverview(launcher); |
Hyunyoung Song | 4bd4725 | 2018-06-05 16:26:32 -0700 | [diff] [blame] | 263 | } |
| 264 | if (this == NORMAL) { |
Sunny Goyal | 623eddd | 2018-03-02 12:24:41 -0800 | [diff] [blame] | 265 | // Clear any rotation locks when going to normal state |
| 266 | launcher.getRotationHelper().setCurrentStateRequest(REQUEST_NONE); |
Sunny Goyal | 75c59ac | 2018-01-15 14:23:11 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
Sunny Goyal | e39690b | 2018-08-02 13:35:07 -0700 | [diff] [blame] | 270 | public void onBackPressed(Launcher launcher) { |
| 271 | if (this != NORMAL) { |
| 272 | LauncherStateManager lsm = launcher.getStateManager(); |
| 273 | LauncherState lastState = lsm.getLastState(); |
| 274 | launcher.getUserEventDispatcher().logActionCommand(Action.Command.BACK, |
| 275 | containerType, lastState.containerType); |
| 276 | lsm.goToState(lastState); |
| 277 | } |
| 278 | } |
| 279 | |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 280 | protected static void dispatchWindowStateChanged(Launcher launcher) { |
| 281 | launcher.getWindow().getDecorView().sendAccessibilityEvent(TYPE_WINDOW_STATE_CHANGED); |
| 282 | } |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 283 | |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 284 | public static abstract class PageAlphaProvider { |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 285 | |
Sunny Goyal | 0c72335 | 2017-12-12 12:02:29 -0800 | [diff] [blame] | 286 | public final Interpolator interpolator; |
| 287 | |
| 288 | public PageAlphaProvider(Interpolator interpolator) { |
| 289 | this.interpolator = interpolator; |
| 290 | } |
| 291 | |
| 292 | public abstract float getPageAlpha(int pageIndex); |
Sunny Goyal | bc683e9 | 2017-12-06 10:25:07 -0800 | [diff] [blame] | 293 | } |
Tony | bc23440 | 2019-03-19 13:30:25 -0500 | [diff] [blame] | 294 | |
| 295 | public static class ScaleAndTranslation { |
| 296 | public float scale; |
| 297 | public float translationX; |
| 298 | public float translationY; |
| 299 | |
| 300 | public ScaleAndTranslation(float scale, float translationX, float translationY) { |
| 301 | this.scale = scale; |
| 302 | this.translationX = translationX; |
| 303 | this.translationY = translationY; |
| 304 | } |
| 305 | } |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 306 | } |