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 18 19 import android.util.IndentingPrintWriter 20 import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape 21 import com.android.systemui.util.printSection 22 import com.android.systemui.util.println 23 import java.util.function.Consumer 24 25 /** 26 * This is a state holder object used by [NSSL][NotificationStackScrollLayout] to contain states 27 * provided by the `NotificationScrollViewBinder` to the `NotificationScrollView`. 28 * 29 * Unlike AmbientState, no class other than NSSL should ever have access to this class in any way. 30 * These fields are effectively NSSL's private fields. 31 */ 32 class ScrollViewFields { 33 /** Used to produce the clipping path */ 34 var scrimClippingShape: ShadeScrimShape? = null 35 /** Y coordinate in view pixels of the top of the notification stack */ 36 var stackTop: Float = 0f 37 /** 38 * Y coordinate in view pixels above which the bottom of the notification stack / shelf / footer 39 * must be. 40 */ 41 var stackBottom: Float = 0f 42 /** Y coordinate in view pixels of the top of the HUN */ 43 var headsUpTop: Float = 0f 44 /** Whether the notifications are scrolled all the way to the top (i.e. when freshly opened) */ 45 var isScrolledToTop: Boolean = true 46 47 /** 48 * Height in view pixels at which the Notification Stack would like to be laid out, including 49 * Notification rows, paddings the Shelf and the Footer. 50 */ 51 var intrinsicStackHeight: Int = 0 52 53 /** 54 * When internal NSSL expansion requires the stack to be scrolled (e.g. to keep an expanding 55 * notification in view), that scroll amount can be sent here and it will be handled by the 56 * placeholder 57 */ 58 var syntheticScrollConsumer: Consumer<Float>? = null 59 /** 60 * When a gesture is consumed internally by NSSL but needs to be handled by other elements (such 61 * as the notif scrim) as overscroll, we can notify the placeholder through here. 62 */ 63 var currentGestureOverscrollConsumer: Consumer<Boolean>? = null 64 /** 65 * Any time the heads up height is recalculated, it should be updated here to be used by the 66 * placeholder 67 */ 68 var headsUpHeightConsumer: Consumer<Float>? = null 69 70 /** send the [syntheticScroll] to the [syntheticScrollConsumer], if present. */ sendSyntheticScrollnull71 fun sendSyntheticScroll(syntheticScroll: Float) = 72 syntheticScrollConsumer?.accept(syntheticScroll) 73 /** send [isCurrentGestureOverscroll] to the [currentGestureOverscrollConsumer], if present. */ 74 fun sendCurrentGestureOverscroll(isCurrentGestureOverscroll: Boolean) = 75 currentGestureOverscrollConsumer?.accept(isCurrentGestureOverscroll) 76 /** send the [headsUpHeight] to the [headsUpHeightConsumer], if present. */ 77 fun sendHeadsUpHeight(headsUpHeight: Float) = headsUpHeightConsumer?.accept(headsUpHeight) 78 79 fun dump(pw: IndentingPrintWriter) { 80 pw.printSection("StackViewStates") { 81 pw.println("scrimClippingShape", scrimClippingShape) 82 pw.println("stackTop", stackTop) 83 pw.println("stackBottom", stackBottom) 84 pw.println("headsUpTop", headsUpTop) 85 pw.println("isScrolledToTop", isScrolledToTop) 86 } 87 } 88 } 89