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 17 package com.android.systemui.shade; 18 19 import android.view.MotionEvent; 20 21 import com.android.systemui.CoreStartable; 22 import com.android.systemui.statusbar.CommandQueue; 23 import com.android.systemui.statusbar.NotificationPresenter; 24 import com.android.systemui.statusbar.StatusBarState; 25 import com.android.systemui.statusbar.phone.CentralSurfaces; 26 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 27 28 /** 29 * {@link ShadeController} is an abstraction of the work that used to be hard-coded in 30 * {@link CentralSurfaces}. The shade itself represents the concept of the status bar window state, 31 * and can be in multiple states: dozing, locked, showing the bouncer, occluded, etc. All/some of 32 * these are coordinated with {@link StatusBarKeyguardViewManager} via 33 * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others. 34 */ 35 public interface ShadeController extends CoreStartable { 36 /** 37 * True if the shade UI is enabled on this particular Android variant and false otherwise. 38 * 39 * @deprecated use ShadeInteractor instead 40 */ 41 @Deprecated isShadeEnabled()42 boolean isShadeEnabled(); 43 44 /** 45 * Make our window larger and the shade expanded 46 * 47 * @deprecated will no longer be needed when keyguard is a sibling view to the shade 48 */ 49 @Deprecated instantExpandShade()50 void instantExpandShade(); 51 52 /** Collapse the shade instantly with no animation. */ instantCollapseShade()53 void instantCollapseShade(); 54 55 /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ animateCollapseShade()56 default void animateCollapseShade() { 57 animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE); 58 } 59 60 /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ animateCollapseShade(int flags)61 default void animateCollapseShade(int flags) { 62 animateCollapseShade(flags, false, false, 1.0f); 63 } 64 65 /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ animateCollapseShadeForced()66 default void animateCollapseShadeForced() { 67 animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); 68 } 69 70 /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ animateCollapseShadeForcedDelayed()71 default void animateCollapseShadeForcedDelayed() { 72 animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); 73 } 74 75 /** 76 * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or 77 * dismissing status bar when on {@link StatusBarState#SHADE}. 78 */ animateCollapseShade(int flags, boolean force, boolean delayed, float speedUpFactor)79 void animateCollapseShade(int flags, boolean force, boolean delayed, float speedUpFactor); 80 81 /** 82 * Collapses the shade with an animation duration in milliseconds. 83 * 84 * @deprecated use animateCollapseShade with a speed up factor instead 85 */ 86 @Deprecated collapseWithDuration(int animationDuration)87 void collapseWithDuration(int animationDuration); 88 89 /** Expand the shade with an animation. */ animateExpandShade()90 void animateExpandShade(); 91 92 /** Expand the shade with quick settings expanded with an animation. */ animateExpandQs()93 void animateExpandQs(); 94 95 /** 96 * Posts a request to collapse the shade. 97 * 98 * @deprecated use #animateCollapseShade 99 */ 100 @Deprecated postAnimateCollapseShade()101 void postAnimateCollapseShade(); 102 103 /** 104 * Posts a request to force collapse the shade. 105 * 106 * @deprecated use #animateForceCollapseShade 107 */ 108 @Deprecated postAnimateForceCollapseShade()109 void postAnimateForceCollapseShade(); 110 111 /** 112 * Posts a request to expand the shade to quick settings. 113 * 114 * @deprecated use #animateExpandQs 115 */ 116 @Deprecated postAnimateExpandQs()117 void postAnimateExpandQs(); 118 119 /** Cancels any ongoing expansion touch handling and collapses the shade. */ cancelExpansionAndCollapseShade()120 void cancelExpansionAndCollapseShade(); 121 122 /** 123 * If the shade is not fully expanded, collapse it animated. 124 * 125 * @return Seems to always return false 126 * @deprecated use {@link #collapseShade()} instead 127 */ 128 @Deprecated closeShadeIfOpen()129 boolean closeShadeIfOpen(); 130 131 /** 132 * Returns whether the shade is currently open. 133 * Even though in the current implementation shade is in expanded state on keyguard, this 134 * method makes distinction between shade being truly open and plain keyguard state: 135 * - if QS and notifications are visible on the screen, return true 136 * - for any other state, including keyguard, return false 137 * 138 * @deprecated will be replaced by ShadeInteractor once scene container launches 139 */ 140 @Deprecated isShadeFullyOpen()141 boolean isShadeFullyOpen(); 142 143 /** 144 * Returns whether shade or QS are currently opening or collapsing. 145 * 146 * @deprecated will be replaced by ShadeInteractor once scene container launches 147 */ 148 @Deprecated isExpandingOrCollapsing()149 boolean isExpandingOrCollapsing(); 150 151 /** 152 * Add a runnable for NotificationPanelView to post when the panel is expanded. 153 * 154 * @param action the action to post 155 */ postOnShadeExpanded(Runnable action)156 void postOnShadeExpanded(Runnable action); 157 158 /** 159 * Add a runnable to be executed after the shade collapses. Post-collapse runnables are 160 * aggregated and run serially. 161 * 162 * @param action the action to execute 163 */ addPostCollapseAction(Runnable action)164 void addPostCollapseAction(Runnable action); 165 166 /** 167 * Close the shade if it was open 168 * 169 * @return true if the shade was open, else false 170 */ collapseShade()171 void collapseShade(); 172 173 /** 174 * If animate is true, does the same as {@link #collapseShade()}. Otherwise, instantly collapse 175 * the shade. Post collapse runnables will be executed 176 * 177 * @param animate true to animate the collapse, false for instantaneous collapse 178 * @deprecated call either #animateCollapseShade or #instantCollapseShade 179 */ 180 @Deprecated collapseShade(boolean animate)181 void collapseShade(boolean animate); 182 183 /** 184 * Calls #collapseShade if already on the main thread. If not, posts a call to it. 185 * @deprecated call #collapseShade 186 */ 187 @Deprecated collapseOnMainThread()188 void collapseOnMainThread(); 189 190 /** 191 * If necessary, instantly collapses the shade for an activity start, otherwise runs the 192 * post-collapse runnables. Instant collapse is ok here, because the purpose is to have the 193 * shade collapsed when the user returns to SysUI from the launched activity. 194 */ collapseShadeForActivityStart()195 void collapseShadeForActivityStart(); 196 197 /** 198 * Makes shade expanded but not visible. 199 * 200 * @deprecated no longer needed once keyguard is a sibling view to the shade 201 */ 202 @Deprecated makeExpandedInvisible()203 void makeExpandedInvisible(); 204 205 /** 206 * Makes shade expanded and visible. 207 * 208 * @deprecated no longer needed once keyguard is a sibling view to the shade 209 */ 210 @Deprecated makeExpandedVisible(boolean force)211 void makeExpandedVisible(boolean force); 212 213 /** 214 * Returns whether the shade is expanded and visible. 215 * 216 * @deprecated no longer needed once keyguard is a sibling view to the shade 217 */ 218 @Deprecated isExpandedVisible()219 boolean isExpandedVisible(); 220 221 /** 222 * Handle status bar touch event. 223 * 224 * @deprecated only called by CentralSurfaces, which is being deleted 225 */ 226 @Deprecated onStatusBarTouch(MotionEvent event)227 void onStatusBarTouch(MotionEvent event); 228 229 /** Called when a launch animation was cancelled. */ onLaunchAnimationCancelled(boolean isLaunchForActivity)230 void onLaunchAnimationCancelled(boolean isLaunchForActivity); 231 232 /** Called when a launch animation ends. */ onLaunchAnimationEnd(boolean launchIsFullScreen)233 void onLaunchAnimationEnd(boolean launchIsFullScreen); 234 235 /** 236 * Performs haptic feedback from a view with a haptic feedback constant. 237 * 238 * @param constant One of android.view.HapticFeedbackConstants 239 */ performHapticFeedback(int constant)240 void performHapticFeedback(int constant); 241 242 /** Sets the listener for when the visibility of the shade changes. */ setVisibilityListener(ShadeVisibilityListener listener)243 default void setVisibilityListener(ShadeVisibilityListener listener) {} 244 245 /** */ setNotificationPresenter(NotificationPresenter presenter)246 default void setNotificationPresenter(NotificationPresenter presenter) {} 247 248 /** */ setNotificationShadeWindowViewController( NotificationShadeWindowViewController notificationShadeWindowViewController)249 default void setNotificationShadeWindowViewController( 250 NotificationShadeWindowViewController notificationShadeWindowViewController) {} 251 252 /** Listens for shade visibility changes. */ 253 interface ShadeVisibilityListener { 254 /** Called when shade expanded and visible state changed. */ expandedVisibleChanged(boolean expandedVisible)255 void expandedVisibleChanged(boolean expandedVisible); 256 } 257 } 258