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.statusbar.NotificationPresenter; 22 import com.android.systemui.statusbar.StatusBarState; 23 import com.android.systemui.statusbar.phone.CentralSurfaces; 24 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 25 26 /** 27 * {@link ShadeController} is an abstraction of the work that used to be hard-coded in 28 * {@link CentralSurfaces}. The shade itself represents the concept of the status bar window state, 29 * and can be in multiple states: dozing, locked, showing the bouncer, occluded, etc. All/some of 30 * these are coordinated with {@link StatusBarKeyguardViewManager} via 31 * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others. 32 */ 33 public interface ShadeController { 34 35 /** Make our window larger and the shade expanded */ instantExpandShade()36 void instantExpandShade(); 37 38 /** Collapse the shade instantly with no animation. */ instantCollapseShade()39 void instantCollapseShade(); 40 41 /** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ animateCollapseShade()42 void animateCollapseShade(); 43 44 /** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ animateCollapseShade(int flags)45 void animateCollapseShade(int flags); 46 47 /** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ animateCollapseShadeForced()48 void animateCollapseShadeForced(); 49 50 /** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ animateCollapseShadeDelayed()51 void animateCollapseShadeDelayed(); 52 53 /** 54 * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or 55 * dismissing status bar when on {@link StatusBarState#SHADE}. 56 */ animateCollapsePanels(int flags, boolean force, boolean delayed, float speedUpFactor)57 void animateCollapsePanels(int flags, boolean force, boolean delayed, float speedUpFactor); 58 59 /** 60 * If the shade is not fully expanded, collapse it animated. 61 * 62 * @return Seems to always return false 63 */ closeShadeIfOpen()64 boolean closeShadeIfOpen(); 65 66 /** 67 * Returns whether the shade is currently open. 68 * Even though in the current implementation shade is in expanded state on keyguard, this 69 * method makes distinction between shade being truly open and plain keyguard state: 70 * - if QS and notifications are visible on the screen, return true 71 * - for any other state, including keyguard, return false 72 */ isShadeFullyOpen()73 boolean isShadeFullyOpen(); 74 75 /** 76 * Add a runnable for NotificationPanelView to post when the panel is expanded. 77 * 78 * @param action the action to post 79 */ postOnShadeExpanded(Runnable action)80 void postOnShadeExpanded(Runnable action); 81 82 /** 83 * Add a runnable to be executed after the shade collapses. Post-collapse runnables are 84 * aggregated and run serially. 85 * 86 * @param action the action to execute 87 */ addPostCollapseAction(Runnable action)88 void addPostCollapseAction(Runnable action); 89 90 /** Run all of the runnables added by {@link #addPostCollapseAction}. */ runPostCollapseRunnables()91 void runPostCollapseRunnables(); 92 93 /** 94 * Close the shade if it was open 95 * 96 * @return true if the shade was open, else false 97 */ collapseShade()98 boolean collapseShade(); 99 100 /** 101 * If animate is true, does the same as {@link #collapseShade()}. Otherwise, instantly collapse 102 * the shade. Post collapse runnables will be executed 103 * 104 * @param animate true to animate the collapse, false for instantaneous collapse 105 */ collapseShade(boolean animate)106 void collapseShade(boolean animate); 107 108 /** Makes shade expanded but not visible. */ makeExpandedInvisible()109 void makeExpandedInvisible(); 110 111 /** Makes shade expanded and visible. */ makeExpandedVisible(boolean force)112 void makeExpandedVisible(boolean force); 113 114 /** Returns whether the shade is expanded and visible. */ isExpandedVisible()115 boolean isExpandedVisible(); 116 117 /** Handle status bar touch event. */ onStatusBarTouch(MotionEvent event)118 void onStatusBarTouch(MotionEvent event); 119 120 /** Called when the shade finishes collapsing. */ onClosingFinished()121 void onClosingFinished(); 122 123 /** Sets the listener for when the visibility of the shade changes. */ setVisibilityListener(ShadeVisibilityListener listener)124 void setVisibilityListener(ShadeVisibilityListener listener); 125 126 /** */ setNotificationPresenter(NotificationPresenter presenter)127 void setNotificationPresenter(NotificationPresenter presenter); 128 129 /** */ setNotificationShadeWindowViewController( NotificationShadeWindowViewController notificationShadeWindowViewController)130 void setNotificationShadeWindowViewController( 131 NotificationShadeWindowViewController notificationShadeWindowViewController); 132 133 /** */ setNotificationPanelViewController( NotificationPanelViewController notificationPanelViewController)134 void setNotificationPanelViewController( 135 NotificationPanelViewController notificationPanelViewController); 136 137 /** Listens for shade visibility changes. */ 138 interface ShadeVisibilityListener { 139 /** Called when the visibility of the shade changes. */ visibilityChanged(boolean visible)140 void visibilityChanged(boolean visible); 141 142 /** Called when shade expanded and visible state changed. */ expandedVisibleChanged(boolean expandedVisible)143 void expandedVisibleChanged(boolean expandedVisible); 144 } 145 } 146