mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: clean up theme and language pickers
This commit is contained in:
parent
8d93ed88ce
commit
71c7aca10b
2 changed files with 29 additions and 59 deletions
|
|
@ -37,7 +37,7 @@ object LanguageUtils : Logging {
|
|||
* Build a list from locales_config.xml
|
||||
* of native language names paired to its Locale tag (ex: "English", "en")
|
||||
*/
|
||||
fun getLanguageTags(context: Context): List<Pair<String, String>> {
|
||||
fun getLanguageTags(context: Context): Map<String, String> {
|
||||
val languageTags = mutableListOf(SYSTEM_DEFAULT)
|
||||
try {
|
||||
context.resources.getXml(R.xml.locales_config).use {
|
||||
|
|
@ -51,7 +51,7 @@ object LanguageUtils : Logging {
|
|||
} catch (e: Exception) {
|
||||
errormsg("Error parsing locale_config.xml ${e.message}")
|
||||
}
|
||||
return languageTags.map { tag ->
|
||||
return languageTags.associateBy { tag ->
|
||||
val loc = Locale(tag)
|
||||
when (tag) {
|
||||
SYSTEM_DEFAULT -> context.getString(R.string.preferences_system_default)
|
||||
|
|
@ -59,7 +59,7 @@ object LanguageUtils : Logging {
|
|||
"pt-BR" -> context.getString(R.string.pt_BR)
|
||||
else -> loc.getDisplayLanguage(loc)
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(loc) else it.toString() }
|
||||
} to tag
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue