1 /*
2  * Copyright (C) 2021 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.taskbar;
17 
18 import static android.view.Display.DEFAULT_DISPLAY;
19 import static android.view.InsetsFrameProvider.SOURCE_DISPLAY;
20 import static android.view.WindowInsets.Type.mandatorySystemGestures;
21 import static android.view.WindowInsets.Type.navigationBars;
22 import static android.view.WindowInsets.Type.systemGestures;
23 import static android.view.WindowInsets.Type.tappableElement;
24 
25 import static com.android.launcher3.taskbar.LauncherTaskbarUIController.DISPLAY_PROGRESS_COUNT;
26 
27 import android.app.PendingIntent;
28 import android.os.Binder;
29 import android.os.IBinder;
30 import android.view.InsetsFrameProvider;
31 
32 import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
33 
34 /**
35  * State shared across different taskbar instance
36  */
37 public class TaskbarSharedState {
38 
39     private final IBinder mInsetsOwner = new Binder();
40     private static int INDEX_LEFT = 0;
41     private static int INDEX_RIGHT = 1;
42 
43     // TaskbarManager#onSystemUiFlagsChanged
44     @SystemUiStateFlags
45     public long sysuiStateFlags;
46 
47     // TaskbarManager#disableNavBarElements()
48     public int disableNavBarDisplayId;
49     public int disableNavBarState1;
50     public int disableNavBarState2;
51 
52     // TaskbarManager#onSystemBarAttributesChanged()
53     public int systemBarAttrsDisplayId;
54     public int systemBarAttrsBehavior;
55 
56     // TaskbarManager#onNavButtonsDarkIntensityChanged()
57     public float navButtonsDarkIntensity;
58 
59     // TaskbarManager#onNavigationBarLumaSamplingEnabled()
60     public int mLumaSamplingDisplayId = DEFAULT_DISPLAY;
61     public boolean mIsLumaSamplingEnabled = true;
62 
63     public boolean setupUIVisible = false;
64 
65     public boolean allAppsVisible = false;
66 
67     // LauncherTaskbarUIController#mTaskbarInAppDisplayProgressMultiProp
68     public float[] inAppDisplayProgressMultiPropValues = new float[DISPLAY_PROGRESS_COUNT];
69 
70     // Taskbar System Action
71     public PendingIntent taskbarSystemActionPendingIntent;
72 
73     public final InsetsFrameProvider[] insetsFrameProviders = new InsetsFrameProvider[] {
74             new InsetsFrameProvider(mInsetsOwner, 0, navigationBars()),
75             new InsetsFrameProvider(mInsetsOwner, 0, tappableElement()),
76             new InsetsFrameProvider(mInsetsOwner, 0, mandatorySystemGestures()),
77             new InsetsFrameProvider(mInsetsOwner, INDEX_LEFT, systemGestures())
78                     .setSource(SOURCE_DISPLAY),
79             new InsetsFrameProvider(mInsetsOwner, INDEX_RIGHT, systemGestures())
80                     .setSource(SOURCE_DISPLAY)
81     };
82 
83     // Allows us to shift translation logic when doing taskbar pinning animation.
84     public boolean startTaskbarVariantIsTransient = true;
85 
86     // To track if taskbar was pinned using taskbar pinning feature at the time of recreate,
87     // so we can unstash transient taskbar when we un-pinning taskbar.
88     private boolean mTaskbarWasPinned = false;
89 
getTaskbarWasPinned()90     public boolean getTaskbarWasPinned() {
91         return mTaskbarWasPinned;
92     }
93 
setTaskbarWasPinned(boolean taskbarWasPinned)94     public void setTaskbarWasPinned(boolean taskbarWasPinned) {
95         mTaskbarWasPinned = taskbarWasPinned;
96     }
97 
98     // To track if taskbar was stashed / unstashed between configuration changes (which recreates
99     // the task bar).
100     public Boolean taskbarWasStashedAuto = true;
101 }
102