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

Commit 3718b1c3 authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "[bc25] Introduce `isShadeLayoutWide` state, and refactor `shadeMode`." into main

parents 315c49e3 72ffc982
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -67,8 +67,7 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        val isUdfpsVisible = viewModel.isUdfpsVisible
        val shouldUseSplitNotificationShade by
            viewModel.shouldUseSplitNotificationShade.collectAsStateWithLifecycle()
        val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
        val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()

        LockscreenLongPress(
@@ -100,7 +99,7 @@ constructor(
                                        }
                                )
                            }
                            if (shouldUseSplitNotificationShade) {
                            if (isShadeLayoutWide) {
                                with(notificationSection) {
                                    Notifications(
                                        burnInParams = null,
@@ -112,7 +111,7 @@ constructor(
                                }
                            }
                        }
                        if (!shouldUseSplitNotificationShade) {
                        if (!isShadeLayoutWide) {
                            with(notificationSection) {
                                Notifications(
                                    burnInParams = null,
+3 −4
Original line number Diff line number Diff line
@@ -69,8 +69,7 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        val isUdfpsVisible = viewModel.isUdfpsVisible
        val shouldUseSplitNotificationShade by
            viewModel.shouldUseSplitNotificationShade.collectAsStateWithLifecycle()
        val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
        val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()

        LockscreenLongPress(
@@ -102,7 +101,7 @@ constructor(
                                        },
                                )
                            }
                            if (shouldUseSplitNotificationShade) {
                            if (isShadeLayoutWide) {
                                with(notificationSection) {
                                    Notifications(
                                        burnInParams = null,
@@ -114,7 +113,7 @@ constructor(
                                }
                            }
                        }
                        if (!shouldUseSplitNotificationShade) {
                        if (!isShadeLayoutWide) {
                            with(notificationSection) {
                                Notifications(
                                    burnInParams = null,
+3 −5
Original line number Diff line number Diff line
@@ -90,8 +90,8 @@ constructor(
     */
    @Composable
    fun SceneScope.Notifications(burnInParams: BurnInParameters?, modifier: Modifier = Modifier) {
        val shouldUseSplitNotificationShade by
            lockscreenContentViewModel.shouldUseSplitNotificationShade.collectAsStateWithLifecycle()
        val isShadeLayoutWide by
            lockscreenContentViewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
        val areNotificationsVisible by
            lockscreenContentViewModel.areNotificationsVisible.collectAsStateWithLifecycle()
        val splitShadeTopMargin: Dp =
@@ -111,9 +111,7 @@ constructor(
            modifier =
                modifier
                    .fillMaxWidth()
                    .thenIf(shouldUseSplitNotificationShade) {
                        Modifier.padding(top = splitShadeTopMargin)
                    }
                    .thenIf(isShadeLayoutWide) { Modifier.padding(top = splitShadeTopMargin) }
                    .let {
                        if (burnInParams == null) {
                            it
+19 −20
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.media.controls.data.repository.mediaFilterRepository
import com.android.systemui.media.controls.shared.model.MediaData
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
@@ -81,10 +80,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.keyguardInteractor.setClockShouldBeCentered(true)
            assertThat(value).isEqualTo(true)
            assertThat(value).isTrue()

            kosmos.keyguardInteractor.setClockShouldBeCentered(false)
            assertThat(value).isEqualTo(false)
            assertThat(value).isFalse()
        }

    @Test
@@ -103,7 +102,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockSize_SceneContainerFlagOn_shadeModeSingle_hasNotifs_SMALL() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockSize)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            kosmos.shadeRepository.setShadeLayoutWide(false)
            kosmos.activeNotificationListRepository.setActiveNotifs(1)
            assertThat(value).isEqualTo(ClockSize.SMALL)
        }
@@ -113,7 +112,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockSize_SceneContainerFlagOn_shadeModeSingle_hasMedia_SMALL() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockSize)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            kosmos.shadeRepository.setShadeLayoutWide(false)
            val userMedia = MediaData().copy(active = true)
            kosmos.mediaFilterRepository.addSelectedUserMediaEntry(userMedia)
            assertThat(value).isEqualTo(ClockSize.SMALL)
@@ -125,7 +124,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
        testScope.runTest {
            val value by collectLastValue(underTest.clockSize)
            val userMedia = MediaData().copy(active = true)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.mediaFilterRepository.addSelectedUserMediaEntry(userMedia)
            kosmos.keyguardRepository.setIsDozing(false)
            assertThat(value).isEqualTo(ClockSize.SMALL)
@@ -136,7 +135,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockSize_SceneContainerFlagOn_shadeModeSplit_noMedia_LARGE() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockSize)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.keyguardRepository.setIsDozing(false)
            assertThat(value).isEqualTo(ClockSize.LARGE)
        }
@@ -147,7 +146,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
        testScope.runTest {
            val value by collectLastValue(underTest.clockSize)
            val userMedia = MediaData().copy(active = true)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.mediaFilterRepository.addSelectedUserMediaEntry(userMedia)
            kosmos.keyguardRepository.setIsDozing(true)
            assertThat(value).isEqualTo(ClockSize.LARGE)
@@ -158,8 +157,8 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_notSplitMode_true() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            assertThat(value).isEqualTo(true)
            kosmos.shadeRepository.setShadeLayoutWide(false)
            assertThat(value).isTrue()
        }

    @Test
@@ -167,9 +166,9 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_splitMode_noActiveNotifications_true() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.activeNotificationListRepository.setActiveNotifs(0)
            assertThat(value).isEqualTo(true)
            assertThat(value).isTrue()
        }

    @Test
@@ -177,10 +176,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_splitMode_isActiveDreamLockscreenHosted_true() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.activeNotificationListRepository.setActiveNotifs(1)
            kosmos.keyguardRepository.setIsActiveDreamLockscreenHosted(true)
            assertThat(value).isEqualTo(true)
            assertThat(value).isTrue()
        }

    @Test
@@ -188,11 +187,11 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_splitMode_hasPulsingNotifications_false() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.activeNotificationListRepository.setActiveNotifs(1)
            kosmos.headsUpNotificationRepository.isHeadsUpAnimatingAway.value = true
            kosmos.keyguardRepository.setIsDozing(true)
            assertThat(value).isEqualTo(false)
            assertThat(value).isFalse()
        }

    @Test
@@ -200,10 +199,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_splitMode_onAod_true() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.activeNotificationListRepository.setActiveNotifs(1)
            transitionTo(KeyguardState.LOCKSCREEN, KeyguardState.AOD)
            assertThat(value).isEqualTo(true)
            assertThat(value).isTrue()
        }

    @Test
@@ -211,10 +210,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
    fun clockShouldBeCentered_sceneContainerFlagOn_splitMode_offAod_false() =
        testScope.runTest {
            val value by collectLastValue(underTest.clockShouldBeCentered)
            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            kosmos.shadeRepository.setShadeLayoutWide(true)
            kosmos.activeNotificationListRepository.setActiveNotifs(1)
            transitionTo(KeyguardState.AOD, KeyguardState.LOCKSCREEN)
            assertThat(value).isEqualTo(false)
            assertThat(value).isFalse()
        }

    private suspend fun transitionTo(from: KeyguardState, to: KeyguardState) {
+12 −13
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.testKosmos
import com.android.systemui.unfold.fakeUnfoldTransitionProgressProvider
import com.android.systemui.util.mockito.whenever
@@ -76,7 +75,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
    fun setup() {
        with(kosmos) {
            fakeFeatureFlagsClassic.set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, true)
            shadeRepository.setShadeMode(ShadeMode.Single)
            shadeRepository.setShadeLayoutWide(false)
            underTest = lockscreenContentViewModel
        }
    }
@@ -126,7 +125,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible)
                shadeRepository.setShadeMode(ShadeMode.Split)
                shadeRepository.setShadeLayoutWide(true)
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)

                assertThat(areNotificationsVisible).isTrue()
@@ -156,24 +155,24 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
        }

    @Test
    fun shouldUseSplitNotificationShade_withConfigTrue_true() =
    fun isShadeLayoutWide_withConfigTrue_true() =
        with(kosmos) {
            testScope.runTest {
                val shouldUseSplitNotificationShade by
                    collectLastValue(underTest.shouldUseSplitNotificationShade)
                shadeRepository.setShadeMode(ShadeMode.Split)
                assertThat(shouldUseSplitNotificationShade).isTrue()
                val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
                shadeRepository.setShadeLayoutWide(true)

                assertThat(isShadeLayoutWide).isTrue()
            }
        }

    @Test
    fun shouldUseSplitNotificationShade_withConfigFalse_false() =
    fun isShadeLayoutWide_withConfigFalse_false() =
        with(kosmos) {
            testScope.runTest {
                val shouldUseSplitNotificationShade by
                    collectLastValue(underTest.shouldUseSplitNotificationShade)
                shadeRepository.setShadeMode(ShadeMode.Single)
                assertThat(shouldUseSplitNotificationShade).isFalse()
                val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
                shadeRepository.setShadeLayoutWide(false)

                assertThat(isShadeLayoutWide).isFalse()
            }
        }

Loading