Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d49a2c48 authored by András Kurucz's avatar András Kurucz
Browse files

[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
parent 3a41c67f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
+6 −4
Original line number Diff line number Diff line
@@ -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 {}
+0 −9
Original line number Diff line number Diff line
@@ -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)
        }
}
+0 −9
Original line number Diff line number Diff line
@@ -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)
+2 −0
Original line number Diff line number Diff line
@@ -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
    }

Loading