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

Commit d9997c57 authored by Andre Le's avatar Andre Le
Browse files

Move HighlightChip interface to ShadeHighlightChip

ShadeHighlightChip was moved to a separate file in ag/34791265. We
should move the HighlightChip interface out of ShadeHeader as well as a
result.

Bug: None
Flag: EXEMPT clean up
Test: ShadeHeaderViewModelTest
Change-Id: I448eaedc00dd50a05303c2778ef222ef732ad6e2
parent 75c89664
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -39,9 +39,9 @@ import com.android.systemui.res.R
import com.android.systemui.scene.session.ui.composable.SaveableSession
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.ui.composable.Overlay
import com.android.systemui.shade.ui.composable.ChipHighlightModel
import com.android.systemui.shade.ui.composable.OverlayShade
import com.android.systemui.shade.ui.composable.OverlayShadeHeader
import com.android.systemui.shade.ui.composable.ShadeHeader
import com.android.systemui.shade.ui.composable.isFullWidthShade
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView
import dagger.Lazy
@@ -102,7 +102,7 @@ constructor(
                        }
                    OverlayShadeHeader(
                        viewModel = headerViewModel,
                        notificationsHighlight = ShadeHeader.ChipHighlight.Strong,
                        notificationsHighlight = ChipHighlightModel.Strong,
                        quickSettingsHighlight = headerViewModel.inactiveChipHighlight,
                        showClock = !isFullWidth,
                        modifier = Modifier.element(NotificationsShade.Elements.StatusBar),
+2 −2
Original line number Diff line number Diff line
@@ -83,10 +83,10 @@ import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeOverlayContentView
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.ui.composable.Overlay
import com.android.systemui.shade.ui.composable.ChipHighlightModel
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.ShadeHeader
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
@@ -169,7 +169,7 @@ constructor(
                        OverlayShadeHeader(
                            viewModel = headerViewModel,
                            notificationsHighlight = headerViewModel.inactiveChipHighlight,
                            quickSettingsHighlight = ShadeHeader.ChipHighlight.Strong,
                            quickSettingsHighlight = ChipHighlightModel.Strong,
                            showClock = true,
                            modifier = Modifier.element(QuickSettingsShade.Elements.StatusBar),
                        )
+3 −49
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@@ -146,51 +145,6 @@ object ShadeHeader {
        const val BatteryTestTag = "battery_meter_composable_view"
        const val BatteryTestTagLegacy = "battery_percentage_view"
    }

    /** Represents the background highlighting of a header icons chip. */
    sealed interface ChipHighlight {
        val backgroundColor: Color
            @Composable @ReadOnlyComposable get

        val foregroundColor: Color
            @Composable @ReadOnlyComposable get

        val onHoveredBackgroundColor: Color
            @Composable @ReadOnlyComposable get

        data object Weak : ChipHighlight {
            override val backgroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.surface.copy(alpha = 0.3f)

            override val foregroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.onSurface

            override val onHoveredBackgroundColor: Color
                @Composable get() = backgroundColor
        }

        data object Strong : ChipHighlight {
            override val backgroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.secondary

            override val foregroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.onSecondary

            override val onHoveredBackgroundColor: Color
                @Composable get() = backgroundColor
        }

        data object Transparent : ChipHighlight {
            override val backgroundColor: Color
                @Composable get() = Color.Transparent

            override val foregroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.onSurface

            override val onHoveredBackgroundColor: Color
                @Composable get() = MaterialTheme.colorScheme.surface.copy(alpha = 0.3f)
        }
    }
}

/** The status bar that appears above the Shade scene on small screens. */
@@ -362,8 +316,8 @@ fun ContentScope.ExpandedShadeHeader(
@Composable
fun ContentScope.OverlayShadeHeader(
    viewModel: ShadeHeaderViewModel,
    notificationsHighlight: ShadeHeader.ChipHighlight,
    quickSettingsHighlight: ShadeHeader.ChipHighlight,
    notificationsHighlight: ChipHighlightModel,
    quickSettingsHighlight: ChipHighlightModel,
    showClock: Boolean,
    modifier: Modifier = Modifier,
) {
@@ -428,7 +382,7 @@ fun ContentScope.OverlayShadeHeader(
                        with(LocalDensity.current) {
                            (if (NewStatusBarIcons.isEnabled) 3.sp else 6.sp).toDp()
                        }
                    val isHighlighted = quickSettingsHighlight is ShadeHeader.ChipHighlight.Strong
                    val isHighlighted = quickSettingsHighlight is ChipHighlightModel.Strong
                    StatusIcons(
                        viewModel = viewModel,
                        useExpandedFormat = false,
+47 −0
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@@ -37,6 +39,51 @@ import com.android.compose.modifiers.thenIf
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingHorizontal
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingVertical

/** Represents the background and foreground colors of a ShadeHighlightChip. */
sealed interface ChipHighlightModel {
    val backgroundColor: Color
        @Composable @ReadOnlyComposable get

    val foregroundColor: Color
        @Composable @ReadOnlyComposable get

    val onHoveredBackgroundColor: Color
        @Composable @ReadOnlyComposable get

    data object Weak : ChipHighlightModel {
        override val backgroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.surface.copy(alpha = 0.3f)

        override val foregroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.onSurface

        override val onHoveredBackgroundColor: Color
            @Composable get() = backgroundColor
    }

    data object Strong : ChipHighlightModel {
        override val backgroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.secondary

        override val foregroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.onSecondary

        override val onHoveredBackgroundColor: Color
            @Composable get() = backgroundColor
    }

    data object Transparent : ChipHighlightModel {
        override val backgroundColor: Color
            @Composable get() = Color.Transparent

        override val foregroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.onSurface

        override val onHoveredBackgroundColor: Color
            @Composable get() = MaterialTheme.colorScheme.surface.copy(alpha = 0.3f)
    }
}

/** A chip with a colored highlight. Used as an entry point for the shade. */
@Composable
fun ShadeHighlightChip(
+3 −4
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import com.android.systemui.shade.data.repository.fakePrivacyChipRepository
import com.android.systemui.shade.domain.interactor.disableDualShade
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.shade.ui.composable.ShadeHeader
import com.android.systemui.shade.ui.composable.ChipHighlightModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.fakeMobileIconsInteractor
import com.android.systemui.statusbar.policy.configurationController
@@ -156,8 +156,7 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            setEnableDesktopFeatureSet(enable = true)

            assertThat(underTest.inactiveChipHighlight)
                .isEqualTo(ShadeHeader.ChipHighlight.Transparent)
            assertThat(underTest.inactiveChipHighlight).isEqualTo(ChipHighlightModel.Transparent)
        }

    @Test
@@ -165,7 +164,7 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            setEnableDesktopFeatureSet(enable = false)

            assertThat(underTest.inactiveChipHighlight).isEqualTo(ShadeHeader.ChipHighlight.Weak)
            assertThat(underTest.inactiveChipHighlight).isEqualTo(ChipHighlightModel.Weak)
        }

    @Test
Loading