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

Commit 5d86b464 authored by burakov's avatar burakov
Browse files

[Dual Shade] Hide the status bar on QuickSettings shade on wide screens.

Fix: 385077133
Test: Manually tested by opening the quick settings shade on a folded
and unfolded device.
Test: Added unit tests.
Flag: com.android.systemui.dual_shade

Change-Id: Id01c07cf7ee0d8f09dc2fcd21526ba6341d35f9e
parent 96452180
Loading
Loading
Loading
Loading
+11 −8
Original line number Original line Diff line number Diff line
@@ -103,12 +103,15 @@ constructor(
            onScrimClicked = viewModel::onScrimClicked,
            onScrimClicked = viewModel::onScrimClicked,
        ) {
        ) {
            Column {
            Column {
                if (viewModel.showHeader) {
                    CollapsedShadeHeader(
                    CollapsedShadeHeader(
                        viewModelFactory = viewModel.shadeHeaderViewModelFactory,
                        viewModelFactory = viewModel.shadeHeaderViewModelFactory,
                        createTintedIconManager = tintedIconManagerFactory::create,
                        createTintedIconManager = tintedIconManagerFactory::create,
                    createBatteryMeterViewController = batteryMeterViewControllerFactory::create,
                        createBatteryMeterViewController =
                            batteryMeterViewControllerFactory::create,
                        statusBarIconController = statusBarIconController,
                        statusBarIconController = statusBarIconController,
                    )
                    )
                }


                ShadeBody(viewModel = viewModel.quickSettingsContainerViewModel)
                ShadeBody(viewModel = viewModel.quickSettingsContainerViewModel)
            }
            }
@@ -178,8 +181,8 @@ fun ContentScope.QuickSettingsLayout(
    Column(
    Column(
        verticalArrangement = Arrangement.spacedBy(QuickSettingsShade.Dimensions.Padding),
        verticalArrangement = Arrangement.spacedBy(QuickSettingsShade.Dimensions.Padding),
        horizontalAlignment = Alignment.CenterHorizontally,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = modifier
        modifier =
            .padding(
            modifier.padding(
                start = QuickSettingsShade.Dimensions.Padding,
                start = QuickSettingsShade.Dimensions.Padding,
                end = QuickSettingsShade.Dimensions.Padding,
                end = QuickSettingsShade.Dimensions.Padding,
                bottom = QuickSettingsShade.Dimensions.Padding,
                bottom = QuickSettingsShade.Dimensions.Padding,
+19 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.android.systemui.testKosmos
@@ -124,6 +125,24 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() {
            assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade)
            assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade)
        }
        }


    @Test
    fun showHeader_showsOnNarrowScreen() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(false)
            runCurrent()

            assertThat(underTest.showHeader).isTrue()
        }

    @Test
    fun showHeader_hidesOnWideScreen() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(true)
            runCurrent()

            assertThat(underTest.showHeader).isFalse()
        }

    private fun TestScope.lockDevice() {
    private fun TestScope.lockDevice() {
        val currentScene by collectLastValue(sceneInteractor.currentScene)
        val currentScene by collectLastValue(sceneInteractor.currentScene)
        kosmos.powerInteractor.setAsleepForTest()
        kosmos.powerInteractor.setAsleepForTest()
+15 −0
Original line number Original line Diff line number Diff line
@@ -16,8 +16,10 @@


package com.android.systemui.qs.ui.viewmodel
package com.android.systemui.qs.ui.viewmodel


import androidx.compose.runtime.getValue
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.Hydrator
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.domain.interactor.ShadeInteractor
@@ -28,6 +30,8 @@ import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch


/**
/**
 * Models UI state used to render the content of the quick settings shade overlay.
 * Models UI state used to render the content of the quick settings shade overlay.
@@ -44,10 +48,21 @@ constructor(
    quickSettingsContainerViewModelFactory: QuickSettingsContainerViewModel.Factory,
    quickSettingsContainerViewModelFactory: QuickSettingsContainerViewModel.Factory,
) : ExclusiveActivatable() {
) : ExclusiveActivatable() {


    private val hydrator = Hydrator("QuickSettingsContainerViewModel.hydrator")

    val showHeader: Boolean by
        hydrator.hydratedStateOf(
            traceName = "showHeader",
            initialValue = !shadeInteractor.isShadeLayoutWide.value,
            source = shadeInteractor.isShadeLayoutWide.map { !it },
        )

    val quickSettingsContainerViewModel = quickSettingsContainerViewModelFactory.create(false)
    val quickSettingsContainerViewModel = quickSettingsContainerViewModelFactory.create(false)


    override suspend fun onActivated(): Nothing {
    override suspend fun onActivated(): Nothing {
        coroutineScope {
        coroutineScope {
            launch { hydrator.activate() }

            launch {
            launch {
                sceneInteractor.currentScene.collect { currentScene ->
                sceneInteractor.currentScene.collect { currentScene ->
                    when (currentScene) {
                    when (currentScene) {