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 import android.view.View.OnClickListener;
19 
20 import com.android.systemui.plugins.FragmentBase;
21 import com.android.systemui.plugins.annotations.DependsOn;
22 import com.android.systemui.plugins.annotations.ProvidesInterface;
23 import com.android.systemui.plugins.qs.QS.HeightListener;
24 
25 import java.util.function.Consumer;
26 
27 /**
28  * Fragment that contains QS in the notification shade.  Most of the interface is for
29  * handling the expand/collapsing of the view interaction.
30  */
31 @ProvidesInterface(action = QS.ACTION, version = QS.VERSION)
32 @DependsOn(target = HeightListener.class)
33 public interface QS extends FragmentBase {
34 
35     String ACTION = "com.android.systemui.action.PLUGIN_QS";
36 
37     int VERSION = 12;
38 
39     String TAG = "QS";
40 
setPanelView(HeightListener notificationPanelView)41     void setPanelView(HeightListener notificationPanelView);
42 
hideImmediately()43     void hideImmediately();
getQsMinExpansionHeight()44     int getQsMinExpansionHeight();
getDesiredHeight()45     int getDesiredHeight();
setHeightOverride(int desiredHeight)46     void setHeightOverride(int desiredHeight);
setHeaderClickable(boolean qsExpansionEnabled)47     void setHeaderClickable(boolean qsExpansionEnabled);
isCustomizing()48     boolean isCustomizing();
49     /** Close the QS customizer, if it is open. */
closeCustomizer()50     void closeCustomizer();
setOverscrolling(boolean overscrolling)51     void setOverscrolling(boolean overscrolling);
setExpanded(boolean qsExpanded)52     void setExpanded(boolean qsExpanded);
setListening(boolean listening)53     void setListening(boolean listening);
isShowingDetail()54     boolean isShowingDetail();
closeDetail()55     void closeDetail();
animateHeaderSlidingOut()56     void animateHeaderSlidingOut();
57 
58     /**
59      * Asks QS to update its presentation, according to {@code NotificationPanelViewController}.
60      * @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.)
61      * @param panelExpansionFraction Whats the expansion of the whole shade.
62      * @param headerTranslation How much we should vertically translate QS.
63      * @param squishinessFraction Fraction that affects tile height. 0 when collapsed,
64      *                            1 when expanded.
65      */
setQsExpansion(float qsExpansionFraction, float panelExpansionFraction, float headerTranslation, float squishinessFraction)66     void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction,
67             float headerTranslation, float squishinessFraction);
setHeaderListening(boolean listening)68     void setHeaderListening(boolean listening);
notifyCustomizeChanged()69     void notifyCustomizeChanged();
setContainerController(QSContainerController controller)70     void setContainerController(QSContainerController controller);
setExpandClickListener(OnClickListener onClickListener)71     void setExpandClickListener(OnClickListener onClickListener);
72 
getHeader()73     View getHeader();
74 
setHasNotifications(boolean hasNotifications)75     default void setHasNotifications(boolean hasNotifications) {
76     }
77 
78     /**
79      * Should touches from the notification panel be disallowed?
80      * The notification panel might grab any touches rom QS at any time to collapse the shade.
81      * We should disallow that in case we are showing the detail panel.
82      */
disallowPanelTouches()83     default boolean disallowPanelTouches() {
84         return isShowingDetail();
85     }
86 
87     /**
88      * If QS should translate as we pull it down, or if it should be static.
89      */
setInSplitShade(boolean shouldTranslate)90     void setInSplitShade(boolean shouldTranslate);
91 
92     /**
93      * Set the amount of pixels we have currently dragged down if we're transitioning to the full
94      * shade. 0.0f means we're not transitioning yet.
95      */
setTransitionToFullShadeAmount(float pxAmount, float progress)96     default void setTransitionToFullShadeAmount(float pxAmount, float progress) {}
97 
98     /**
99      * A rounded corner clipping that makes QS feel as if it were behind everything.
100      */
setFancyClipping(int top, int bottom, int cornerRadius, boolean visible)101     void setFancyClipping(int top, int bottom, int cornerRadius, boolean visible);
102 
103     /**
104      * @return if quick settings is fully collapsed currently
105      */
isFullyCollapsed()106     default boolean isFullyCollapsed() {
107         return true;
108     }
109 
110     /**
111      * Add a listener for when the collapsed media visibility changes.
112      */
setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener)113     void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener);
114 
115     /**
116      * Set a scroll listener for the QSPanel container
117      */
setScrollListener(ScrollListener scrollListener)118     default void setScrollListener(ScrollListener scrollListener) {}
119 
120     /**
121      * Callback for when QSPanel container is scrolled
122      */
123     @ProvidesInterface(version = ScrollListener.VERSION)
124     interface ScrollListener {
125         int VERSION = 1;
onQsPanelScrollChanged(int scrollY)126         void onQsPanelScrollChanged(int scrollY);
127     }
128 
129     @ProvidesInterface(version = HeightListener.VERSION)
130     interface HeightListener {
131         int VERSION = 1;
onQsHeightChanged()132         void onQsHeightChanged();
133     }
134 
135 }
136