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 /** 98 * Should touches from the notification panel be disallowed? 99 * The notification panel might grab any touches rom QS at any time to collapse the shade. 100 * We should disallow that in case we are showing the detail panel. 101 */ disallowPanelTouches()102 default boolean disallowPanelTouches() { 103 return isShowingDetail(); 104 } 105 106 /** 107 * If QS should translate as we pull it down, or if it should be static. 108 */ setInSplitShade(boolean shouldTranslate)109 void setInSplitShade(boolean shouldTranslate); 110 111 /** 112 * Sets the progress of the transition to full shade on the lockscreen. 113 * 114 * @param isTransitioningToFullShade 115 * whether the transition to full shade is in progress. This might be {@code true}, even 116 * though {@code qsTransitionFraction} is still 0. 117 * The reason for that is that on some device configurations, the QS transition has a 118 * start delay compared to the overall transition. 119 * 120 * @param qsTransitionFraction 121 * the fraction of the QS transition progress, from 0 to 1. 122 * 123 * @param qsSquishinessFraction 124 * the fraction of the QS "squish" transition progress, from 0 to 1. 125 */ setTransitionToFullShadeProgress( boolean isTransitioningToFullShade, @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction)126 default void setTransitionToFullShadeProgress( 127 boolean isTransitioningToFullShade, 128 @FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction, 129 @FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction) {} 130 131 /** 132 * A rounded corner clipping that makes QS feel as if it were behind everything. 133 */ setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, boolean visible, boolean fullWidth)134 void setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius, 135 boolean visible, boolean fullWidth); 136 137 /** 138 * @return if quick settings is fully collapsed currently 139 */ isFullyCollapsed()140 default boolean isFullyCollapsed() { 141 return true; 142 } 143 144 /** 145 * Add a listener for when the collapsed media visibility changes. 146 */ setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener)147 void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener); 148 149 /** 150 * Set a scroll listener for the QSPanel container 151 */ setScrollListener(ScrollListener scrollListener)152 default void setScrollListener(ScrollListener scrollListener) {} 153 154 /** 155 * Sets the amount of vertical over scroll that should be performed on QS. 156 */ setOverScrollAmount(int overScrollAmount)157 default void setOverScrollAmount(int overScrollAmount) {} 158 159 /** 160 * Sets whether the notification panel is using the full width of the screen. Typically true on 161 * small screens and false on large screens. 162 */ setIsNotificationPanelFullWidth(boolean isFullWidth)163 void setIsNotificationPanelFullWidth(boolean isFullWidth); 164 165 /** 166 * Callback for when QSPanel container is scrolled 167 */ 168 @ProvidesInterface(version = ScrollListener.VERSION) 169 interface ScrollListener { 170 int VERSION = 1; onQsPanelScrollChanged(int scrollY)171 void onQsPanelScrollChanged(int scrollY); 172 } 173 174 @ProvidesInterface(version = HeightListener.VERSION) 175 interface HeightListener { 176 int VERSION = 1; onQsHeightChanged()177 void onQsHeightChanged(); 178 } 179 180 } 181