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.content.Intent; 20 import android.content.pm.ShortcutInfo; 21 import android.os.UserHandle; 22 import android.view.LayoutInflater; 23 24 import com.android.launcher3.popup.SystemShortcut; 25 import com.android.launcher3.util.BaseContext; 26 import com.android.launcher3.util.NavigationMode; 27 import com.android.launcher3.util.Themes; 28 import com.android.quickstep.SystemUiProxy; 29 30 // TODO(b/218912746): Share more behavior to avoid all apps context depending directly on taskbar. 31 /** Base for common behavior between taskbar window contexts. */ 32 public abstract class BaseTaskbarContext extends BaseContext 33 implements SystemShortcut.BubbleActivityStarter { 34 35 protected final LayoutInflater mLayoutInflater; 36 BaseTaskbarContext(Context windowContext, boolean isPrimaryDisplay)37 public BaseTaskbarContext(Context windowContext, boolean isPrimaryDisplay) { 38 super(windowContext, Themes.getActivityThemeRes(windowContext)); 39 mLayoutInflater = LayoutInflater.from(this).cloneInContext(this); 40 } 41 42 /** 43 * Returns whether taskbar is transient or persistent. External displays will be persistent. 44 * 45 * @return {@code true} if transient, {@code false} if persistent. 46 */ isTransientTaskbar()47 public abstract boolean isTransientTaskbar(); 48 49 /** 50 * Returns whether the taskbar is pinned in gesture navigation mode. 51 */ isPinnedTaskbar()52 public abstract boolean isPinnedTaskbar(); 53 54 /** 55 * Returns the current navigation mode. External displays will be in THREE_BUTTONS mode. 56 */ getNavigationMode()57 public abstract NavigationMode getNavigationMode(); 58 59 /** 60 * Returns whether the taskbar is in desktop mode. 61 */ isInDesktopMode()62 public abstract boolean isInDesktopMode(); 63 64 /** 65 * Returns whether the taskbar is forced to be pinned when home is visible. 66 */ showLockedTaskbarOnHome()67 public abstract boolean showLockedTaskbarOnHome(); 68 69 /** 70 * Returns whether desktop taskbar (pinned taskbar that shows desktop tasks) is to be used on 71 * the display because the display is a freeform display. 72 */ showDesktopTaskbarForFreeformDisplay()73 public abstract boolean showDesktopTaskbarForFreeformDisplay(); 74 75 /** 76 * Returns whether the taskbar is displayed on primary or external display. 77 */ isPrimaryDisplay()78 public abstract boolean isPrimaryDisplay(); 79 80 @Override getLayoutInflater()81 public final LayoutInflater getLayoutInflater() { 82 return mLayoutInflater; 83 } 84 85 @Override showShortcutBubble(ShortcutInfo info)86 public void showShortcutBubble(ShortcutInfo info) { 87 if (info == null) return; 88 SystemUiProxy.INSTANCE.get(this).showShortcutBubble(info); 89 } 90 91 @Override showAppBubble(Intent intent, UserHandle user)92 public void showAppBubble(Intent intent, UserHandle user) { 93 if (intent == null || intent.getPackage() == null) return; 94 SystemUiProxy.INSTANCE.get(this).showAppBubble(intent, user); 95 } 96 97 /** Callback invoked when a drag is initiated within this context. */ onDragStart()98 public abstract void onDragStart(); 99 100 /** Callback invoked when a drag is finished within this context. */ onDragEnd()101 public abstract void onDragEnd(); 102 103 /** Callback invoked when a popup is shown or closed within this context. */ onPopupVisibilityChanged(boolean isVisible)104 public abstract void onPopupVisibilityChanged(boolean isVisible); 105 106 /** 107 * Callback invoked when user attempts to split the screen through a long-press menu in Taskbar 108 * or AllApps. 109 */ onSplitScreenMenuButtonClicked()110 public abstract void onSplitScreenMenuButtonClicked(); 111 } 112