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

Commit 59327e81 authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Merge "Only apply text marquee to tiles with label overflow" into main

parents 5cd619c4 23bab1dd
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -82,6 +82,7 @@ fun ContentScope.QuickQuickSettings(
                        viewModel.tileHapticsViewModelFactoryProvider,
                        viewModel.tileHapticsViewModelFactoryProvider,
                    // There should be no QuickQuickSettings when the details view is enabled.
                    // There should be no QuickQuickSettings when the details view is enabled.
                    detailsViewModel = null,
                    detailsViewModel = null,
                    isVisible = listening,
                )
                )
            }
            }
        }
        }
+38 −18
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.setValue
@@ -102,6 +103,7 @@ fun LargeTileContent(
    sideDrawable: Drawable?,
    sideDrawable: Drawable?,
    colors: TileColors,
    colors: TileColors,
    squishiness: () -> Float,
    squishiness: () -> Float,
    isVisible: () -> Boolean = { true },
    accessibilityUiState: AccessibilityUiState? = null,
    accessibilityUiState: AccessibilityUiState? = null,
    iconShape: RoundedCornerShape = RoundedCornerShape(CommonTileDefaults.InactiveCornerRadius),
    iconShape: RoundedCornerShape = RoundedCornerShape(CommonTileDefaults.InactiveCornerRadius),
    toggleClick: (() -> Unit)? = null,
    toggleClick: (() -> Unit)? = null,
@@ -158,6 +160,7 @@ fun LargeTileContent(
            secondaryLabel = secondaryLabel,
            secondaryLabel = secondaryLabel,
            colors = colors,
            colors = colors,
            accessibilityUiState = accessibilityUiState,
            accessibilityUiState = accessibilityUiState,
            isVisible = isVisible,
        )
        )


        if (sideDrawable != null) {
        if (sideDrawable != null) {
@@ -176,6 +179,7 @@ fun LargeTileLabels(
    secondaryLabel: String?,
    secondaryLabel: String?,
    colors: TileColors,
    colors: TileColors,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
    isVisible: () -> Boolean = { true },
    accessibilityUiState: AccessibilityUiState? = null,
    accessibilityUiState: AccessibilityUiState? = null,
) {
) {
    val animatedLabelColor by animateColorAsState(colors.label, label = "QSTileLabelColor")
    val animatedLabelColor by animateColorAsState(colors.label, label = "QSTileLabelColor")
@@ -186,12 +190,14 @@ fun LargeTileLabels(
            text = label,
            text = label,
            style = MaterialTheme.typography.labelLarge,
            style = MaterialTheme.typography.labelLarge,
            color = { animatedLabelColor },
            color = { animatedLabelColor },
            isVisible = isVisible,
        )
        )
        if (!TextUtils.isEmpty(secondaryLabel)) {
        if (!TextUtils.isEmpty(secondaryLabel)) {
            TileLabel(
            TileLabel(
                secondaryLabel ?: "",
                secondaryLabel ?: "",
                color = { animatedSecondaryLabelColor },
                color = { animatedSecondaryLabelColor },
                style = MaterialTheme.typography.bodyMedium,
                style = MaterialTheme.typography.bodyMedium,
                isVisible = isVisible,
                modifier =
                modifier =
                    Modifier.thenIf(
                    Modifier.thenIf(
                        accessibilityUiState?.stateDescription?.contains(secondaryLabel ?: "") ==
                        accessibilityUiState?.stateDescription?.contains(secondaryLabel ?: "") ==
@@ -277,18 +283,27 @@ private fun TileLabel(
    color: ColorProducer,
    color: ColorProducer,
    style: TextStyle,
    style: TextStyle,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
    isVisible: () -> Boolean = { true },
) {
) {
    var textSize by remember { mutableIntStateOf(0) }

    BasicText(
    BasicText(
        text = text,
        text = text,
        color = color,
        color = color,
        style = style,
        style = style,
        maxLines = 1,
        maxLines = 1,
        onTextLayout = { textSize = it.size.width },
        modifier =
        modifier =
            modifier
            modifier
                .fillMaxWidth()
                .fillMaxWidth()
                .graphicsLayer { compositingStrategy = CompositingStrategy.Offscreen }
                .graphicsLayer {
                    if (textSize > size.width) {
                        compositingStrategy = CompositingStrategy.Offscreen
                    }
                }
                .drawWithContent {
                .drawWithContent {
                    drawContent()
                    drawContent()
                    if (textSize > size.width) {
                        // Draw a blur over the end of the text
                        // Draw a blur over the end of the text
                        val edgeWidthPx = TileLabelBlurWidth.toPx()
                        val edgeWidthPx = TileLabelBlurWidth.toPx()
                        drawRect(
                        drawRect(
@@ -303,10 +318,15 @@ private fun TileLabel(
                            blendMode = BlendMode.DstIn,
                            blendMode = BlendMode.DstIn,
                        )
                        )
                    }
                    }
                .basicMarquee(
                }
                .thenIf(isVisible()) {
                    // Only apply the marquee when the label is visible, which is needed for the
                    // always composed QS
                    Modifier.basicMarquee(
                        iterations = TILE_MARQUEE_ITERATIONS,
                        iterations = TILE_MARQUEE_ITERATIONS,
                        initialDelayMillis = TILE_INITIAL_DELAY_MILLIS,
                        initialDelayMillis = TILE_INITIAL_DELAY_MILLIS,
                ),
                    )
                },
    )
    )
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -119,6 +119,7 @@ constructor(
                            isLastInRow = isLastInColumn,
                            isLastInRow = isLastInColumn,
                        ),
                        ),
                    detailsViewModel = detailsViewModel,
                    detailsViewModel = detailsViewModel,
                    isVisible = listening,
                )
                )
            }
            }
        }
        }
+2 −0
Original line number Original line Diff line number Diff line
@@ -139,6 +139,7 @@ fun Tile(
    bounceableInfo: BounceableInfo,
    bounceableInfo: BounceableInfo,
    tileHapticsViewModelFactoryProvider: TileHapticsViewModelFactoryProvider,
    tileHapticsViewModelFactoryProvider: TileHapticsViewModelFactoryProvider,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
    isVisible: () -> Boolean = { true },
    detailsViewModel: DetailsViewModel?,
    detailsViewModel: DetailsViewModel?,
) {
) {
    trace(tile.traceName) {
    trace(tile.traceName) {
@@ -249,6 +250,7 @@ fun Tile(
                        onLongClick = longClick,
                        onLongClick = longClick,
                        accessibilityUiState = uiState.accessibilityUiState,
                        accessibilityUiState = uiState.accessibilityUiState,
                        squishiness = squishiness,
                        squishiness = squishiness,
                        isVisible = isVisible,
                    )
                    )
                }
                }
            }
            }