Settings has a Language row, for choosing Gearslip's language

Android 13 and later already let you pick it, but only from the
system's app settings, which few people find (#51).
This commit is contained in:
Seb3thehacker committed 2026-11-02 16:53:14 -08:00
1 parent a1a7eca5cb
commit 3f25122fb6
21 files changed
+79

No files matched your search

@@ -1,6 +1,7 @@
package app.seb3thehacker.gearslip.ui
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import app.seb3thehacker.gearslip.R
import androidx.compose.runtime.withFrameNanos
import android.net.Uri
@@ -136,6 +137,7 @@ fun SettingsScreen(
icon = Icons.Filled.Star,
trailing = { Arrow() },
)
LanguageRow()
}
SettingsSection(
stringResource(R.string.settings_support),
@@ -167,6 +169,35 @@ private fun Arrow() = Icon(
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
/**
* Android 13 and later choose an app's language in their own settings, from the languages
* Gearslip declares; this opens that page, which few people find on their own (issue #51).
*/
@Composable
private fun LanguageRow() {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.TIRAMISU) return
val context = LocalContext.current
// A new choice arrives as a configuration change, since the manifest keeps the activity.
val chosen = remember(androidx.compose.ui.platform.LocalConfiguration.current) {
context.getSystemService(android.app.LocaleManager::class.java)?.applicationLocales?.get(0)
}
SettingsDivider()
SettingsRow(
stringResource(R.string.settings_language),
Modifier.clickable {
runCatching {
context.startActivity(
android.content.Intent(android.provider.Settings.ACTION_APP_LOCALE_SETTINGS, Uri.fromParts("package", context.packageName, null)),
)
}
},
subtitle = chosen?.let { it.getDisplayName(it).replaceFirstChar { c -> c.titlecase(it) } }
?: stringResource(R.string.settings_language_phone),
icon = androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_language),
trailing = { Arrow() },
)
}
/** The setup guide replay, and where Gearslip lives outside the app. */
@Composable
private fun AboutSection(onReplayTutorial: () -> Unit) {