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

Commit 9f32eb89 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Split the NotificationStackAppearanceRepository into 2 pieces

* NotificationViewHeightRepository is the data provided by NSSL to the placeholders
* NotificationPlaceholderRepository is the data provided by the placeholders back to the NSSL

Bug: 296118689
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I7bb6b4b496dcc86306a8e22de1106a87eb32dd7a
parent aef03313
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ import com.android.systemui.notifications.ui.composable.Notifications.Transition
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.ui.composable.ShadeHeader
import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimRounding
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import kotlin.math.roundToInt

@@ -157,9 +157,9 @@ fun SceneScope.NotificationScrollingStack(
                .toPx()
        } + navBarHeight

    val contentHeight = viewModel.intrinsicContentHeight.collectAsState()
    val stackHeight = viewModel.stackHeight.collectAsState()

    val stackRounding = viewModel.stackRounding.collectAsState(StackRounding())
    val scrimRounding = viewModel.shadeScrimRounding.collectAsState(ShadeScrimRounding())

    // the offset for the notifications scrim. Its upper bound is 0, and its lower bound is
    // calculated in minScrimOffset. The scrim is the same height as the screen minus the
@@ -186,8 +186,8 @@ fun SceneScope.NotificationScrollingStack(

    // if contentHeight drops below minimum visible scrim height while scrim is
    // expanded, reset scrim offset.
    LaunchedEffect(contentHeight, scrimOffset) {
        snapshotFlow { contentHeight.value < minVisibleScrimHeight() && scrimOffset.value < 0f }
    LaunchedEffect(stackHeight, scrimOffset) {
        snapshotFlow { stackHeight.value < minVisibleScrimHeight() && scrimOffset.value < 0f }
            .collect { shouldCollapse -> if (shouldCollapse) scrimOffset.value = 0f }
    }

@@ -232,7 +232,7 @@ fun SceneScope.NotificationScrollingStack(
                                { expansionFraction },
                                layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade)
                            )
                            .let { stackRounding.value.toRoundedCornerShape(it) }
                            .let { scrimRounding.value.toRoundedCornerShape(it) }
                    clip = true
                }
    ) {
@@ -274,14 +274,14 @@ fun SceneScope.NotificationScrollingStack(
                                    onScrimOffsetChanged = { scrimOffset.value = it },
                                    minScrimOffset = minScrimOffset,
                                    maxScrimOffset = 0f,
                                    contentHeight = { contentHeight.value },
                                    contentHeight = { stackHeight.value },
                                    minVisibleScrimHeight = minVisibleScrimHeight,
                                )
                            }
                        )
                        .verticalScroll(scrollState)
                        .fillMaxWidth()
                        .height { (contentHeight.value + navBarHeight).roundToInt() },
                        .height { (stackHeight.value + navBarHeight).roundToInt() },
            )
        }
    }
@@ -396,7 +396,7 @@ private fun Modifier.debugBackground(
        this
    }

fun StackRounding.toRoundedCornerShape(radius: Dp): RoundedCornerShape {
fun ShadeScrimRounding.toRoundedCornerShape(radius: Dp): RoundedCornerShape {
    val topRadius = if (roundTop) radius else 0.dp
    val bottomRadius = if (roundBottom) radius else 0.dp
    return RoundedCornerShape(
+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel
import com.android.systemui.testKosmos
@@ -64,7 +64,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
    @Test
    fun updateBounds() =
        testScope.runTest {
            val clipping by collectLastValue(appearanceViewModel.stackClipping)
            val clipping by collectLastValue(appearanceViewModel.shadeScrimClipping)

            val top = 200f
            val left = 0f
@@ -77,7 +77,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
                bottom = bottom
            )
            assertThat(clipping?.bounds)
                .isEqualTo(StackBounds(left = left, top = top, right = right, bottom = bottom))
                .isEqualTo(ShadeScrimBounds(left = left, top = top, right = right, bottom = bottom))
        }

    @Test
+14 −12
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimRounding
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -42,42 +42,44 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {
    @Test
    fun stackBounds() =
        testScope.runTest {
            val stackBounds by collectLastValue(underTest.stackBounds)
            val stackBounds by collectLastValue(underTest.shadeScrimBounds)

            val bounds1 =
                StackBounds(
                ShadeScrimBounds(
                    top = 100f,
                    bottom = 200f,
                )
            underTest.setStackBounds(bounds1)
            underTest.setShadeScrimBounds(bounds1)
            assertThat(stackBounds).isEqualTo(bounds1)

            val bounds2 =
                StackBounds(
                ShadeScrimBounds(
                    top = 200f,
                    bottom = 300f,
                )
            underTest.setStackBounds(bounds2)
            underTest.setShadeScrimBounds(bounds2)
            assertThat(stackBounds).isEqualTo(bounds2)
        }

    @Test
    fun stackRounding() =
        testScope.runTest {
            val stackRounding by collectLastValue(underTest.stackRounding)
            val stackRounding by collectLastValue(underTest.shadeScrimRounding)

            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            assertThat(stackRounding).isEqualTo(StackRounding(roundTop = true, roundBottom = false))
            assertThat(stackRounding)
                .isEqualTo(ShadeScrimRounding(roundTop = true, roundBottom = false))

            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            assertThat(stackRounding).isEqualTo(StackRounding(roundTop = true, roundBottom = true))
            assertThat(stackRounding)
                .isEqualTo(ShadeScrimRounding(roundTop = true, roundBottom = true))
        }

    @Test(expected = IllegalStateException::class)
    fun setStackBounds_withImproperBounds_throwsException() =
        testScope.runTest {
            underTest.setStackBounds(
                StackBounds(
            underTest.setShadeScrimBounds(
                ShadeScrimBounds(
                    top = 100f,
                    bottom = 99f,
                )
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -47,16 +47,16 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() {
            val containerBounds by
                collectLastValue(kosmos.keyguardInteractor.notificationContainerBounds)
            val stackBounds by
                collectLastValue(kosmos.notificationStackAppearanceInteractor.stackBounds)
                collectLastValue(kosmos.notificationStackAppearanceInteractor.shadeScrimBounds)
            assertThat(containerBounds)
                .isEqualTo(NotificationContainerBounds(top = 5f, bottom = 5f))
            assertThat(stackBounds)
                .isEqualTo(StackBounds(left = 5f, top = 5f, right = 5f, bottom = 5f))
                .isEqualTo(ShadeScrimBounds(left = 5f, top = 5f, right = 5f, bottom = 5f))
        }

    @Test
    fun onContentTopChanged_setsContentTop() {
        underTest.onContentTopChanged(padding = 5f)
        assertThat(kosmos.notificationStackAppearanceInteractor.contentTop.value).isEqualTo(5f)
        assertThat(kosmos.notificationStackAppearanceInteractor.stackTop.value).isEqualTo(5f)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -1178,7 +1178,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

    /** Get the y-coordinate of the top bound of the stack. */
    public float getPlaceholderTop() {
        return mStackAppearanceInteractor.getStackBounds().getValue().getTop();
        return mStackAppearanceInteractor.getShadeScrimBounds().getValue().getTop();
    }

    /**
@@ -1191,7 +1191,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

    /** Set the intrinsic height of the stack content without additional padding. */
    public void setIntrinsicContentHeight(float intrinsicContentHeight) {
        mStackAppearanceInteractor.setIntrinsicContentHeight(intrinsicContentHeight);
        mStackAppearanceInteractor.setStackHeight(intrinsicContentHeight);
    }

    public void setIntrinsicPadding(int intrinsicPadding) {
Loading