blob: c51b92081254f3e8a976a2651c1277ae20d8e270 [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
18import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
19import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
20
21import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
22import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
23import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
24import static com.android.launcher3.StateFlags.FLAG_DISABLE_ACCESSIBILITY;
Sunny Goyalf9403d92017-10-18 10:55:56 -070025import static com.android.launcher3.StateFlags.FLAG_DO_NOT_RESTORE;
Sunny Goyal4c7f2152017-10-17 17:17:16 -070026import static com.android.launcher3.StateFlags.FLAG_HIDE_HOTSEAT;
27import static com.android.launcher3.StateFlags.FLAG_MULTI_PAGE;
28import static com.android.launcher3.StateFlags.FLAG_SHOW_SCRIM;
29
30import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
31
32interface 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 Goyalf9403d92017-10-18 10:55:56 -070037 int FLAG_DO_NOT_RESTORE = 1 << 4;
Sunny Goyal4c7f2152017-10-17 17:17:16 -070038}
39
40/**
41 * Various states for launcher
42 */
43public enum LauncherState {
44
Sunny Goyalf9403d92017-10-18 10:55:56 -070045 NORMAL (ContainerType.WORKSPACE, 0, FLAG_DO_NOT_RESTORE),
Sunny Goyal4c7f2152017-10-17 17:17:16 -070046 ALL_APPS (ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY),
47 SPRING_LOADED (ContainerType.WORKSPACE, SPRING_LOADED_TRANSITION_MS,
Sunny Goyalf9403d92017-10-18 10:55:56 -070048 FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY | FLAG_DO_NOT_RESTORE),
Sunny Goyal4c7f2152017-10-17 17:17:16 -070049 OVERVIEW (ContainerType.OVERVIEW, OVERVIEW_TRANSITION_MS,
Sunny Goyalf9403d92017-10-18 10:55:56 -070050 FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT | FLAG_DO_NOT_RESTORE);
Sunny Goyal4c7f2152017-10-17 17:17:16 -070051
Sunny Goyalf9403d92017-10-18 10:55:56 -070052 /**
53 * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher}
54 */
Sunny Goyal4c7f2152017-10-17 17:17:16 -070055 public final int containerType;
56
Sunny Goyalf9403d92017-10-18 10:55:56 -070057 /**
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 Goyal4c7f2152017-10-17 17:17:16 -070065 public final boolean hasMultipleVisiblePages;
Sunny Goyalf9403d92017-10-18 10:55:56 -070066
67 /**
68 * Accessibility flag for workspace and its pages.
69 * @see android.view.View#setImportantForAccessibility(int)
70 */
Sunny Goyal4c7f2152017-10-17 17:17:16 -070071 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 Goyalf9403d92017-10-18 10:55:56 -070088 this.doNotRestore = (flags & FLAG_DO_NOT_RESTORE) != 0;
Sunny Goyal4c7f2152017-10-17 17:17:16 -070089 }
90}