• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.statusbar.notification.stack.ui.view
18 
19 import android.view.View
20 import com.android.systemui.statusbar.notification.stack.shared.model.AccessibilityScrollEvent
21 import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape
22 import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrollState
23 import java.util.function.Consumer
24 
25 /**
26  * This view (interface) is the view which scrolls and positions the heads up notification and
27  * notification stack, but is otherwise agnostic to the content.
28  */
29 interface NotificationScrollView {
30 
31     /**
32      * Height in view pixels at which the Notification Stack would like to be laid out, including
33      * Notification rows, paddings the Shelf and the Footer.
34      */
35     val intrinsicStackHeight: Int
36 
37     /** Height in pixels required to display the top HeadsUp Notification. */
38     val topHeadsUpHeight: Int
39 
40     /** Bottom inset of the Notification Stack that us used to display the Shelf. */
41     val stackBottomInset: Int
42 
43     /**
44      * Since this is an interface rather than a literal View, this provides cast-like access to the
45      * underlying view.
46      */
asViewnull47     fun asView(): View
48 
49     /** Max alpha for this view */
50     fun setMaxAlpha(alpha: Float)
51 
52     /** Set whether this view is occluded by something else. */
53     fun setOccluded(isOccluded: Boolean)
54 
55     /** Sets a clipping shape, which defines the drawable area of this view. */
56     fun setClippingShape(shape: ShadeScrimShape?)
57 
58     /**
59      * Sets a clipping shape, which defines the non-drawable area of this view. The final drawing
60      * area is the difference of the clipping shape, and the negative clipping shape.
61      */
62     fun setNegativeClippingShape(shape: ShadeScrimShape?)
63 
64     /**
65      * Sets a blur effect on the view. A radius of 0 means no blur.
66      *
67      * @param radius blur radius in pixels
68      */
69     fun setBlurRadius(radius: Float)
70 
71     /** set the y position in px of the top of the stack in this view's coordinates */
72     fun setStackTop(stackTop: Float)
73 
74     /**
75      * set the bottom-most acceptable y-position of the bottom of the notification stack/ shelf /
76      * footer.
77      */
78     fun setStackCutoff(stackBottom: Float)
79 
80     /** set the y position in px of the top of the HUN in this view's coordinates */
81     fun setHeadsUpTop(headsUpTop: Float)
82 
83     /** set the bottom-most y position in px, where we can draw HUNs in this view's coordinates */
84     fun setHeadsUpBottom(headsUpBottom: Float)
85 
86     /** Updates the current scroll state of the notification shade. */
87     fun setScrollState(scrollState: ShadeScrollState)
88 
89     /** Set a consumer for synthetic scroll events */
90     fun setSyntheticScrollConsumer(consumer: Consumer<Float>?)
91 
92     /** Set a consumer for accessibility actions to be handled by the placeholder. */
93     fun setAccessibilityScrollEventConsumer(consumer: Consumer<AccessibilityScrollEvent>?)
94 
95     /** Set a consumer for current gesture overscroll events */
96     fun setCurrentGestureOverscrollConsumer(consumer: Consumer<Boolean>?)
97 
98     /** Set a consumer for current gesture in guts events */
99     fun setCurrentGestureInGutsConsumer(consumer: Consumer<Boolean>?)
100 
101     /** Set a consumer for current remote input notification row bottom bound events */
102     fun setRemoteInputRowBottomBoundConsumer(consumer: Consumer<Float?>?)
103 
104     /** sets that scrolling is allowed */
105     fun setScrollingEnabled(enabled: Boolean)
106 
107     /** sets the current expand fraction */
108     fun setExpandFraction(expandFraction: Float)
109 
110     /** sets the current QS expand fraction */
111     fun setQsExpandFraction(expandFraction: Float)
112 
113     /** set whether we are idle on the lockscreen scene */
114     fun setShowingStackOnLockscreen(showingStackOnLockscreen: Boolean)
115 
116     /** set the alpha from 0-1f of stack fade-in on lockscreen */
117     fun setAlphaForLockscreenFadeIn(alphaForLockscreenFadeIn: Float)
118 
119     /** Sets whether the view is displayed in doze mode. */
120     fun setDozing(dozing: Boolean)
121 
122     /** Sets whether the view is displayed in pulsing mode. */
123     fun setPulsing(pulsing: Boolean, animated: Boolean)
124 
125     /**
126      * Signals that any open Notification guts should be closed, as scene container is handling
127      * touch events.
128      */
129     fun closeGutsOnSceneTouch()
130 
131     /** Adds a listener to be notified, when the stack height might have changed. */
132     fun addStackHeightChangedListener(runnable: Runnable)
133 
134     /** @see addStackHeightChangedListener */
135     fun removeStackHeightChangedListener(runnable: Runnable)
136 
137     /**
138      * Adds a listener to be notified, when the height of the top heads up notification might have
139      * changed.
140      */
141     fun addHeadsUpHeightChangedListener(runnable: Runnable)
142 
143     /** @see addHeadsUpHeightChangedListener */
144     fun removeHeadsUpHeightChangedListener(runnable: Runnable)
145 
146     /** Sets whether updates to the stack are are suppressed. */
147     fun suppressHeightUpdates(suppress: Boolean)
148 }
149