diff options
| author | 2025-01-20 04:23:43 -0800 | |
|---|---|---|
| committer | 2025-01-20 04:23:43 -0800 | |
| commit | 3122ef7c149c075c0c416d80bb52afe2aaabd499 (patch) | |
| tree | 7ad3cc4b12a1c5422f3c2f708795fa5ed6c25ae9 | |
| parent | 6454c647d4cfa40e1cd7fb813fe083ae16ba17a3 (diff) | |
| parent | 7eb765596830f70178eeaa5cfa316184397575f3 (diff) | |
Merge "[Dual Shade] Send the QS clipping bounds to the NSSL inline" into main
7 files changed, 46 insertions, 35 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt index dce110201e1d..7d366f65d64a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt @@ -39,9 +39,9 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.shared.flag.DualShade -import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape +import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationScrollViewModel import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -149,8 +149,9 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { @Test fun onPanelShapeChanged() = testScope.runTest { - val actual by - collectLastValue(kosmos.notificationStackAppearanceInteractor.qsPanelShape) + var actual: ShadeScrimShape? = null + kosmos.notificationScrollViewModel.setQsScrimShapeConsumer { shape -> actual = shape } + val expected = ShadeScrimShape( bounds = ShadeScrimBounds(left = 10f, top = 0f, right = 710f, bottom = 600f), @@ -160,7 +161,7 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { underTest.onPanelShapeChanged(expected) - assertThat(expected).isEqualTo(actual) + assertThat(actual).isEqualTo(expected) } private fun TestScope.lockDevice() { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt index 66ccf1822e21..9f0ef0057b8b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt @@ -54,10 +54,10 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { assertThat(stackBounds).isEqualTo(bounds2) } - @Test fun setQsPanelShape() = testScope.runTest { - val actual by collectLastValue(underTest.qsPanelShape) + var actual: ShadeScrimShape? = null + underTest.setQsPanelShapeConsumer { shape -> actual = shape } val expected1 = ShadeScrimShape( @@ -65,11 +65,9 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { topRadius = 0, bottomRadius = 10, ) - underTest.setQsPanelShape(expected1) assertThat(actual).isEqualTo(expected1) val expected2 = expected1.copy(topRadius = 10) - underTest.setQsPanelShape(expected2) assertThat(expected2).isEqualTo(actual) } @@ -97,7 +95,7 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { fun setQsPanelShape_withImproperBounds_throwsException() = testScope.runTest { val invalidBounds = ShadeScrimBounds(top = 0f, bottom = -10f) - underTest.setQsPanelShape( + underTest.sendQsPanelShape( ShadeScrimShape(bounds = invalidBounds, topRadius = 10, bottomRadius = 10) ) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt index 465d08b36ed0..a108bc2c4a8c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt @@ -96,7 +96,7 @@ constructor( /** Notifies that the bounds of the QuickSettings panel have changed. */ fun onPanelShapeChanged(shape: ShadeScrimShape?) { - notificationStackAppearanceInteractor.setQsPanelShape(shape) + notificationStackAppearanceInteractor.sendQsPanelShape(shape) } fun onScrimClicked() { 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 1d196c2fc079..7691328c399b 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 @@ -45,14 +45,6 @@ class NotificationPlaceholderRepository @Inject constructor() { */ val notificationShadeScrimBounds = MutableStateFlow<ShadeScrimBounds?>(null) - /** - * The shape of the QuickSettings overlay panel. Used to clip Notification content when the QS - * covers it. - * - * When `null`, it doesn't affect notification clipping. - */ - val qsPanelShape = MutableStateFlow<ShadeScrimShape?>(null) - /** height made available to the notifications in the size-constrained mode of lock screen. */ val constrainedAvailableSpace = MutableStateFlow(0) @@ -61,4 +53,10 @@ class NotificationPlaceholderRepository @Inject constructor() { /** A consumer of [AccessibilityScrollEvent]s. */ var accessibilityScrollEventConsumer: Consumer<AccessibilityScrollEvent>? = null + + /** + * A consumer of [ShadeScrimShape], to be updated when the bounds of the QuickSettings Overlay + * panel changes. + */ + var qsPanelShapeConsumer: ((ShadeScrimShape?) -> Unit)? = null } 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 406a0dbb120f..1bd44406507d 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 @@ -51,9 +51,6 @@ constructor( val notificationShadeScrimBounds: StateFlow<ShadeScrimBounds?> = placeholderRepository.notificationShadeScrimBounds.asStateFlow() - /** The shape of the QuickSettingsShadeOverlay panel */ - val qsPanelShape: StateFlow<ShadeScrimShape?> = placeholderRepository.qsPanelShape.asStateFlow() - /** * Whether the stack is expanding from GONE-with-HUN to SHADE * @@ -128,10 +125,22 @@ constructor( placeholderRepository.notificationShadeScrimBounds.value = bounds } - /** Sets the bounds of the QuickSettings overlay panel */ - fun setQsPanelShape(shape: ShadeScrimShape?) { + /** + * Sends the bounds of the QuickSettings panel to the consumer set by [setQsPanelShapeConsumer]. + * + * Used to clip Notification content when the QuickSettings Overlay panel covers it. Sending + * `null` resets the negative shape clipping of the Notification Stack. + */ + fun sendQsPanelShape(shape: ShadeScrimShape?) { checkValidBounds(shape?.bounds) - placeholderRepository.qsPanelShape.value = shape + placeholderRepository.qsPanelShapeConsumer?.invoke(shape) + } + + /** + * Sets a consumer to be notified when the QuickSettings Overlay panel changes size or position. + */ + fun setQsPanelShapeConsumer(consumer: ((ShadeScrimShape?) -> Unit)?) { + placeholderRepository.qsPanelShapeConsumer = consumer } /** Updates the current scroll state of the notification shade. */ 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 8709d27bddcc..43a552b516ae 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 @@ -86,12 +86,6 @@ constructor( .collectTraced { view.setClippingShape(it) } } - launch { - viewModel.qsScrimShape(viewLeftOffset = viewLeftOffset).collectTraced { - view.setNegativeClippingShape(it) - } - } - launch { viewModel.maxAlpha.collectTraced { view.setMaxAlpha(it) } } launch { viewModel.shadeScrollState.collect { view.setScrollState(it) } } launch { @@ -134,12 +128,20 @@ constructor( viewModel.remoteInputRowBottomBoundConsumer ) view.setAccessibilityScrollEventConsumer(viewModel.accessibilityScrollEventConsumer) + viewModel.setQsScrimShapeConsumer { shape -> + view.setNegativeClippingShape( + shape?.let { + it.copy(bounds = it.bounds.minus(leftOffset = view.asView().left)) + } + ) + } DisposableHandle { view.setSyntheticScrollConsumer(null) view.setCurrentGestureOverscrollConsumer(null) view.setCurrentGestureInGutsConsumer(null) view.setRemoteInputRowBottomBoundConsumer(null) view.setAccessibilityScrollEventConsumer(null) + viewModel.setQsScrimShapeConsumer(null) } } } 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 80ebf43baf92..20149826ceb9 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 @@ -54,6 +54,8 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull +private typealias ShadeScrimShapeConsumer = (ShadeScrimShape?) -> Unit + /** ViewModel which represents the state of the NSSL/Controller in the world of flexiglass */ class NotificationScrollViewModel @AssistedInject @@ -243,11 +245,12 @@ constructor( } .dumpWhileCollecting("shadeScrimShape") - fun qsScrimShape(viewLeftOffset: Flow<Int>): Flow<ShadeScrimShape?> = - combine(stackAppearanceInteractor.qsPanelShape, viewLeftOffset) { shape, leftOffset -> - shape?.let { it.copy(bounds = it.bounds.minus(leftOffset = leftOffset)) } - } - .dumpWhileCollecting("qsScrimShape") + /** + * Sets a consumer to be notified when the QuickSettings Overlay panel changes size or position. + */ + fun setQsScrimShapeConsumer(consumer: ShadeScrimShapeConsumer?) { + stackAppearanceInteractor.setQsPanelShapeConsumer(consumer) + } /** * Max alpha to apply directly to the view based on the compose placeholder. |