blob: 8ddc49122756623fadcde971c113264d05af10d7 [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;
25import static com.android.launcher3.StateFlags.FLAG_HIDE_HOTSEAT;
26import static com.android.launcher3.StateFlags.FLAG_MULTI_PAGE;
27import static com.android.launcher3.StateFlags.FLAG_SHOW_SCRIM;
28
29import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
30
31interface StateFlags {
32 int FLAG_SHOW_SCRIM = 1 << 0;
33 int FLAG_MULTI_PAGE = 1 << 1;
34 int FLAG_HIDE_HOTSEAT = 1 << 2;
35 int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
36}
37
38/**
39 * Various states for launcher
40 */
41public enum LauncherState {
42
43 NORMAL (ContainerType.WORKSPACE, 0, 0),
44 ALL_APPS (ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY),
45 SPRING_LOADED (ContainerType.WORKSPACE, SPRING_LOADED_TRANSITION_MS,
46 FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY),
47 OVERVIEW (ContainerType.OVERVIEW, OVERVIEW_TRANSITION_MS,
48 FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT);
49
50 public final int containerType;
51
52 public final boolean hasMultipleVisiblePages;
53 public final int workspaceAccessibilityFlag;
54
55 // Properties related to state transition animation.
56 public final boolean hasScrim;
57 public final boolean hideHotseat;
58 public final int transitionDuration;
59
60 LauncherState(int containerType, int transitionDuration, int flags) {
61 this.containerType = containerType;
62 this.transitionDuration = transitionDuration;
63
64 this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0;
65 this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
66 this.hideHotseat = (flags & FLAG_HIDE_HOTSEAT) != 0;
67 this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
68 ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
69 : IMPORTANT_FOR_ACCESSIBILITY_AUTO;
70 }
71}