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