Show locale name in system default locale

This commit is contained in:
arkon 2020-04-18 22:48:52 -04:00
parent ca47446b46
commit 359d4dc1b2
9 changed files with 23 additions and 12 deletions

View File

@ -73,7 +73,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
binding.extensionTitle.text = extension.name
binding.extensionVersion.text = context.getString(R.string.ext_version_info, extension.versionName)
binding.extensionLang.text = context.getString(R.string.ext_language_info, LocaleHelper.getDisplayName(extension.lang, context))
binding.extensionLang.text = context.getString(R.string.ext_language_info, LocaleHelper.getSourceDisplayName(extension.lang, context))
binding.extensionPkg.text = extension.pkgName
extension.getApplicationIcon(context)?.let { binding.extensionIcon.setImageDrawable(it) }
binding.extensionUninstallButton.clicks()

View File

@ -31,7 +31,7 @@ class ExtensionFilterController : SettingsController() {
availableLangs.forEach {
switchPreference {
preferenceScreen.addPreference(this)
title = LocaleHelper.getDisplayName(it, context)
title = LocaleHelper.getSourceDisplayName(it, context)
isPersistent = false
isChecked = it in activeLangs

View File

@ -42,7 +42,7 @@ class ExtensionHolder(view: View, override val adapter: ExtensionAdapter) :
ext_title.text = extension.name
version.text = extension.versionName
lang.text = if (extension !is Extension.Untrusted) {
LocaleHelper.getDisplayName(extension.lang, itemView.context)
LocaleHelper.getSourceDisplayName(extension.lang, itemView.context)
} else {
itemView.context.getString(R.string.ext_untrusted).toUpperCase()
}

View File

@ -90,7 +90,7 @@ open class ExtensionPresenter(
}
if (availableSorted.isNotEmpty()) {
val availableGroupedByLang = availableSorted
.groupBy { LocaleHelper.getDisplayName(it.lang, context) }
.groupBy { LocaleHelper.getSourceDisplayName(it.lang, context) }
.toSortedMap()
availableGroupedByLang

View File

@ -62,15 +62,14 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_language
val langs = mutableListOf<Pair<String, String>>()
langs += Pair("", context.getString(R.string.system_default))
langs += Pair("", "${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})")
langs += arrayOf(
"ar", "bg", "bn", "ca", "cs", "de", "el", "en-US", "en-GB", "es", "fr", "he",
"hi", "hu", "in", "it", "ja", "ko", "lv", "ms", "nb-rNO", "nl", "pl", "pt",
"pt-BR", "ro", "ru", "sc", "sr", "sv", "th", "tl", "tr", "uk", "vi", "zh-rCN"
)
.map {
val locale = LocaleHelper.getLocaleFromString(it)
Pair(it, locale!!.getDisplayName(locale).capitalize())
Pair(it, LocaleHelper.getDisplayName(it))
}
.sortedBy { it.second }

View File

@ -40,7 +40,7 @@ class SettingsSourcesController : SettingsController() {
// Create a preference group and set initial state and change listener
switchPreferenceCategory {
preferenceScreen.addPreference(this)
title = LocaleHelper.getDisplayName(lang, context)
title = LocaleHelper.getSourceDisplayName(lang, context)
isPersistent = false
if (lang in activeLangsCodes) {
setChecked(true)

View File

@ -10,6 +10,6 @@ class LangHolder(view: View, adapter: FlexibleAdapter<*>) :
BaseFlexibleViewHolder(view, adapter) {
fun bind(item: LangItem) {
title.text = LocaleHelper.getDisplayName(item.code, itemView.context)
title.text = LocaleHelper.getSourceDisplayName(item.code, itemView.context)
}
}

View File

@ -47,12 +47,24 @@ object LocaleHelper {
/**
* Returns Display name of a string language code
*/
fun getDisplayName(lang: String?, context: Context): String {
fun getSourceDisplayName(lang: String?, context: Context): String {
return when (lang) {
null -> ""
"" -> context.getString(R.string.other_source)
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
"all" -> context.getString(R.string.all_lang)
else -> getDisplayName(lang)
}
}
/**
* Returns Display name of a string language code
*/
fun getDisplayName(lang: String?): String {
return when (lang) {
null -> ""
"" -> {
systemLocale!!.getDisplayName(systemLocale).capitalize()
}
else -> {
val locale = getLocale(lang)
locale.getDisplayName(locale).capitalize()

View File

@ -142,7 +142,7 @@
<string name="theme_dark_amoled">AMOLED black</string>
<string name="pref_start_screen">Start screen</string>
<string name="pref_language">Language</string>
<string name="system_default">System default</string>
<string name="system_default">Default</string>
<string name="pref_date_format">Date format</string>
<string name="pref_confirm_exit">Confirm exit</string>
<string name="pref_manage_notifications">Manage notifications</string>