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

Commit bc142e0a authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes Ib374e71d,I2ac1e1ad into main

* changes:
  [SB][Chips] Add simple fade in / fade out animations to chips.
  [SB][Chips] Align 3-2-1 countdown within the center of the chip.
parents 4d60bc1d 8158e4fd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.text.TextMeasurer
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
@@ -114,6 +115,7 @@ fun ChipContent(
                style = textStyle,
                color = textColor,
                softWrap = false,
                textAlign = TextAlign.Center,
                modifier = modifier.neverDecreaseWidth(density),
            )
        }
+39 −14
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.systemui.statusbar.chips.ui.compose

import android.graphics.RectF
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
@@ -60,8 +63,9 @@ fun OngoingActivityChips(
        }
    }

    val shownChips = chips.active.filter { !it.isHidden }
    if (shownChips.isNotEmpty()) {
    val activeChips = chips.active
    if (activeChips.isNotEmpty()) {
        // For performance reasons, only create the Row if we have chips. See b/401241197.
        Row(
            // The status bar clock will have some end padding so we don't need as much padding
            // at the beginning of the row (but we need more padding between chips)
@@ -69,20 +73,41 @@ fun OngoingActivityChips(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.spacedBy(8.dp),
        ) {
            shownChips.forEach {
            activeChips.forEach {
                key(it.key) {
                    OngoingActivityChip(
                        model = it,
                        iconViewStore = iconViewStore,
                        modifier =
                    val chipModifier =
                        Modifier.sysuiResTag(it.key).onGloballyPositioned { coordinates ->
                            onChipBoundsChanged.invoke(
                                it.key,
                                coordinates.boundsInWindow().toAndroidRectF(),
                            )
                            },
                        }
                    if (activeChips.size == 1) {
                        // AnimatedVisibility works well if we have just 1 active chip, but it
                        // causes some problems if there's 2 chips and then one chip becomes hidden.
                        // For now, use AnimatedVisibility only if we only have 1 active chip. See
                        // b/393581408.
                        AnimatedVisibility(
                            visible = !it.isHidden,
                            enter = fadeIn(),
                            exit = fadeOut(),
                        ) {
                            OngoingActivityChip(
                                model = it,
                                iconViewStore = iconViewStore,
                                modifier = chipModifier,
                            )
                        }
                    } else {
                        if (!it.isHidden) {
                            OngoingActivityChip(
                                model = it,
                                iconViewStore = iconViewStore,
                                modifier = chipModifier,
                            )
                        }
                    }
                }
            }
        }
    }