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

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

Merge "Implement new typography for QS surfaces" into main

parents fdf2e8bc d8201006
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
@@ -81,6 +82,7 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.compose.Icon
import com.android.systemui.common.ui.compose.Icon
import com.android.systemui.compose.modifiers.sysuiResTag
import com.android.systemui.compose.modifiers.sysuiResTag
import com.android.systemui.qs.flags.QSComposeFragment
import com.android.systemui.qs.flags.QSComposeFragment
import com.android.systemui.qs.flags.QsInCompose
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsButtonViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsButtonViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsForegroundServicesButtonViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsForegroundServicesButtonViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsSecurityButtonViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsSecurityButtonViewModel
@@ -388,6 +390,7 @@ private fun NewChangesDot(modifier: Modifier = Modifier) {
}
}


/** A larger button with an icon, some text and an optional dot (to indicate new changes). */
/** A larger button with an icon, some text and an optional dot (to indicate new changes). */
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
private fun TextButton(
private fun TextButton(
    icon: Icon,
    icon: Icon,
@@ -422,10 +425,13 @@ private fun TextButton(
            Text(
            Text(
                text,
                text,
                Modifier.weight(1f),
                Modifier.weight(1f),
                style = MaterialTheme.typography.bodyMedium,
                style =
                // TODO(b/242040009): Remove this letter spacing. We should only use the M3 text
                    if (QsInCompose.isEnabled) {
                // styles without modifying them.
                        MaterialTheme.typography.labelLarge
                letterSpacing = 0.01.em,
                    } else {
                        MaterialTheme.typography.bodyMedium
                    },
                letterSpacing = if (QsInCompose.isEnabled) 0.em else 0.01.em,
                color = colorAttr(R.attr.onShadeInactiveVariant),
                color = colorAttr(R.attr.onShadeInactiveVariant),
                maxLines = 1,
                maxLines = 1,
                overflow = TextOverflow.Ellipsis,
                overflow = TextOverflow.Ellipsis,
+3 −0
Original line number Original line Diff line number Diff line
@@ -2560,6 +2560,9 @@
    <!-- Button to edit the tile ordering of quick settings [CHAR LIMIT=60] -->
    <!-- Button to edit the tile ordering of quick settings [CHAR LIMIT=60] -->
    <string name="qs_edit">Edit</string>
    <string name="qs_edit">Edit</string>


    <!-- Title for QS Edit mode screen [CHAR LIMIT=30] -->
    <string name="qs_edit_tiles">Edit tiles</string>

    <!-- SysUI Tuner: Options for how clock is displayed [CHAR LIMIT=NONE] -->
    <!-- SysUI Tuner: Options for how clock is displayed [CHAR LIMIT=NONE] -->
    <string name="tuner_time">Time</string>
    <string name="tuner_time">Time</string>


+4 −2
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicText
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.DisposableEffect
@@ -173,6 +174,7 @@ fun LargeTileContent(
    }
    }
}
}


@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
fun LargeTileLabels(
fun LargeTileLabels(
    label: String,
    label: String,
@@ -188,7 +190,7 @@ fun LargeTileLabels(
    Column(verticalArrangement = Arrangement.Center, modifier = modifier.fillMaxHeight()) {
    Column(verticalArrangement = Arrangement.Center, modifier = modifier.fillMaxHeight()) {
        TileLabel(
        TileLabel(
            text = label,
            text = label,
            style = MaterialTheme.typography.labelLarge,
            style = MaterialTheme.typography.titleSmallEmphasized,
            color = { animatedLabelColor },
            color = { animatedLabelColor },
            isVisible = isVisible,
            isVisible = isVisible,
        )
        )
@@ -196,7 +198,7 @@ fun LargeTileLabels(
            TileLabel(
            TileLabel(
                secondaryLabel ?: "",
                secondaryLabel ?: "",
                color = { animatedSecondaryLabelColor },
                color = { animatedSecondaryLabelColor },
                style = MaterialTheme.typography.bodyMedium,
                style = MaterialTheme.typography.labelMedium,
                isVisible = isVisible,
                isVisible = isVisible,
                modifier =
                modifier =
                    Modifier.thenIf(
                    Modifier.thenIf(
+22 −6
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalContentColor
@@ -109,11 +110,11 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.text.style.Hyphens
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastMap
import androidx.compose.ui.util.fastMap
import com.android.compose.gesture.effect.rememberOffsetOverscrollEffectFactory
import com.android.compose.gesture.effect.rememberOffsetOverscrollEffectFactory
import com.android.compose.modifiers.height
import com.android.compose.modifiers.height
@@ -165,7 +166,7 @@ import kotlinx.coroutines.launch


object TileType
object TileType


@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
private fun EditModeTopBar(onStopEditing: () -> Unit, onReset: (() -> Unit)?) {
private fun EditModeTopBar(onStopEditing: () -> Unit, onReset: (() -> Unit)?) {
    val primaryContainerColor = MaterialTheme.colorScheme.primaryContainer
    val primaryContainerColor = MaterialTheme.colorScheme.primaryContainer
@@ -177,7 +178,8 @@ private fun EditModeTopBar(onStopEditing: () -> Unit, onReset: (() -> Unit)?) {
            ),
            ),
        title = {
        title = {
            Text(
            Text(
                text = stringResource(id = R.string.qs_edit),
                text = stringResource(id = R.string.qs_edit_tiles),
                style = MaterialTheme.typography.titleLargeEmphasized,
                modifier = Modifier.padding(start = 24.dp),
                modifier = Modifier.padding(start = 24.dp),
            )
            )
        },
        },
@@ -204,7 +206,10 @@ private fun EditModeTopBar(onStopEditing: () -> Unit, onReset: (() -> Unit)?) {
                            contentColor = MaterialTheme.colorScheme.onPrimary,
                            contentColor = MaterialTheme.colorScheme.onPrimary,
                        ),
                        ),
                ) {
                ) {
                    Text(stringResource(id = com.android.internal.R.string.reset))
                    Text(
                        text = stringResource(id = com.android.internal.R.string.reset),
                        style = MaterialTheme.typography.labelLarge,
                    )
                }
                }
            }
            }
        },
        },
@@ -212,6 +217,7 @@ private fun EditModeTopBar(onStopEditing: () -> Unit, onReset: (() -> Unit)?) {
    )
    )
}
}


@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
fun DefaultEditTileGrid(
fun DefaultEditTileGrid(
    listState: EditTileListState,
    listState: EditTileListState,
@@ -283,7 +289,9 @@ fun DefaultEditTileGrid(
                                }
                                }
                            }
                            }
                        } else {
                        } else {
                            Text(text = stringResource(id = R.string.drag_to_rearrange_tiles))
                            EditGridCenteredText(
                                text = stringResource(id = R.string.drag_to_rearrange_tiles)
                            )
                        }
                        }
                    }
                    }
                }
                }
