diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/ImportThemeSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/ImportThemeSettingsScreen.kt index dca1f03f7..6ef1fd6f8 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/ImportThemeSettingsScreen.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/ImportThemeSettingsScreen.kt @@ -59,7 +59,6 @@ import de.mm20.launcher2.ui.component.preferences.PreferenceScreen import de.mm20.launcher2.ui.component.preferences.SwitchPreference import de.mm20.launcher2.ui.locals.LocalDarkTheme import de.mm20.launcher2.ui.settings.transparencies.checkerboard -import de.mm20.launcher2.ui.settings.typography.PreviewTexts import de.mm20.launcher2.ui.theme.colorscheme.darkColorSchemeOf import de.mm20.launcher2.ui.theme.colorscheme.lightColorSchemeOf import de.mm20.launcher2.ui.theme.shapes.shapesOf @@ -250,7 +249,6 @@ private fun ThemePreview( darkMode: Boolean, onDarkModeChanged: (Boolean) -> Unit, ) { - val previewTexts = PreviewTexts() Column( modifier = Modifier .fillMaxWidth() @@ -311,17 +309,17 @@ private fun ThemePreview( modifier = Modifier.fillMaxWidth(), ) { Text( - previewTexts.Medium1, + stringResource(R.string.typo_preview_medium1), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onSurface, ) Text( - previewTexts.Medium2, + stringResource(R.string.typo_preview_medium2), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.secondary ) Text( - previewTexts.TwoLines, + stringResource(R.string.typo_preview_long), style = MaterialTheme.typography.bodyMedium, modifier = Modifier.padding(top = 4.dp), color = MaterialTheme.colorScheme.onSurface, @@ -336,7 +334,7 @@ private fun ThemePreview( ) { FilterChip( selected = true, - label = { Text(previewTexts.Short1) }, + label = { Text(stringResource(R.string.typo_preview_short1)) }, leadingIcon = { Icon( painterResource(R.drawable.star_20px), null, @@ -347,7 +345,7 @@ private fun ThemePreview( ) FilterChip( selected = false, - label = { Text(previewTexts.Short2) }, + label = { Text(stringResource(R.string.typo_preview_short2)) }, leadingIcon = { Icon( painterResource(R.drawable.star_20px), null, @@ -368,8 +366,8 @@ private fun ThemePreview( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End), ) { - Button(onClick = {}) { Text(previewTexts.Medium1) } - OutlinedButton(onClick = {}) { Text(previewTexts.Medium2) } + Button(onClick = {}) { Text(stringResource(R.string.typo_preview_medium1)) } + OutlinedButton(onClick = {}) { Text(stringResource(R.string.typo_preview_medium2)) } } } Box( diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/PreviewTexts.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/PreviewTexts.kt deleted file mode 100644 index 9e69ef66c..000000000 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/PreviewTexts.kt +++ /dev/null @@ -1,88 +0,0 @@ -package de.mm20.launcher2.ui.settings.typography - -import android.icu.util.ULocale - -/** - * Preview texts to demonstrate typography settings in the users dominant script. - * Preview texts should be similar in length, and they should be language-neutral, and not use - * letters that are used only in some languages. - */ -interface PreviewTexts { - /** - * Preview for the font. Should be a character that is representative for a font. - */ - val ExtraShort: String - - /** - * A short, 3-letter preview. - */ - val Short1: String - - /** - * An alternative to [Short1], also 3 letters. - */ - val Short2: String - /** - * A medium-length preview, 5-6 letters. - */ - val Medium1: String - /** - * An alternative to [Medium1], also 5-6 letters. - */ - val Medium2: String - /** - * A longer preview, to demonstrate line height. - * Should contain letters and numbers, and a newline. - */ - val TwoLines: String - - companion object { - operator fun invoke(): PreviewTexts { - val script = ULocale.addLikelySubtags(ULocale.getDefault()).script - return forScript(script) - } - - /** - * Returns the appropriate [PreviewTexts] implementation based on the script. - * Defaults to [LatinPreviewTexts] if the script is not recognized. - * @param script the ISO-15924 script code - */ - fun forScript(script: String): PreviewTexts { - return when (script) { - "Latn" -> LatinPreviewTexts - "Cyrl" -> CyrillicPreviewTexts - "Grek" -> GreekPreviewTexts - else -> LatinPreviewTexts - } - } - } -} - -object LatinPreviewTexts: PreviewTexts { - override val ExtraShort: String = "Aa" - override val Short1: String = "Abc" - override val Short2: String = "Deg" - override val Medium1: String = "Abcdeg" - override val Medium2: String = "Hilmno" - override val TwoLines: String = "Abcdeghilm Nop\nRst 123456890" -} - -object CyrillicPreviewTexts: PreviewTexts { - override val ExtraShort: String = "Аа" - override val Short1: String = "Абв" - override val Short2: String = "Где" - override val Medium1: String = "Абвгде" - override val Medium2: String = "Жзиклм" - override val TwoLines: String = "Абвгдежзик Лмн\nОпр 1234567890" -} - -object GreekPreviewTexts: PreviewTexts { - override val ExtraShort: String = "Αα" - override val Short1: String = "Αβγ" - override val Short2: String = "Δεζ" - override val Medium1: String = "Αβγδεζ" - override val Medium2: String = "Ηθικλμ" - override val TwoLines: String = "Αβγδεζηθ Ικλμ\nΝξο 1234567890" -} - - diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt index fd011ea7d..2e10ebaeb 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographiesSettingsScreen.kt @@ -256,19 +256,17 @@ fun TypographiesSettingsScreen() { @Composable private fun TypographyPreview(typography: androidx.compose.material3.Typography) { - val previewTexts = PreviewTexts() - Column( modifier = Modifier.padding(vertical = 12.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { Text( - text = previewTexts.Short1, + text = stringResource(R.string.typo_preview_short1), style = typography.titleSmall, ) Text( - text = previewTexts.Short2, + text = stringResource(R.string.typo_preview_short2), style = typography.bodySmall, color = MaterialTheme.colorScheme.secondary, ) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreen.kt index 9a0611b94..6a2b294ab 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreen.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/typography/TypographySettingsScreen.kt @@ -104,7 +104,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) { viewModel.getTypography(themeId) }.collectAsStateWithLifecycle(null) val previewTypography = theme?.let { typographyOf(it) } - val previewTexts = PreviewTexts() var editName by remember { mutableStateOf(false) } @@ -167,7 +166,7 @@ fun TypographySettingsScreen(themeId: UUID) { } item { PreferenceCategory("Body") { - TypographyPreview(previewTypography, previewTexts) { + TypographyPreview(previewTypography) { Column( horizontalAlignment = Alignment.CenterHorizontally ) { @@ -176,7 +175,7 @@ fun TypographySettingsScreen(themeId: UUID) { modifier = Modifier.padding(bottom = 8.dp), ) Text( - previewTexts.Medium1, + stringResource(R.string.typo_preview_medium1), textAlign = TextAlign.Center, style = MaterialTheme.typography.bodySmall ) @@ -195,7 +194,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Body Medium", @@ -210,7 +208,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Body Large", @@ -225,7 +222,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Body Small Emphasized", @@ -242,7 +238,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Body Medium Emphasized", @@ -259,7 +254,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Body Large Emphasized", @@ -276,20 +270,17 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) } } item { PreferenceCategory("Label") { - TypographyPreview(previewTypography, previewTexts) { + TypographyPreview(previewTypography) { FilterChip( modifier = Modifier .padding(end = 16.dp), label = { - Text( - previewTexts.Short1 - ) + Text(stringResource(R.string.typo_preview_short1)) }, leadingIcon = { Icon( @@ -302,7 +293,7 @@ fun TypographySettingsScreen(themeId: UUID) { onClick = {}, ) Button(onClick = {}) { - Text(previewTexts.Medium2) + Text(stringResource(R.string.typo_preview_medium2)) } } TextStylePreference( @@ -318,7 +309,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Label Medium", @@ -333,7 +323,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Label Large", @@ -348,7 +337,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Label Small Emphasized", @@ -365,7 +353,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Label Medium Emphasized", @@ -382,7 +369,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Label Large Emphasized", @@ -399,17 +385,16 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) } } item { PreferenceCategory("Title") { - TypographyPreview(previewTypography, previewTexts) { + TypographyPreview(previewTypography) { PrimaryTabRow(0, modifier = Modifier.width(300.dp)) { LeadingIconTab( selected = true, - text = { Text(previewTexts.Short1) }, + text = { Text(stringResource(R.string.typo_preview_short1)) }, icon = { Icon( painterResource(R.drawable.person_24px_filled), @@ -420,7 +405,7 @@ fun TypographySettingsScreen(themeId: UUID) { ) LeadingIconTab( selected = false, - text = { Text(previewTexts.Short2) }, + text = { Text(stringResource(R.string.typo_preview_short2)) }, icon = { Icon( painterResource(R.drawable.enterprise_24px), @@ -444,7 +429,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Title Medium", @@ -459,7 +443,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Title Large", @@ -474,7 +457,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Title Small Emphasized", @@ -491,7 +473,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Title Medium Emphasized", @@ -508,7 +489,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Title Large Emphasized", @@ -525,7 +505,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) } } @@ -544,7 +523,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Headline Medium", @@ -559,7 +537,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Headline Large", @@ -574,7 +551,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Headline Small Emphasized", @@ -592,7 +568,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Headline Medium Emphasized", @@ -610,7 +585,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Headline Large Emphasized", @@ -628,7 +602,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) } } @@ -647,7 +620,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Display Medium", @@ -662,7 +634,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Display Large", @@ -677,7 +648,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Display Small Emphasized", @@ -695,7 +665,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Display Medium Emphasized", @@ -713,7 +682,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) TextStylePreference( title = "Display Large Emphasized", @@ -731,7 +699,6 @@ fun TypographySettingsScreen(themeId: UUID) { ) ) }, - previewTexts = previewTexts, ) } } @@ -744,7 +711,6 @@ private fun FontPreference( value: ThemeFontFamily?, onValueChange: (ThemeFontFamily?) -> Unit = {}, ) { - val preview = PreviewTexts() val context = LocalContext.current val fontManager = FontManager(context) @@ -774,7 +740,7 @@ private fun FontPreference( summary = getFontName(context, value), icon = { Text( - text = preview.ExtraShort, + text = stringResource(R.string.typo_preview_extra_short), style = TextStyle( fontFamily = remember(value) { fontFamilyOf(context, value) }, fontWeight = FontWeight.Normal, @@ -822,7 +788,7 @@ private fun FontPreference( if (fonts.builtIn.isNotEmpty()) { item { FontPickerCategory( - preview.ExtraShort, + stringResource(R.string.typo_preview_extra_short), null, fonts.builtIn, onFontClick = { @@ -834,7 +800,7 @@ private fun FontPreference( if (fonts.deviceDefault.isNotEmpty()) { item { FontPickerCategory( - preview.ExtraShort, + stringResource(R.string.typo_preview_extra_short), stringResource(R.string.font_category_device_default), fonts.deviceDefault, onFontClick = { @@ -846,7 +812,7 @@ private fun FontPreference( if (fonts.generic.isNotEmpty()) { item { FontPickerCategory( - preview.ExtraShort, + stringResource(R.string.typo_preview_extra_short), stringResource(R.string.font_category_generic), fonts.generic, onFontClick = { @@ -880,7 +846,7 @@ private fun FontPreference( ) { Text( modifier = Modifier.fillMaxWidth(), - text = preview.TwoLines, + text = stringResource(R.string.typo_preview_long), textAlign = TextAlign.Center, color = MaterialTheme.colorScheme.primary, style = MaterialTheme.typography.headlineMedium, @@ -1033,7 +999,6 @@ private fun TextStylePreference( defaultValue: ThemeTextStyle?, defaultValueParent: ThemeTextStyle? = null, onValueChange: (ThemeTextStyle?) -> Unit = {}, - previewTexts: PreviewTexts, ) { val context = LocalContext.current @@ -1048,7 +1013,7 @@ private fun TextStylePreference( }, icon = { Text( - text = previewTexts.ExtraShort, + text = stringResource(R.string.typo_preview_extra_short), style = textStyle, color = MaterialTheme.colorScheme.primary, maxLines = 1, @@ -1136,7 +1101,7 @@ private fun TextStylePreference( ) { Text( modifier = Modifier.fillMaxWidth(), - text = previewTexts.TwoLines, + text = stringResource(R.string.typo_preview_long), textAlign = TextAlign.Center, color = MaterialTheme.colorScheme.primary, fontFamily = fontFamilyOf(context, fonts[actualFontFamily]), @@ -1170,7 +1135,7 @@ private fun TextStylePreference( }, ) { Text( - text = previewTexts.ExtraShort, + text = stringResource(R.string.typo_preview_extra_short), fontFamily = f, style = MaterialTheme.typography.headlineSmall, textAlign = TextAlign.Center, @@ -1268,7 +1233,6 @@ private fun TextStylePreference( @Composable private fun TypographyPreview( previewTypography: Typography, - previewTexts: PreviewTexts, content: @Composable () -> Unit, ) { Row( diff --git a/core/i18n/src/main/res/values-de/strings.xml b/core/i18n/src/main/res/values-de/strings.xml index efe0f44ab..d1bdb0bdd 100644 --- a/core/i18n/src/main/res/values-de/strings.xml +++ b/core/i18n/src/main/res/values-de/strings.xml @@ -902,4 +902,10 @@ Neues Tag Tag bearbeiten Verlassen, ohne zu speichern? + Aa + Typ + Äöü + Hamburg + Größe + Franz jagt im komplett\nverwahrlosten Taxi 123479 diff --git a/core/i18n/src/main/res/values/strings.xml b/core/i18n/src/main/res/values/strings.xml index fd69b0db0..87749414b 100644 --- a/core/i18n/src/main/res/values/strings.xml +++ b/core/i18n/src/main/res/values/strings.xml @@ -1091,4 +1091,10 @@ New tag Edit tag Quit without saving? + Aa + Ava + Typ + Hamburg + Preview + The quick brown fox\njumps over 123479