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

Commit 30cf72e2 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Allow for MR text to grow with font scaling" into main

parents c7cac003 82c8f5cd
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -33,9 +33,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
@@ -43,6 +41,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
@@ -56,11 +55,17 @@ import com.android.systemui.res.R
@Composable
fun Chip(action: ActionViewModel, modifier: Modifier = Modifier) {
    val backgroundColor = if (isSystemInDarkTheme()) Color.Black else Color.White
    val density = LocalDensity.current
    val config = LocalConfiguration.current
    val isBoldTextEnabled by remember { derivedStateOf { config.fontWeightAdjustment > 0 } }
    val isBoldTextEnabled = config.fontWeightAdjustment > 0
    val fontScale = config.fontScale
    val chipTextStyle =
        MaterialTheme.typography.labelLarge.copy(
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium,
            fontSize =
                with(density) {
                    (MaterialTheme.typography.labelLarge.fontSize.value * fontScale).dp.toSp()
                },
        )

    val haptics = LocalHapticFeedback.current
+10 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@@ -50,7 +51,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -153,10 +153,15 @@ fun NavBarPill(
            label = "expansion",
        )
    val config = LocalConfiguration.current
    val isBoldTextEnabled by remember { derivedStateOf { config.fontWeightAdjustment > 0 } }
    val isBoldTextEnabled = config.fontWeightAdjustment > 0
    val fontScale = config.fontScale
    val actionTextStyle =
        MaterialTheme.typography.labelMedium.copy(
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium,
            fontSize =
                with(density) {
                    (MaterialTheme.typography.labelMedium.fontSize.value * fontScale).dp.toSp()
                },
        )

    Column(
@@ -267,7 +272,8 @@ fun NavBarPill(
                                                    Color.Transparent
                                                }
                                            )
                                            .padding(4.dp),
                                            .height(28.dp)
                                            .padding(start = 6.dp, end = 6.dp),
                                ) {
                                    Image(
                                        painter = rememberDrawablePainter(action.icon.drawable),
+8 −2
Original line number Diff line number Diff line
@@ -142,11 +142,17 @@ fun ShortPill(
    var pillContentSize by remember { mutableStateOf(IntSize.Zero) }
    var pillContentPosition by remember { mutableStateOf(Offset.Zero) }

    val density = LocalDensity.current
    val config = LocalConfiguration.current
    val isBoldTextEnabled by remember { derivedStateOf { config.fontWeightAdjustment > 0 } }
    val fontScale = config.fontScale
    val actionTextStyle =
        MaterialTheme.typography.labelMedium.copy(
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium
            fontWeight = if (isBoldTextEnabled) FontWeight.Bold else FontWeight.Medium,
            fontSize =
                with(density) {
                    (MaterialTheme.typography.labelMedium.fontSize.value * fontScale).dp.toSp()
                },
        )

    Box(
@@ -260,7 +266,7 @@ fun ShortPill(

        // The layout for the expanded state (a single, centered button)
        if (expansionAlpha < 1f && pillContentSize != IntSize.Zero) {
            with(LocalDensity.current) {
            with(density) {
                val offsetX =
                    pillContentPosition.x.toDp() + (pillContentSize.width.toDp() / 2) -
                        (closeButtonSize / 2)