• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.uioverrides.states;
17 
18 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
19 import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
20 
21 import android.content.Context;
22 import android.graphics.Color;
23 
24 import com.android.launcher3.BaseDraggingActivity;
25 import com.android.launcher3.DeviceProfile;
26 import com.android.launcher3.Launcher;
27 import com.android.launcher3.allapps.AllAppsTransitionController;
28 import com.android.quickstep.util.LayoutUtils;
29 import com.android.quickstep.views.DesktopTaskView;
30 import com.android.quickstep.views.RecentsView;
31 
32 /**
33  * State indicating that the Launcher is behind an app
34  */
35 public class BackgroundAppState extends OverviewState {
36 
37     private static final int STATE_FLAGS = FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI
38             | FLAG_WORKSPACE_INACCESSIBLE | FLAG_NON_INTERACTIVE | FLAG_CLOSE_POPUPS;
39 
BackgroundAppState(int id)40     public BackgroundAppState(int id) {
41         this(id, LAUNCHER_STATE_BACKGROUND);
42     }
43 
BackgroundAppState(int id, int logContainer)44     protected BackgroundAppState(int id, int logContainer) {
45         super(id, logContainer, STATE_FLAGS);
46     }
47 
48     @Override
getVerticalProgress(Launcher launcher)49     public float getVerticalProgress(Launcher launcher) {
50         if (launcher.getDeviceProfile().isVerticalBarLayout()) {
51             return super.getVerticalProgress(launcher);
52         }
53         RecentsView recentsView = launcher.getOverviewPanel();
54         int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher,
55                 launcher.getDeviceProfile(),
56                 recentsView.getPagedOrientationHandler());
57         AllAppsTransitionController controller = launcher.getAllAppsController();
58         float scrollRange = Math.max(controller.getShiftRange(), 1);
59         float progressDelta = (transitionLength / scrollRange);
60         return super.getVerticalProgress(launcher) + progressDelta;
61     }
62 
63     @Override
getOverviewScaleAndOffset(Launcher launcher)64     public float[] getOverviewScaleAndOffset(Launcher launcher) {
65         return getOverviewScaleAndOffsetForBackgroundState(launcher);
66     }
67 
68     @Override
getOverviewFullscreenProgress()69     public float getOverviewFullscreenProgress() {
70         return 1;
71     }
72 
73     @Override
getVisibleElements(Launcher launcher)74     public int getVisibleElements(Launcher launcher) {
75         return super.getVisibleElements(launcher)
76                 & ~OVERVIEW_ACTIONS
77                 & ~CLEAR_ALL_BUTTON
78                 & ~VERTICAL_SWIPE_INDICATOR;
79     }
80 
81     @Override
displayOverviewTasksAsGrid(DeviceProfile deviceProfile)82     public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
83         return false;
84     }
85 
86     @Override
showTaskThumbnailSplash()87     public boolean showTaskThumbnailSplash() {
88         return true;
89     }
90 
91     @Override
getDepthUnchecked(Context context)92     protected float getDepthUnchecked(Context context) {
93         if (DesktopTaskView.DESKTOP_MODE_SUPPORTED) {
94             if (Launcher.getLauncher(context).areFreeformTasksVisible()) {
95                 // Don't blur the background while freeform tasks are visible
96                 return 0;
97             }
98         }
99         return 1;
100     }
101 
102     @Override
getWorkspaceScrimColor(Launcher launcher)103     public int getWorkspaceScrimColor(Launcher launcher) {
104         return Color.TRANSPARENT;
105     }
106 
107     @Override
isTaskbarAlignedWithHotseat(Launcher launcher)108     public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
109         if (ENABLE_SHELL_TRANSITIONS) return false;
110         return super.isTaskbarAlignedWithHotseat(launcher);
111     }
112 
113     @Override
disallowTaskbarGlobalDrag()114     public boolean disallowTaskbarGlobalDrag() {
115         // Enable global drag in overview
116         return false;
117     }
118 
119     @Override
allowTaskbarInitialSplitSelection()120     public boolean allowTaskbarInitialSplitSelection() {
121         // Disallow split select from taskbar items in overview
122         return false;
123     }
124 
getOverviewScaleAndOffsetForBackgroundState( BaseDraggingActivity activity)125     public static float[] getOverviewScaleAndOffsetForBackgroundState(
126             BaseDraggingActivity activity) {
127         return new float[] {
128                 ((RecentsView) activity.getOverviewPanel()).getMaxScaleForFullScreen(),
129                 NO_OFFSET};
130     }
131 }
132