1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui.plugins.qs; 16 17 import android.graphics.Rect; 18 import android.view.View; 19 20 import androidx.annotation.FloatRange; 21 22 import com.android.systemui.plugins.FragmentBase; 23 import com.android.systemui.plugins.annotations.DependsOn; 24 import com.android.systemui.plugins.annotations.ProvidesInterface; 25 import com.android.systemui.plugins.qs.QS.HeightListener; 26 27 import java.util.function.Consumer; 28 29 /** 30 * Fragment that contains QS in the notification shade. Most of the interface is for 31 * handling the expand/collapsing of the view interaction. 32 */ 33 @ProvidesInterface(action = QS.ACTION, version = QS.VERSION) 34 @DependsOn(target = HeightListener.class) 35 public interface QS extends FragmentBase { 36 37 String ACTION = "com.android.systemui.action.PLUGIN_QS"; 38 39 int VERSION = 16; 40 41 String TAG = "QS"; 42 setPanelView(HeightListener notificationPanelView)43 void setPanelView(HeightListener notificationPanelView); 44 hideImmediately()45 void hideImmediately(); getQsMinExpansionHeight()46 int getQsMinExpansionHeight(); getDesiredHeight()47 int getDesiredHeight(); setHeightOverride(int desiredHeight)48 void setHeightOverride(int desiredHeight); setHeaderClickable(boolean qsExpansionEnabled)49 void setHeaderClickable(boolean qsExpansionEnabled); isCustomizing()50 boolean isCustomizing(); 51 /** Close the QS customizer, if it is open. */ closeCustomizer()52 void closeCustomizer(); setOverscrolling(boolean overscrolling)53 void setOverscrolling(boolean overscrolling); setExpanded(boolean qsExpanded)54 void setExpanded(boolean qsExpanded); setListening(boolean listening)55 void setListening(boolean listening); 56 57 /** 58 * Set whether QQS/QS is visible or not. 59 * 60 * This is different from setExpanded, as it will be true when QQS is visible. In particular, 61 * it should be false when device is locked and only notifications (in lockscreen) are visible. 62 */ setQsVisible(boolean qsVisible)63 void setQsVisible(boolean qsVisible); isShowingDetail()64 boolean isShowingDetail(); closeDetail()65 void closeDetail(); animateHeaderSlidingOut()66 void animateHeaderSlidingOut(); 67 68 /** 69 * Asks QS to update its presentation, according to {@code NotificationPanelViewController}. 70 * @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.) 71 * @param panelExpansionFraction Whats the expansion of the whole shade. 72 * @param headerTranslation How much we should vertically translate QS. 73 * @param squishinessFraction Fraction that affects tile height. 0 when collapsed, 74 * 1 when expanded. 75 */ setQsExpansion(float qsExpansionFraction, float panelExpansionFraction, float headerTranslation, float squishinessFraction)76 void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction, 77 float headerTranslation, float squishinessFraction); setHeaderListening(boolean listening)78 void setHeaderListening(boolean listening); notifyCustomizeChanged()79 void notifyCustomizeChanged(); setContainerController(QSContainerController controller)80 void setContainerController(QSContainerController controller); 81 82 /** 83 * Provide an action to collapse if expanded or expand if collapsed. 84 * @param action 85 */ setCollapseExpandAction(Runnable action)86 void setCollapseExpandAction(Runnable action); 87 88 /** 89 * Returns the height difference between the QSPanel container and the QuickQSPanel container 90 */ getHeightDiff()91 int getHeightDiff(); 92 93 /** 94 * Returns the header view that contains QQS. This might return null (or throw) if there's no 95 * actual header view. 96 */ getHeader()97 View getHeader(); 98 99 /** 100 * Returns the top of the header view that contains QQS wrt to the container view 101 */ getHeaderTop()102 int getHeaderTop(); 103 104 /** 105 * Returns the bottom of the header view that contains QQS wrt to the container view 106 */ getHeaderBottom()107 int getHeaderBottom(); 108 109 /** 110 * Returns the left bound of the header view that contains QQS wrt to the container view 111 */ getHeaderLeft()112 int getHeaderLeft(); 113 114 /** 115 * Fills outBounds with the bounds of the header view (container of QQS) on the screen 116 */ getHeaderBoundsOnScreen(Rect outBounds)117 void getHeaderBoundsOnScreen(Rect outBounds); 118 119 /** 120 * Returns the height of the header view that contains QQS. It defaults to bottom - top. 121 */ getHeaderHeight()122 default int getHeaderHeight() { 123 return getHeaderBottom() - getHeaderTop(); 124 } 125 126 /** 127 * Returns whether the header view that contains QQS is shown on screen (similar semantics to 128 * View.isShown). 129 */ isHeaderShown()130 boolean isHeaderShown(); 131 setHasNotifications(boolean hasNotifications)132 default void setHasNotifications(boolean hasNotifications) { 133 } 134 135 /** Sets whether the squishiness fraction should be updated on the media host. */ setShouldUpdateSquishinessOnMedia(boolean shouldUpdate)136 default void setShouldUpdateSquishinessOnMedia(boolean shouldUpdate) {} 137 138 /** 139 * Should touches from the notification panel be disallowed? 140 * The notification panel might grab any touches rom QS at any time to collapse the shade. 141 * We should disallow that in case we are showing the detail panel. 142 */ disallowPanelTouches()143 default boolean disallowPanelTouches() { 144 return isShowingDetail(); 145 } 146 147 /** 148 * If QS should translate as we pull it down, or if it should be static. 149 */ setInSplitShade(boolean shouldTranslate)150 void setInSplitShade(boolean shouldTranslate); 151 152 /** 153 * Sets the progress of the transition to full shade on the lockscreen. 154 * 155 * @param isTransitioningToFullShade 156 * whether the transition to full shade is in progress. This might be {@code true}, even 157 * though {@code qsTransitionFraction} is still 0. 158 * The reason for that is that on some device configurations, the QS transition has a 159 * start delay compared to the overall transition. 160 * 161 * @param qsTransitionFraction 162 * the fraction of the QS transition progress, from 0 to 1. 163 * 164 * @param qsSquishinessFraction 165 * the fraction of the QS "squish" transition progress, from 0 to 1. 166 */ setTransitionToFullShadeProgress( boolean isTransitioningToFullShade, @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction)167 default void setTransitionToFullShadeProgress( 168 boolean isTransitioningToFullShade, 169 @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, 170 @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction) {} 171 172 /** 173 * A rounded corner clipping that makes QS feel as if it were behind everything. 174 */ setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, boolean visible, boolean fullWidth)175 void setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, 176 boolean visible, boolean fullWidth); 177 178 /** 179 * @return if quick settings is fully collapsed currently 180 */ isFullyCollapsed()181 default boolean isFullyCollapsed() { 182 return true; 183 } 184 185 /** 186 * Add a listener for when the collapsed media visibility changes. 187 */ setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener)188 void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener); 189 190 /** 191 * Set a scroll listener for the QSPanel container 192 */ setScrollListener(ScrollListener scrollListener)193 default void setScrollListener(ScrollListener scrollListener) {} 194 195 /** 196 * Sets the amount of vertical over scroll that should be performed on QS. 197 */ setOverScrollAmount(int overScrollAmount)198 default void setOverScrollAmount(int overScrollAmount) {} 199 200 /** 201 * Sets whether the notification panel is using the full width of the screen. Typically true on 202 * small screens and false on large screens. 203 */ setIsNotificationPanelFullWidth(boolean isFullWidth)204 void setIsNotificationPanelFullWidth(boolean isFullWidth); 205 206 /** 207 * Callback for when QSPanel container is scrolled 208 */ 209 @ProvidesInterface(version = ScrollListener.VERSION) 210 interface ScrollListener { 211 int VERSION = 1; onQsPanelScrollChanged(int scrollY)212 void onQsPanelScrollChanged(int scrollY); 213 } 214 215 @ProvidesInterface(version = HeightListener.VERSION) 216 interface HeightListener { 217 int VERSION = 1; onQsHeightChanged()218 void onQsHeightChanged(); 219 } 220 221 } 222