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;
17 
18 import android.content.Context;
19 import android.view.ContextThemeWrapper;
20 import android.view.LayoutInflater;
21 
22 import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
23 import com.android.launcher3.util.Themes;
24 import com.android.launcher3.views.ActivityContext;
25 
26 import java.util.ArrayList;
27 import java.util.List;
28 
29 // TODO(b/218912746): Share more behavior to avoid all apps context depending directly on taskbar.
30 /** Base for common behavior between taskbar window contexts. */
31 public abstract class BaseTaskbarContext extends ContextThemeWrapper implements ActivityContext {
32 
33     protected final LayoutInflater mLayoutInflater;
34     private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
35 
BaseTaskbarContext(Context windowContext)36     public BaseTaskbarContext(Context windowContext) {
37         super(windowContext, Themes.getActivityThemeRes(windowContext));
38         mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
39     }
40 
41     @Override
getLayoutInflater()42     public final LayoutInflater getLayoutInflater() {
43         return mLayoutInflater;
44     }
45 
46     @Override
getOnDeviceProfileChangeListeners()47     public final List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
48         return mDPChangeListeners;
49     }
50 
51     /** Callback invoked when a drag is initiated within this context. */
onDragStart()52     public abstract void onDragStart();
53 
54     /** Callback invoked when a drag is finished within this context. */
onDragEnd()55     public abstract void onDragEnd();
56 
57     /** Callback invoked when a popup is shown or closed within this context. */
onPopupVisibilityChanged(boolean isVisible)58     public abstract void onPopupVisibilityChanged(boolean isVisible);
59 
60     /**
61      * Callback invoked when user attempts to split the screen through a long-press menu in Taskbar
62      * or AllApps.
63      */
onSplitScreenMenuButtonClicked()64     public abstract void onSplitScreenMenuButtonClicked();
65 }
66