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

Commit 3cee9a16 authored by Jan Lanik's avatar Jan Lanik
Browse files

No text in Privacy Indicator Chip

Allowing no text to be passed and adjusting the padding in that case for
the chip to look symmetrical.

Bug: 394074664
Test: Manual verification
Flag: com.android.systemui.expanded_privacy_indicators_on_large_screen
Change-Id: Ifb15057030f3fcebfcec9722f01d655e61240347
parent 60d3fed2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ private fun PopupChipModel.verifyShown(): PopupChipModel.Shown {
}

private fun PopupChipModel.Shown.verifyHasNoText() {
    assertThat(this.chipText).isEqualTo("")
    assertThat(this.chipText).isEqualTo(null)
}

private fun PopupChipModel.Shown.verifyHasIcon(res: Int) {
+1 −2
Original line number Diff line number Diff line
@@ -70,8 +70,7 @@ constructor(
                PopupChipModel.Shown(
                    chipId = chipId,
                    icons = icons(sensorActivityModel = sensorActivityModel),
                    // TODO(405903665): Remove text after api change
                    chipText = "",
                    chipText = null,
                    colors = ColorsModel.AvControlsTheme,
                    hoverBehavior = HoverBehavior.None,
                )
+49 −39
Original line number Diff line number Diff line
@@ -98,6 +98,10 @@ fun StatusBarPopupChip(
                )
            },
    ) {
        val text = viewModel.chipText
        // End padding should be symmetrical if the text is omitted.
        val startPadding = 4.dp
        val endPadding = if (text != null) 8.dp else startPadding
        Row(
            horizontalArrangement = Arrangement.spacedBy(4.dp),
            verticalAlignment = Alignment.CenterVertically,
@@ -115,7 +119,7 @@ fun StatusBarPopupChip(
                        shape = chipShape,
                    )
                    .indication(interactionSource, indication)
                    .padding(start = 4.dp, end = 8.dp),
                    .padding(start = startPadding, end = endPadding),
        ) {
            val hoverBehavior = viewModel.hoverBehavior
            val chipIcons =
@@ -131,7 +135,7 @@ fun StatusBarPopupChip(
                isHovered = isHovered,
            )

            val text = viewModel.chipText
            if (text != null) {
                val textStyle = MaterialTheme.typography.labelLarge
                val textMeasurer = rememberTextMeasurer()
                var textOverflow by remember { mutableStateOf(false) }
@@ -148,12 +152,17 @@ fun StatusBarPopupChip(
                    modifier =
                        Modifier.widthIn(
                                max =
                                dimensionResource(id = R.dimen.ongoing_activity_chip_max_text_width)
                                    dimensionResource(
                                        id = R.dimen.ongoing_activity_chip_max_text_width
                                    )
                            )
                            .layout { measurables, constraints ->
                                val placeable = measurables.measure(constraints)
                                val intrinsicWidth =
                                textMeasurer.measure(text, textStyle, softWrap = false).size.width
                                    textMeasurer
                                        .measure(text, textStyle, softWrap = false)
                                        .size
                                        .width
                                textOverflow = intrinsicWidth > constraints.maxWidth

                                layout(placeable.width, placeable.height) {
@@ -177,6 +186,7 @@ fun StatusBarPopupChip(
            }
        }
    }
}

@Composable
private fun ChipIcons(
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ sealed class PopupChipModel {
        override val chipId: PopupChipId,
        /** Icons shown on the chip when no specific hover behavior. */
        val icons: List<ChipIcon>,
        val chipText: String,
        val chipText: String?,
        /** Determines the colors used for the chip. Defaults to system themed colors. */
        val colors: ColorsModel = ColorsModel.SystemTheme,
        val isPopupShown: Boolean = false,