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.view.View; 18 19 import androidx.annotation.FloatRange; 20 21 import com.android.systemui.plugins.FragmentBase; 22 import com.android.systemui.plugins.annotations.DependsOn; 23 import com.android.systemui.plugins.annotations.ProvidesInterface; 24 import com.android.systemui.plugins.qs.QS.HeightListener; 25 26 import java.util.function.Consumer; 27 28 /** 29 * Fragment that contains QS in the notification shade. Most of the interface is for 30 * handling the expand/collapsing of the view interaction. 31 */ 32 @ProvidesInterface(action = QS.ACTION, version = QS.VERSION) 33 @DependsOn(target = HeightListener.class) 34 public interface QS extends FragmentBase { 35 36 String ACTION = "com.android.systemui.action.PLUGIN_QS"; 37 38 int VERSION = 15; 39 40 String TAG = "QS"; 41 setPanelView(HeightListener notificationPanelView)42 void setPanelView(HeightListener notificationPanelView); 43 hideImmediately()44 void hideImmediately(); getQsMinExpansionHeight()45 int getQsMinExpansionHeight(); getDesiredHeight()46 int getDesiredHeight(); setHeightOverride(int desiredHeight)47 void setHeightOverride(int desiredHeight); setHeaderClickable(boolean qsExpansionEnabled)48 void setHeaderClickable(boolean qsExpansionEnabled); isCustomizing()49 boolean isCustomizing(); 50 /** Close the QS customizer, if it is open. */ closeCustomizer()51 void closeCustomizer(); setOverscrolling(boolean overscrolling)52 void setOverscrolling(boolean overscrolling); setExpanded(boolean qsExpanded)53 void setExpanded(boolean qsExpanded); setListening(boolean listening)54 void setListening(boolean listening); 55 56 /** 57 * Set whether QQS/QS is visible or not. 58 * 59 * This is different from setExpanded, as it will be true when QQS is visible. In particular, 60 * it should be false when device is locked and only notifications (in lockscreen) are visible. 61 */ setQsVisible(boolean qsVisible)62 void setQsVisible(boolean qsVisible); isShowingDetail()63 boolean isShowingDetail(); closeDetail()64 void closeDetail(); animateHeaderSlidingOut()65 void animateHeaderSlidingOut(); 66 67 /** 68 * Asks QS to update its presentation, according to {@code NotificationPanelViewController}. 69 * @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.) 70 * @param panelExpansionFraction Whats the expansion of the whole shade. 71 * @param headerTranslation How much we should vertically translate QS. 72 * @param squishinessFraction Fraction that affects tile height. 0 when collapsed, 73 * 1 when expanded. 74 */ setQsExpansion(float qsExpansionFraction, float panelExpansionFraction, float headerTranslation, float squishinessFraction)75 void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction, 76 float headerTranslation, float squishinessFraction); setHeaderListening(boolean listening)77 void setHeaderListening(boolean listening); notifyCustomizeChanged()78 void notifyCustomizeChanged(); setContainerController(QSContainerController controller)79 void setContainerController(QSContainerController controller); 80 81 /** 82 * Provide an action to collapse if expanded or expand if collapsed. 83 * @param action 84 */ setCollapseExpandAction(Runnable action)85 void setCollapseExpandAction(Runnable action); 86 87 /** 88 * Returns the height difference between the QSPanel container and the QuickQSPanel container 89 */ getHeightDiff()90 int getHeightDiff(); 91 getHeader()92 View getHeader(); 93 setHasNotifications(boolean hasNotifications)94 default void setHasNotifications(boolean hasNotifications) { 95 } 96 97 /** Sets whether the squishiness fraction should be updated on the media host. */ setShouldUpdateSquishinessOnMedia(boolean shouldUpdate)98 default void setShouldUpdateSquishinessOnMedia(boolean shouldUpdate) {} 99 100 /** 101 * Should touches from the notification panel be disallowed? 102 * The notification panel might grab any touches rom QS at any time to collapse the shade. 103 * We should disallow that in case we are showing the detail panel. 104 */ disallowPanelTouches()105 default boolean disallowPanelTouches() { 106 return isShowingDetail(); 107 } 108 109 /** 110 * If QS should translate as we pull it down, or if it should be static. 111 */ setInSplitShade(boolean shouldTranslate)112 void setInSplitShade(boolean shouldTranslate); 113 114 /** 115 * Sets the progress of the transition to full shade on the lockscreen. 116 * 117 * @param isTransitioningToFullShade 118 * whether the transition to full shade is in progress. This might be {@code true}, even 119 * though {@code qsTransitionFraction} is still 0. 120 * The reason for that is that on some device configurations, the QS transition has a 121 * start delay compared to the overall transition. 122 * 123 * @param qsTransitionFraction 124 * the fraction of the QS transition progress, from 0 to 1. 125 * 126 * @param qsSquishinessFraction 127 * the fraction of the QS "squish" transition progress, from 0 to 1. 128 */ setTransitionToFullShadeProgress( boolean isTransitioningToFullShade, @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction)129 default void setTransitionToFullShadeProgress( 130 boolean isTransitioningToFullShade, 131 @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, 132 @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction) {} 133 134 /** 135 * A rounded corner clipping that makes QS feel as if it were behind everything. 136 */ setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, boolean visible, boolean fullWidth)137 void setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, 138 boolean visible, boolean fullWidth); 139 140 /** 141 * @return if quick settings is fully collapsed currently 142 */ isFullyCollapsed()143 default boolean isFullyCollapsed() { 144 return true; 145 } 146 147 /** 148 * Add a listener for when the collapsed media visibility changes. 149 */ setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener)150 void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener); 151 152 /** 153 * Set a scroll listener for the QSPanel container 154 */ setScrollListener(ScrollListener scrollListener)155 default void setScrollListener(ScrollListener scrollListener) {} 156 157 /** 158 * Sets the amount of vertical over scroll that should be performed on QS. 159 */ setOverScrollAmount(int overScrollAmount)160 default void setOverScrollAmount(int overScrollAmount) {} 161 162 /** 163 * Sets whether the notification panel is using the full width of the screen. Typically true on 164 * small screens and false on large screens. 165 */ setIsNotificationPanelFullWidth(boolean isFullWidth)166 void setIsNotificationPanelFullWidth(boolean isFullWidth); 167 168 /** 169 * Callback for when QSPanel container is scrolled 170 */ 171 @ProvidesInterface(version = ScrollListener.VERSION) 172 interface ScrollListener { 173 int VERSION = 1; onQsPanelScrollChanged(int scrollY)174 void onQsPanelScrollChanged(int scrollY); 175 } 176 177 @ProvidesInterface(version = HeightListener.VERSION) 178 interface HeightListener { 179 int VERSION = 1; onQsHeightChanged()180 void onQsHeightChanged(); 181 } 182 183 } 184