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

Commit 8aef5589 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

[flexiglass] Notification composables now set the particular placeholder...

[flexiglass] Notification composables now set the particular placeholder values from the right place.

* Only the ConstrainedNotificationStack sets the constrained height used for keyguard calculation
* The stack placeholder element sets the stack top and bottom
* The scrim bounds are now actually set by the scrim element

Bug: 296118689
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Ic5ab3f387a6c15088dcc631e06f0909d422d5c98
parent fdf1804b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.notifications.ui.composable.NotificationStack
import com.android.systemui.notifications.ui.composable.ConstrainedNotificationStack
import com.android.systemui.res.R
import com.android.systemui.shade.LargeScreenHeaderHelper
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
@@ -94,7 +94,7 @@ constructor(
            return
        }

        NotificationStack(
        ConstrainedNotificationStack(
            viewModel = viewModel,
            modifier =
                modifier.fillMaxWidth().thenIf(shouldUseSplitNotificationShade) {
+31 −15
Original line number Diff line number Diff line
@@ -118,16 +118,21 @@ fun SceneScope.HeadsUpNotificationSpace(

/** Adds the space where notification stack should appear in the scene. */
@Composable
fun SceneScope.NotificationStack(
fun SceneScope.ConstrainedNotificationStack(
    viewModel: NotificationsPlaceholderViewModel,
    modifier: Modifier = Modifier,
) {
    Box(
        modifier =
            modifier.onSizeChanged { viewModel.onConstrainedAvailableSpaceChanged(it.height) }
    ) {
        NotificationPlaceholder(
            viewModel = viewModel,
            form = Form.Stack,
        modifier = modifier,
            modifier = Modifier.fillMaxSize(),
        )
    }
}

/**
 * Adds the space where notification stack should appear in the scene, with a scrim and nested
@@ -235,6 +240,20 @@ fun SceneScope.NotificationScrollingStack(
                            .let { scrimRounding.value.toRoundedCornerShape(it) }
                    clip = true
                }
                .onGloballyPositioned { coordinates ->
                    val boundsInWindow = coordinates.boundsInWindow()
                    debugLog(viewModel) {
                        "SCRIM onGloballyPositioned:" +
                            " size=${coordinates.size}" +
                            " bounds=$boundsInWindow"
                    }
                    viewModel.onScrimBoundsChanged(
                        left = boundsInWindow.left,
                        top = boundsInWindow.top,
                        right = boundsInWindow.right,
                        bottom = boundsInWindow.bottom,
                    )
                }
    ) {
        // Creates a cutout in the background scrim in the shape of the notifications scrim.
        // Only visible when notif scrim alpha < 1, during shade expansion.
@@ -311,7 +330,6 @@ fun SceneScope.NotificationShelfSpace(
                debugLog(viewModel) {
                    ("SHELF onPlaced:" +
                        " size=${coordinates.size}" +
                        " position=${coordinates.positionInWindow()}" +
                        " bounds=${coordinates.boundsInWindow()}")
                }
            }
@@ -339,19 +357,17 @@ private fun SceneScope.NotificationPlaceholder(
                    debugLog(viewModel) { "STACK onSizeChanged: size=$size" }
                }
                .onGloballyPositioned { coordinates: LayoutCoordinates ->
                    viewModel.onContentTopChanged(coordinates.positionInWindow().y)
                    val positionInWindow = coordinates.positionInWindow()
                    debugLog(viewModel) {
                        "STACK onGloballyPositioned:" +
                            " size=${coordinates.size}" +
                            " position=${coordinates.positionInWindow()}" +
                            " position=$positionInWindow" +
                            " bounds=${coordinates.boundsInWindow()}"
                    }
                    val boundsInWindow = coordinates.boundsInWindow()
                    viewModel.onBoundsChanged(
                        left = boundsInWindow.left,
                        top = boundsInWindow.top,
                        right = boundsInWindow.right,
                        bottom = boundsInWindow.bottom,
                    // NOTE: positionInWindow.y scrolls off screen, but boundsInWindow.top will not
                    viewModel.onStackBoundsChanged(
                        top = positionInWindow.y,
                        bottom = positionInWindow.y + coordinates.size.height,
                    )
                }
    ) {
+7 −2
Original line number Diff line number Diff line
@@ -70,7 +70,12 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            val viewPosition = MutableStateFlow(ViewPosition(0, 0))
            val shape by collectLastValue(appearanceViewModel.shadeScrimShape(radius, viewPosition))

            placeholderViewModel.onBoundsChanged(left = 0f, top = 200f, right = 100f, bottom = 550f)
            placeholderViewModel.onScrimBoundsChanged(
                left = 0f,
                top = 200f,
                right = 100f,
                bottom = 550f
            )
            assertThat(shape)
                .isEqualTo(
                    ShadeScrimShape(
@@ -83,7 +88,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {

            viewPosition.value = ViewPosition(200, 15)
            radius.value = 24
            placeholderViewModel.onBoundsChanged(
            placeholderViewModel.onScrimBoundsChanged(
                left = 210f,
                top = 200f,
                right = 300f,
+10 −12
Original line number Diff line number Diff line
@@ -40,23 +40,21 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() {
    private val underTest = kosmos.notificationsPlaceholderViewModel

    @Test
    @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
    fun onBoundsChanged_setsNotificationContainerBounds() =
    fun onBoundsChanged() =
        kosmos.testScope.runTest {
            underTest.onBoundsChanged(left = 5f, top = 5f, right = 5f, bottom = 5f)
            val containerBounds by
                collectLastValue(kosmos.keyguardInteractor.notificationContainerBounds)
            underTest.onScrimBoundsChanged(left = 5f, top = 15f, right = 25f, bottom = 35f)
            val stackBounds by
                collectLastValue(kosmos.notificationStackAppearanceInteractor.shadeScrimBounds)
            assertThat(containerBounds)
                .isEqualTo(NotificationContainerBounds(top = 5f, bottom = 5f))
            assertThat(stackBounds)
                .isEqualTo(ShadeScrimBounds(left = 5f, top = 5f, right = 5f, bottom = 5f))
                .isEqualTo(ShadeScrimBounds(left = 5f, top = 15f, right = 25f, bottom = 35f))
        }

    @Test
    fun onContentTopChanged_setsContentTop() {
        underTest.onContentTopChanged(padding = 5f)
    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)
        }
}
+6 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.core.LogLevel.VERBOSE
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import javax.inject.Inject
@@ -69,11 +70,13 @@ constructor(
            }
        }

        if (!SceneContainerFlag.isEnabled) {
            scope.launch {
                sharedNotificationContainerViewModel.bounds.collect {
                    logger.log(TAG, VERBOSE, "Notif: bounds", it)
                }
            }
        }

        scope.launch {
            sharedNotificationContainerViewModel.isOnLockscreenWithoutShade.collect {
Loading