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

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

Merge changes from topic "shade-header-clock" into main

* changes:
  [Dual Shade] Render the shade header in QS based on the compose state.
  [Dual Shade] Render the shade header clock based on the compose state.
parents ac590013 f71e1f5b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ constructor(
        mediaHost.get().expansion =
            if (usingCollapsedLandscapeMedia && isLandscape()) COLLAPSED else EXPANDED

        val isFullWidth = isFullWidthShade()

        OverlayShade(
            panelElement = NotificationsShade.Elements.Panel,
            alignmentOnWideScreens = Alignment.TopStart,
@@ -114,13 +116,14 @@ constructor(
                    }
                OverlayShadeHeader(
                    viewModel = headerViewModel,
                    showClock = !isFullWidth,
                    modifier = Modifier.element(NotificationsShade.Elements.StatusBar),
                )
            },
        ) {
            Box {
                Column {
                    if (isFullWidthShade()) {
                    if (isFullWidth) {
                        val burnIn = rememberBurnIn(keyguardClockViewModel)

                        with(clockSection) {
+3 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import com.android.systemui.scene.ui.composable.Overlay
import com.android.systemui.shade.ui.composable.OverlayShade
import com.android.systemui.shade.ui.composable.OverlayShadeHeader
import com.android.systemui.shade.ui.composable.QuickSettingsOverlayHeader
import com.android.systemui.shade.ui.composable.isFullWidthShade
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.view.NotificationScrollView
@@ -142,6 +143,7 @@ constructor(
                header = {
                    OverlayShadeHeader(
                        viewModel = quickSettingsContainerViewModel.shadeHeaderViewModel,
                        showClock = true,
                        modifier = Modifier.element(QuickSettingsShade.Elements.StatusBar),
                    )
                },
@@ -235,7 +237,7 @@ fun ContentScope.QuickSettingsLayout(
                bottom = QuickSettingsShade.Dimensions.Padding,
            ),
    ) {
        if (viewModel.showHeader) {
        if (isFullWidthShade()) {
            QuickSettingsOverlayHeader(
                viewModel = viewModel.shadeHeaderViewModel,
                modifier =
+0 −14
Original line number Diff line number Diff line
@@ -313,20 +313,6 @@ fun ContentScope.ExpandedShadeHeader(
 */
@Composable
fun ContentScope.OverlayShadeHeader(
    viewModel: ShadeHeaderViewModel,
    modifier: Modifier = Modifier,
) {
    OverlayShadeHeaderPartialStateless(viewModel, viewModel.showClock, modifier)
}

/**
 * Ideally, we should have a stateless function for overlay shade header, which facilitates testing.
 * However, it is cumbersome to implement such a stateless function, especially when some of the
 * overlay shade header's children accept a view model as the param. Therefore, this function only
 * break up the clock visibility. It is where "PartialStateless" comes from.
 */
@Composable
fun ContentScope.OverlayShadeHeaderPartialStateless(
    viewModel: ShadeHeaderViewModel,
    showClock: Boolean,
    modifier: Modifier = Modifier,
+0 −24
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.lifecycle.activateIn
@@ -29,7 +28,6 @@ import com.android.systemui.media.controls.shared.model.MediaData
import com.android.systemui.qs.composefragment.dagger.usingMediaInComposeFragment
import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -52,8 +50,6 @@ class QuickSettingsContainerViewModelTest : SysuiTestCase() {
        }
    private val testScope = kosmos.testScope

    private val shadeModeInteractor = kosmos.shadeModeInteractor

    private val underTest by lazy {
        kosmos.quickSettingsContainerViewModelFactory.create(supportsBrightnessMirroring = false)
    }
@@ -65,26 +61,6 @@ class QuickSettingsContainerViewModelTest : SysuiTestCase() {
        underTest.activateIn(testScope)
    }

    @Test
    fun showHeader_showsOnNarrowScreen() =
        testScope.runTest {
            kosmos.enableDualShade(wideLayout = false)
            val isShadeLayoutWide by collectLastValue(shadeModeInteractor.isShadeLayoutWide)
            assertThat(isShadeLayoutWide).isFalse()

            assertThat(underTest.showHeader).isTrue()
        }

    @Test
    fun showHeader_hidesOnWideScreen() =
        testScope.runTest {
            kosmos.enableDualShade(wideLayout = true)
            val isShadeLayoutWide by collectLastValue(shadeModeInteractor.isShadeLayoutWide)
            assertThat(isShadeLayoutWide).isTrue()

            assertThat(underTest.showHeader).isFalse()
        }

    @Test
    fun showMedia_activeMedia_true() =
        testScope.runTest {
+0 −30
Original line number Diff line number Diff line
@@ -93,36 +93,6 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {
                )
        }

    @Test
    fun showClock_wideLayout_returnsTrue() =
        testScope.runTest {
            kosmos.enableDualShade(wideLayout = true)

            setupDualShadeState(scene = Scenes.Lockscreen, overlay = Overlays.NotificationsShade)
            assertThat(underTest.showClock).isTrue()

            setupDualShadeState(scene = Scenes.Lockscreen, overlay = Overlays.QuickSettingsShade)
            assertThat(underTest.showClock).isTrue()
        }

    @Test
    fun showClock_narrowLayoutOnNotificationsShade_returnsFalse() =
        testScope.runTest {
            kosmos.enableDualShade(wideLayout = false)
            setupDualShadeState(scene = Scenes.Lockscreen, overlay = Overlays.NotificationsShade)

            assertThat(underTest.showClock).isFalse()
        }

    @Test
    fun showClock_narrowLayoutOnQuickSettingsShade_returnsTrue() =
        testScope.runTest {
            kosmos.enableDualShade(wideLayout = false)
            setupDualShadeState(scene = Scenes.Lockscreen, overlay = Overlays.QuickSettingsShade)

            assertThat(underTest.showClock).isTrue()
        }

    @Test
    fun onShadeCarrierGroupClicked_launchesNetworkSettings() =
        testScope.runTest {
Loading