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

Commit fb293b51 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ic25a4c32,If90c1cca into main

* changes:
  [Dual Shade] Open the clock app when clicking on the notifications chip.
  [Dual Shade] Include the shade header clock in the highlight chip.
parents 2707f6be 5cee9fa5
Loading
Loading
Loading
Loading
+39 −54
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
@@ -55,6 +54,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
@@ -230,8 +230,12 @@ fun ContentScope.CollapsedShadeHeader(
                    if (isSplitShade) {
                        ShadeCarrierGroup(viewModel = viewModel)
                    }
                    SystemIconChip(
                        onClick = viewModel::onSystemIconChipClicked.takeIf { isSplitShade }
                    HighlightChip(
                        onClick = {
                            if (isSplitShade) {
                                viewModel.onSystemIconChipClicked()
                            }
                        }
                    ) {
                        val paddingEnd =
                            with(LocalDensity.current) {
@@ -309,7 +313,7 @@ fun ContentScope.ExpandedShadeHeader(
                    textColor = colorAttr(android.R.attr.textColorPrimary),
                    modifier = Modifier.widthIn(max = 90.dp),
                )
                SystemIconChip {
                HighlightChip {
                    val paddingEnd =
                        with(LocalDensity.current) {
                            (if (NewStatusBarIcons.isEnabled) 3.sp else 6.sp).toDp()
@@ -350,22 +354,14 @@ fun ContentScope.OverlayShadeHeader(
    CutoutAwareShadeHeader(
        modifier = modifier,
        startContent = {
            Row(
                verticalAlignment = Alignment.CenterVertically,
            Box(modifier = Modifier.padding(horizontal = horizontalPadding)) {
                HighlightChip(
                    backgroundColor = notificationsHighlight.backgroundColor,
                    horizontalArrangement = Arrangement.spacedBy(5.dp),
                modifier = Modifier.padding(horizontal = horizontalPadding),
            ) {
                if (showClock) {
                    Clock(
                        onClick = viewModel::onClockClicked,
                        modifier = Modifier.padding(horizontal = 4.dp),
                    )
                }
                NotificationsChip(
                    onClick = viewModel::onNotificationIconChipClicked,
                    backgroundColor = notificationsHighlight.backgroundColor,
                    modifier =
                        Modifier.bouncy(
                        Modifier.align(Alignment.CenterStart)
                            .bouncy(
                                isEnabled = viewModel.animateNotificationsChipBounce,
                                onBoundsChange = { bounds ->
                                    viewModel.onDualShadeEducationElementBoundsChange(
@@ -375,6 +371,9 @@ fun ContentScope.OverlayShadeHeader(
                                },
                            ),
                ) {
                    if (showClock) {
                        Clock(textColor = notificationsHighlight.foregroundColor)
                    }
                    VariableDayDate(
                        longerDateText = viewModel.longerDateText,
                        shorterDateText = viewModel.shorterDateText,
@@ -389,7 +388,7 @@ fun ContentScope.OverlayShadeHeader(
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(horizontal = horizontalPadding),
            ) {
                SystemIconChip(
                HighlightChip(
                    backgroundColor = quickSettingsHighlight.backgroundColor,
                    onClick = viewModel::onSystemIconChipClicked,
                    modifier =
@@ -506,9 +505,10 @@ private fun CutoutAwareShadeHeader(

@Composable
private fun ContentScope.Clock(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    onClick: (() -> Unit)? = null,
    scale: Float = 1f,
    textColor: Color? = null,
) {
    val layoutDirection = LocalLayoutDirection.current

@@ -523,6 +523,7 @@ private fun ContentScope.Clock(
                        null,
                    )
                },
                update = { view -> textColor?.let { view.setTextColor(it.toArgb()) } },
                modifier =
                    modifier
                        // use graphicsLayer instead of Modifier.scale to anchor transform to the
@@ -539,7 +540,7 @@ private fun ContentScope.Clock(
                                    0.5f,
                                )
                        }
                        .clickable { onClick() },
                        .thenIf(onClick != null) { Modifier.clickable { onClick?.invoke() } },
            )
        }
    }
@@ -777,41 +778,25 @@ private fun ContentScope.StatusIcons(
}

@Composable
private fun NotificationsChip(
    onClick: () -> Unit,
private fun HighlightChip(
    modifier: Modifier = Modifier,
    backgroundColor: Color,
    content: @Composable BoxScope.() -> Unit,
    backgroundColor: Color = Color.Unspecified,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    onClick: () -> Unit = {},
    content: @Composable RowScope.() -> Unit,
) {
    val interactionSource = remember { MutableInteractionSource() }
    Box(
    Row(
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = horizontalArrangement,
        modifier =
            modifier
                .clip(RoundedCornerShape(25.dp))
                .clickable(
                    interactionSource = interactionSource,
                    indication = null,
                    onClick = onClick,
                )
                .background(backgroundColor, RoundedCornerShape(25.dp))
                .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
    ) {
        content()
    }
}

@Composable
private fun SystemIconChip(
    modifier: Modifier = Modifier,
    backgroundColor: Color = Color.Unspecified,
    onClick: (() -> Unit)? = null,
    content: @Composable RowScope.() -> Unit,
) {
    Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier =
            modifier
                .clip(RoundedCornerShape(25.dp))
                .thenIf(onClick != null) { Modifier.clickable(onClick = { onClick?.invoke() }) }
                .thenIf(backgroundColor != Color.Unspecified) {
                    Modifier.background(backgroundColor)
                        .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
+14 −2
Original line number Diff line number Diff line
@@ -181,9 +181,10 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {
        }

    @Test
    fun onNotificationIconChipClicked_lockedOnNotifShade_collapsesShadeToLockscreen() =
    fun onNotificationIconChipClicked_lockedOnNotifShade_collapsesShadeToLockscreen_opensClock() =
        testScope.runTest {
            setupDualShadeState(scene = Scenes.Lockscreen, overlay = Overlays.NotificationsShade)
            val activityStarter = kosmos.activityStarter
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)

@@ -191,6 +192,11 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {

            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(currentOverlays).isEmpty()
            verify(activityStarter)
                .postStartActivityDismissingKeyguard(
                    argThat(IntentMatcherAction(AlarmClock.ACTION_SHOW_ALARMS)),
                    anyInt(),
                )
        }

    @Test
@@ -208,9 +214,10 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {
        }

    @Test
    fun onNotificationIconChipClicked_unlockedOnNotifShade_collapsesShadeToGone() =
    fun onNotificationIconChipClicked_unlockedOnNotifShade_collapsesShadeToGone_opensClock() =
        testScope.runTest {
            setupDualShadeState(scene = Scenes.Gone, overlay = Overlays.NotificationsShade)
            val activityStarter = kosmos.activityStarter
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)

@@ -218,6 +225,11 @@ class ShadeHeaderViewModelTest : SysuiTestCase() {

            assertThat(currentScene).isEqualTo(Scenes.Gone)
            assertThat(currentOverlays).isEmpty()
            verify(activityStarter)
                .postStartActivityDismissingKeyguard(
                    argThat(IntentMatcherAction(AlarmClock.ACTION_SHOW_ALARMS)),
                    anyInt(),
                )
        }

    @Test
+2 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ constructor(
        clockInteractor.launchClockActivity()
    }

    /** Notifies that the system icons container was clicked. */
    /** Notifies that the notification icons container was clicked. */
    fun onNotificationIconChipClicked() {
        if (!shadeModeInteractor.isDualShade) {
            return
@@ -222,6 +222,7 @@ constructor(
                loggingReason = loggingReason,
                transitionKey = SlightlyFasterShadeCollapse,
            )
            onClockClicked()
        } else {
            shadeInteractor.expandNotificationsShade(loggingReason)
        }