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

Commit 7e1aaadb authored by Shawn Lee's avatar Shawn Lee
Browse files

[flexiglass] Add largescreen layout to Shade Header and fix percentage behavior

Shade Header now shows correct layout in large screen and also correctly shows battery percentage when there is no center cutout.

Bug: 301646951
Bug: 298525212
Test: manually verified appearance
Change-Id: I2be22b4721486176b1ff2f11d24af39f5747cfeb
parent 50622554
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -23,11 +23,13 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.SceneScope
import com.android.compose.windowsizeclass.LocalWindowSizeClass
import com.android.systemui.battery.BatteryMeterViewController
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.qs.footer.ui.compose.QuickSettings
@@ -37,6 +39,7 @@ import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneModel
import com.android.systemui.scene.shared.model.UserAction
import com.android.systemui.scene.ui.composable.ComposableScene
import com.android.systemui.shade.ui.composable.CollapsedShadeHeader
import com.android.systemui.shade.ui.composable.ExpandedShadeHeader
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager
@@ -98,12 +101,22 @@ private fun SceneScope.QuickSettingsScene(
                .clickable(onClick = { viewModel.onContentClicked() })
                .padding(start = 16.dp, end = 16.dp, bottom = 48.dp)
    ) {
        when (LocalWindowSizeClass.current.widthSizeClass) {
            WindowWidthSizeClass.Compact ->
                ExpandedShadeHeader(
                    viewModel = viewModel.shadeHeaderViewModel,
                    createTintedIconManager = createTintedIconManager,
                    createBatteryMeterViewController = createBatteryMeterViewController,
                    statusBarIconController = statusBarIconController,
                )
            else ->
                CollapsedShadeHeader(
                    viewModel = viewModel.shadeHeaderViewModel,
                    createTintedIconManager = createTintedIconManager,
                    createBatteryMeterViewController = createBatteryMeterViewController,
                    statusBarIconController = statusBarIconController,
                )
        }
        Spacer(modifier = Modifier.height(16.dp))
        QuickSettings()
    }
+12 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
@@ -50,6 +51,7 @@ import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.ValueKey
import com.android.compose.animation.scene.animateSharedFloatAsState
import com.android.compose.windowsizeclass.LocalWindowSizeClass
import com.android.settingslib.Utils
import com.android.systemui.battery.BatteryMeterView
import com.android.systemui.battery.BatteryMeterViewController
@@ -98,12 +100,12 @@ fun SceneScope.CollapsedShadeHeader(
            ShadeHeader.Keys.transitionProgress,
            ShadeHeader.Elements.FormatPlaceholder
        )
    val useExpandedFormat by
        remember(formatProgress) { derivedStateOf { formatProgress.value > 0.5f } }

    val cutoutWidth = LocalDisplayCutout.current.width()
    val cutoutLocation = LocalDisplayCutout.current.location

    val useExpandedFormat = formatProgress.value > 0.5f || cutoutLocation != CutoutLocation.CENTER

    // This layout assumes it is globally positioned at (0, 0) and is the
    // same size as the screen.
    Layout(
@@ -131,6 +133,14 @@ fun SceneScope.CollapsedShadeHeader(
                {
                    Row(horizontalArrangement = Arrangement.End) {
                        SystemIconContainer {
                            when (LocalWindowSizeClass.current.widthSizeClass) {
                                WindowWidthSizeClass.Medium,
                                WindowWidthSizeClass.Expanded ->
                                    ShadeCarrierGroup(
                                        viewModel = viewModel,
                                        modifier = Modifier.align(Alignment.CenterVertically),
                                    )
                            }
                            StatusIcons(
                                viewModel = viewModel,
                                createTintedIconManager = createTintedIconManager,