@@ -400,6 +408,11 @@ private fun EditGridHeader(
    }
    }
}
}


@Composable
private fun EditGridCenteredText(text: String, modifier: Modifier = Modifier) {
    Text(text = text, style = MaterialTheme.typography.titleSmall, modifier = modifier)
}

@Composable
@Composable
private fun RemoveTileTarget(onClick: () -> Unit) {
private fun RemoveTileTarget(onClick: () -> Unit) {
    Row(
    Row(
@@ -486,6 +499,7 @@ private fun CurrentTilesGrid(
    }
    }
}
}


@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
private fun AvailableTileGrid(
private fun AvailableTileGrid(
    tiles: List<AvailableTileGridCell>,
    tiles: List<AvailableTileGridCell>,
@@ -524,7 +538,7 @@ private fun AvailableTileGrid(
                ) {
                ) {
                    Text(
                    Text(
                        text = category.label.load() ?: "",
                        text = category.label.load() ?: "",
                        fontSize = 20.sp,
                        style = MaterialTheme.typography.titleMediumEmphasized,
                        color = MaterialTheme.colorScheme.onSurface,
                        color = MaterialTheme.colorScheme.onSurface,
                        modifier = Modifier.fillMaxWidth().padding(start = 8.dp, bottom = 16.dp),
                        modifier = Modifier.fillMaxWidth().padding(start = 8.dp, bottom = 16.dp),
                    )
                    )
@@ -737,6 +751,7 @@ private fun TileGridCell(
    }
    }
}
}


@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
@Composable
private fun AvailableTileGridCell(
private fun AvailableTileGridCell(
    cell: AvailableTileGridCell,
    cell: AvailableTileGridCell,
@@ -803,6 +818,7 @@ private fun AvailableTileGridCell(
                color = colors.label,
                color = colors.label,
                overflow = TextOverflow.Ellipsis,
                overflow = TextOverflow.Ellipsis,
                textAlign = TextAlign.Center,
                textAlign = TextAlign.Center,
                style = MaterialTheme.typography.labelMedium.copy(hyphens = Hyphens.Auto),
                modifier = Modifier.align(Alignment.TopCenter),
                modifier = Modifier.align(Alignment.TopCenter),
            )
            )
        }
        }