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; |
| 20 | |
| 21 | import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS; |
| 22 | import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; |
| 23 | import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS; |
| 24 | import static com.android.launcher3.StateFlags.FLAG_DISABLE_ACCESSIBILITY; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 25 | import static com.android.launcher3.StateFlags.FLAG_DO_NOT_RESTORE; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 26 | import static com.android.launcher3.StateFlags.FLAG_HIDE_HOTSEAT; |
| 27 | import static com.android.launcher3.StateFlags.FLAG_MULTI_PAGE; |
| 28 | import static com.android.launcher3.StateFlags.FLAG_SHOW_SCRIM; |
| 29 | |
| 30 | import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; |
| 31 | |
| 32 | interface StateFlags { |
| 33 | int FLAG_SHOW_SCRIM = 1 << 0; |
| 34 | int FLAG_MULTI_PAGE = 1 << 1; |
| 35 | int FLAG_HIDE_HOTSEAT = 1 << 2; |
| 36 | int FLAG_DISABLE_ACCESSIBILITY = 1 << 3; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 37 | int FLAG_DO_NOT_RESTORE = 1 << 4; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Various states for launcher |
| 42 | */ |
| 43 | public enum LauncherState { |
| 44 | |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 45 | NORMAL (ContainerType.WORKSPACE, 0, FLAG_DO_NOT_RESTORE), |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 46 | ALL_APPS (ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY), |
| 47 | SPRING_LOADED (ContainerType.WORKSPACE, SPRING_LOADED_TRANSITION_MS, |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 48 | FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY | FLAG_DO_NOT_RESTORE), |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 49 | OVERVIEW (ContainerType.OVERVIEW, OVERVIEW_TRANSITION_MS, |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 50 | FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT | FLAG_DO_NOT_RESTORE); |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 51 | |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 52 | /** |
| 53 | * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher} |
| 54 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 55 | public final int containerType; |
| 56 | |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 57 | /** |
| 58 | * True if the state can be persisted across activity restarts. |
| 59 | */ |
| 60 | public final boolean doNotRestore; |
| 61 | |
| 62 | /** |
| 63 | * True if workspace has multiple pages visible. |
| 64 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 65 | public final boolean hasMultipleVisiblePages; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 66 | |
| 67 | /** |
| 68 | * Accessibility flag for workspace and its pages. |
| 69 | * @see android.view.View#setImportantForAccessibility(int) |
| 70 | */ |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 71 | public final int workspaceAccessibilityFlag; |
| 72 | |
| 73 | // Properties related to state transition animation. |
| 74 | public final boolean hasScrim; |
| 75 | public final boolean hideHotseat; |
| 76 | public final int transitionDuration; |
| 77 | |
| 78 | LauncherState(int containerType, int transitionDuration, int flags) { |
| 79 | this.containerType = containerType; |
| 80 | this.transitionDuration = transitionDuration; |
| 81 | |
| 82 | this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0; |
| 83 | this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0; |
| 84 | this.hideHotseat = (flags & FLAG_HIDE_HOTSEAT) != 0; |
| 85 | this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0 |
| 86 | ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 87 | : IMPORTANT_FOR_ACCESSIBILITY_AUTO; |
Sunny Goyal | f9403d9 | 2017-10-18 10:55:56 -0700 | [diff] [blame^] | 88 | this.doNotRestore = (flags & FLAG_DO_NOT_RESTORE) != 0; |
Sunny Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 89 | } |
| 90 | } |