diff options
| author | 2024-05-10 11:39:19 +0000 | |
|---|---|---|
| committer | 2024-05-14 16:43:06 +0000 | |
| commit | d49a2c4814f01a1824cfaaf14565e49a7420f7a3 (patch) | |
| tree | 8532977af384295eaa92ae247f808ccf46ea1a78 | |
| parent | 3a41c67ffe5b2a470ee501e264c115b9610f2cbc (diff) | |
[Flexiglass] Set Stack bounds directly on the NSSL
When the NSSL's content is changing, it invalidates the
NotificationPlaceHolder's measurements. The placeholder then measures,
and reads the current stack height from the NSSL directly. Once the
placeholder is laid out, it sends back the calculated stack bounds
via the recommended arch layers (viewmodel-interactor-repository) to
the NSSL.
This CL sets the calculated stack bounds from the placeholder to the
NSSL directly, and removes doing it through the viewmodel.
Bug: 330667757
Test: Check the NSSL scrolling behaviour.
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Idb335a11520cdb0914b005faaa7deff3637177a7
10 files changed, 12 insertions, 67 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt index f48fa88b9722..bade9f168c8c 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt @@ -40,16 +40,19 @@ import com.android.systemui.notifications.ui.composable.ConstrainedNotificationS import com.android.systemui.res.R import com.android.systemui.shade.LargeScreenHeaderHelper import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout +import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel +import dagger.Lazy import javax.inject.Inject @SysUISingleton class NotificationSection @Inject constructor( + private val stackScrollView: Lazy<NotificationScrollView>, private val viewModel: NotificationsPlaceholderViewModel, private val aodBurnInViewModel: AodBurnInViewModel, sharedNotificationContainer: SharedNotificationContainer, @@ -103,6 +106,7 @@ constructor( } ConstrainedNotificationStack( + stackScrollView = stackScrollView.get(), viewModel = viewModel, modifier = modifier diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt index 7c8cc19435e1..5b01bf8722ef 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt @@ -136,6 +136,7 @@ fun SceneScope.HeadsUpNotificationSpace( /** Adds the space where notification stack should appear in the scene. */ @Composable fun SceneScope.ConstrainedNotificationStack( + stackScrollView: NotificationScrollView, viewModel: NotificationsPlaceholderViewModel, modifier: Modifier = Modifier, ) { @@ -144,6 +145,7 @@ fun SceneScope.ConstrainedNotificationStack( modifier.onSizeChanged { viewModel.onConstrainedAvailableSpaceChanged(it.height) } ) { NotificationPlaceholder( + stackScrollView = stackScrollView, viewModel = viewModel, modifier = Modifier.fillMaxSize(), ) @@ -310,6 +312,7 @@ fun SceneScope.NotificationScrollingStack( .debugBackground(viewModel, DEBUG_BOX_COLOR) ) { NotificationPlaceholder( + stackScrollView = stackScrollView, viewModel = viewModel, modifier = Modifier.verticalNestedScrollToScene( @@ -388,6 +391,7 @@ fun SceneScope.NotificationShelfSpace( @Composable private fun SceneScope.NotificationPlaceholder( + stackScrollView: NotificationScrollView, viewModel: NotificationsPlaceholderViewModel, modifier: Modifier = Modifier, ) { @@ -406,10 +410,8 @@ private fun SceneScope.NotificationPlaceholder( " bounds=${coordinates.boundsInWindow()}" } // NOTE: positionInWindow.y scrolls off screen, but boundsInWindow.top will not - viewModel.onStackBoundsChanged( - top = positionInWindow.y, - bottom = positionInWindow.y + coordinates.size.height, - ) + stackScrollView.setStackTop(positionInWindow.y) + stackScrollView.setStackBottom(positionInWindow.y + coordinates.size.height) } ) { content {} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt index 1f0812da9fe9..ee9fd3494d96 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt @@ -44,13 +44,4 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() { collectLastValue(kosmos.notificationStackAppearanceInteractor.shadeScrimBounds) assertThat(stackBounds).isEqualTo(bounds) } - - @Test - fun onStackBoundsChanged() = - kosmos.testScope.runTest { - underTest.onStackBoundsChanged(top = 5f, bottom = 500f) - assertThat(kosmos.notificationStackAppearanceInteractor.stackTop.value).isEqualTo(5f) - assertThat(kosmos.notificationStackAppearanceInteractor.stackBottom.value) - .isEqualTo(500f) - } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 2cd295c6045d..1f45fd6f8a07 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -660,9 +660,6 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization?) : overrideResource(R.bool.config_use_split_notification_shade, false) configurationRepository.onAnyConfigurationChange() - keyguardInteractor.setNotificationContainerBounds( - NotificationContainerBounds(top = 1f, bottom = 2f) - ) assertThat(maxNotifications).isEqualTo(10) @@ -691,9 +688,6 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization?) : overrideResource(R.bool.config_use_split_notification_shade, false) configurationRepository.onAnyConfigurationChange() - keyguardInteractor.setNotificationContainerBounds( - NotificationContainerBounds(top = 1f, bottom = 2f) - ) assertThat(maxNotifications).isEqualTo(10) @@ -728,9 +722,6 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization?) : overrideResource(R.bool.config_use_split_notification_shade, false) configurationRepository.onAnyConfigurationChange() - keyguardInteractor.setNotificationContainerBounds( - NotificationContainerBounds(top = 1f, bottom = 2f) - ) // -1 means No Limit assertThat(maxNotifications).isEqualTo(-1) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 2d7b7375f625..72857391793f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -97,6 +97,7 @@ constructor( /** Bounds of the notification container. */ val notificationContainerBounds: StateFlow<NotificationContainerBounds> by lazy { + SceneContainerFlag.assertInLegacyMode() combine( _notificationPlaceholderBounds, sharedNotificationContainerInteractor.get().configurationBasedDimensions, @@ -115,6 +116,7 @@ constructor( } fun setNotificationContainerBounds(position: NotificationContainerBounds) { + SceneContainerFlag.assertInLegacyMode() _notificationPlaceholderBounds.value = position } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationPlaceholderRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationPlaceholderRepository.kt index dacafc48fc72..db544ce59aa1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationPlaceholderRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationPlaceholderRepository.kt @@ -38,16 +38,6 @@ class NotificationPlaceholderRepository @Inject constructor() { */ val shadeScrimBounds = MutableStateFlow<ShadeScrimBounds?>(null) - /** - * The y-coordinate in px of top of the contents of the notification stack. This value can be - * negative, if the stack is scrolled such that its top extends beyond the top edge of the - * screen. - */ - val stackTop = MutableStateFlow(0f) - - /** the bottom-most acceptable y-position for the bottom of the stack / shelf */ - val stackBottom = MutableStateFlow(0f) - /** the y position of the top of the HUN area */ val headsUpTop = MutableStateFlow(0f) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt index 365ead699c65..e7acbe3ab0b0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt @@ -72,12 +72,6 @@ constructor( val alphaForBrightnessMirror: StateFlow<Float> = placeholderRepository.alphaForBrightnessMirror.asStateFlow() - /** The y-coordinate in px of top of the contents of the notification stack. */ - val stackTop: StateFlow<Float> = placeholderRepository.stackTop.asStateFlow() - - /** The y-coordinate in px of bottom of the contents of the notification stack. */ - val stackBottom: StateFlow<Float> = placeholderRepository.stackBottom.asStateFlow() - /** The height of the keyguard's available space bounds */ val constrainedAvailableSpace: StateFlow<Int> = placeholderRepository.constrainedAvailableSpace.asStateFlow() @@ -121,16 +115,6 @@ constructor( viewHeightRepository.headsUpHeight.value = height } - /** Sets the y-coord in px of the top of the contents of the notification stack. */ - fun setStackTop(stackTop: Float) { - placeholderRepository.stackTop.value = stackTop - } - - /** Sets the y-coord in px of the bottom of the contents of the notification stack. */ - fun setStackBottom(stackBottom: Float) { - placeholderRepository.stackBottom.value = stackBottom - } - /** Sets whether the notification stack is scrolled to the top. */ fun setScrolledToTop(scrolledToTop: Boolean) { placeholderRepository.scrolledToTop.value = scrolledToTop diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt index 3c44713a1df5..622d8e7b2307 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt @@ -79,8 +79,6 @@ constructor( } launch { viewModel.maxAlpha.collect { view.setMaxAlpha(it) } } - launch { viewModel.stackTop.collect { view.setStackTop(it) } } - launch { viewModel.stackBottom.collect { view.setStackBottom(it) } } launch { viewModel.scrolledToTop.collect { view.setScrolledToTop(it) } } launch { viewModel.headsUpTop.collect { view.setHeadsUpTop(it) } } launch { viewModel.expandFraction.collect { view.setExpandFraction(it.coerceIn(0f, 1f)) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt index 082f6b6f11aa..61373815db1c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt @@ -130,10 +130,6 @@ constructor( val maxAlpha: Flow<Float> = stackAppearanceInteractor.alphaForBrightnessMirror.dumpValue("maxAlpha") - /** The y-coordinate in px of top of the contents of the notification stack. */ - val stackTop: Flow<Float> = stackAppearanceInteractor.stackTop.dumpValue("stackTop") - /** The y-coordinate in px of bottom of the contents of the notification stack. */ - val stackBottom: Flow<Float> = stackAppearanceInteractor.stackBottom.dumpValue("stackBottom") /** * Whether the notification stack is scrolled to the top; i.e., it cannot be scrolled down any * further. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt index 736058ac3a78..97b86e3371f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt @@ -16,7 +16,6 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel -import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlagsClassic @@ -57,18 +56,6 @@ constructor( interactor.setShadeScrimBounds(bounds) } - /** Notifies that the bounds of the notification placeholder have changed. */ - fun onStackBoundsChanged( - top: Float, - bottom: Float, - ) { - keyguardInteractor.setNotificationContainerBounds( - NotificationContainerBounds(top = top, bottom = bottom) - ) - interactor.setStackTop(top) - interactor.setStackBottom(bottom) - } - /** Sets the available space */ fun onConstrainedAvailableSpaceChanged(height: Int) { interactor.setConstrainedAvailableSpace(height) |