• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.overlay;
17 
18 import android.content.Context;
19 import android.view.View;
20 
21 import androidx.annotation.NonNull;
22 import androidx.annotation.Nullable;
23 
24 import com.android.launcher3.DeviceProfile;
25 import com.android.launcher3.R;
26 import com.android.launcher3.popup.PopupDataProvider;
27 import com.android.launcher3.taskbar.BaseTaskbarContext;
28 import com.android.launcher3.taskbar.TaskbarActivityContext;
29 import com.android.launcher3.taskbar.TaskbarControllers;
30 import com.android.launcher3.taskbar.TaskbarDragController;
31 import com.android.launcher3.taskbar.TaskbarUIController;
32 import com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView;
33 import com.android.launcher3.taskbar.allapps.TaskbarSearchSessionController;
34 import com.android.launcher3.util.NavigationMode;
35 import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
36 
37 /**
38  * Window context for the taskbar overlays such as All Apps and EDU.
39  * <p>
40  * Overlays have their own window and need a window context. Some properties are delegated to the
41  * {@link TaskbarActivityContext} such as {@link PopupDataProvider}.
42  */
43 public class TaskbarOverlayContext extends BaseTaskbarContext {
44     private final TaskbarActivityContext mTaskbarContext;
45 
46     private final TaskbarOverlayController mOverlayController;
47     private final TaskbarDragController mDragController;
48     private final TaskbarOverlayDragLayer mDragLayer;
49 
50     private final int mStashedTaskbarHeight;
51     private final TaskbarUIController mUiController;
52 
53     private @Nullable TaskbarSearchSessionController mSearchSessionController;
54 
TaskbarOverlayContext( Context windowContext, TaskbarActivityContext taskbarContext, TaskbarControllers controllers)55     public TaskbarOverlayContext(
56             Context windowContext,
57             TaskbarActivityContext taskbarContext,
58             TaskbarControllers controllers) {
59         super(windowContext, taskbarContext.isPrimaryDisplay());
60         mTaskbarContext = taskbarContext;
61         mOverlayController = controllers.taskbarOverlayController;
62         mDragController = new TaskbarDragController(this);
63         mDragController.init(controllers);
64         mDragLayer = new TaskbarOverlayDragLayer(this);
65         mStashedTaskbarHeight = controllers.taskbarStashController.getStashedHeight();
66 
67         mUiController = controllers.uiController;
68         onViewCreated();
69     }
70 
71     /** Called when the controller is destroyed. */
onDestroy()72     public void onDestroy() {
73         mDragController.onDestroy();
74     }
75 
getSearchSessionController()76     public @Nullable TaskbarSearchSessionController getSearchSessionController() {
77         return mSearchSessionController;
78     }
79 
setSearchSessionController( @ullable TaskbarSearchSessionController searchSessionController)80     public void setSearchSessionController(
81             @Nullable TaskbarSearchSessionController searchSessionController) {
82         mSearchSessionController = searchSessionController;
83     }
84 
getStashedTaskbarHeight()85     int getStashedTaskbarHeight() {
86         return mStashedTaskbarHeight;
87     }
88 
getOverlayController()89     public TaskbarOverlayController getOverlayController() {
90         return mOverlayController;
91     }
92 
93     /** Returns {@code true} if overlay or Taskbar windows are handling a system drag. */
isAnySystemDragInProgress()94     boolean isAnySystemDragInProgress() {
95         return mDragController.isSystemDragInProgress()
96                 || mTaskbarContext.getDragController().isSystemDragInProgress();
97     }
98 
99     @Override
getDeviceProfile()100     public DeviceProfile getDeviceProfile() {
101         return mOverlayController.getLauncherDeviceProfile();
102     }
103 
104     @Override
getAccessibilityDelegate()105     public View.AccessibilityDelegate getAccessibilityDelegate() {
106         return mTaskbarContext.getAccessibilityDelegate();
107     }
108 
109     @Override
getDragController()110     public TaskbarDragController getDragController() {
111         return mDragController;
112     }
113 
114     @Override
getDragLayer()115     public TaskbarOverlayDragLayer getDragLayer() {
116         return mDragLayer;
117     }
118 
119     @Override
getAppsView()120     public TaskbarAllAppsContainerView getAppsView() {
121         return mDragLayer.findViewById(R.id.apps_view);
122     }
123 
124     @Override
getItemOnClickListener()125     public View.OnClickListener getItemOnClickListener() {
126         return mTaskbarContext.getItemOnClickListener();
127     }
128 
129     @Override
getAllAppsItemLongClickListener()130     public View.OnLongClickListener getAllAppsItemLongClickListener() {
131         return mDragController::startDragOnLongClick;
132     }
133 
134     @NonNull
135     @Override
getPopupDataProvider()136     public PopupDataProvider getPopupDataProvider() {
137         return mTaskbarContext.getPopupDataProvider();
138     }
139 
140     @Override
startSplitSelection(SplitSelectSource splitSelectSource)141     public void startSplitSelection(SplitSelectSource splitSelectSource) {
142         mUiController.startSplitSelection(splitSelectSource);
143     }
144 
145     @Override
isTransientTaskbar()146     public boolean isTransientTaskbar() {
147         return mTaskbarContext.isTransientTaskbar();
148     }
149 
150     @Override
isPinnedTaskbar()151     public boolean isPinnedTaskbar() {
152         return mTaskbarContext.isPinnedTaskbar();
153     }
154 
155     @Override
getNavigationMode()156     public NavigationMode getNavigationMode() {
157         return mTaskbarContext.getNavigationMode();
158     }
159 
160     @Override
isInDesktopMode()161     public boolean isInDesktopMode() {
162         return mTaskbarContext.isInDesktopMode();
163     }
164 
165     @Override
showLockedTaskbarOnHome()166     public boolean showLockedTaskbarOnHome() {
167         return mTaskbarContext.showLockedTaskbarOnHome();
168     }
169 
170     @Override
showDesktopTaskbarForFreeformDisplay()171     public boolean showDesktopTaskbarForFreeformDisplay() {
172         return mTaskbarContext.showDesktopTaskbarForFreeformDisplay();
173     }
174 
175     @Override
isPrimaryDisplay()176     public boolean isPrimaryDisplay() {
177         return mTaskbarContext.isPrimaryDisplay();
178     }
179 
180     @Override
onDragStart()181     public void onDragStart() {}
182 
183     @Override
onDragEnd()184     public void onDragEnd() {
185         mOverlayController.maybeCloseWindow();
186     }
187 
188     @Override
onPopupVisibilityChanged(boolean isVisible)189     public void onPopupVisibilityChanged(boolean isVisible) {}
190 
191     @Override
onSplitScreenMenuButtonClicked()192     public void onSplitScreenMenuButtonClicked() {
193     }
194 }
195