Sort sources/extensions filter languages

This commit is contained in:
arkon 2020-05-31 15:05:24 -04:00
parent 7dd9a0211b
commit 0bf14fd31c
4 changed files with 10 additions and 13 deletions

View file

@ -91,7 +91,6 @@ open class ExtensionController :
ExtensionFilterController().withFadeTransaction()
)
}
else -> return super.onOptionsItemSelected(item)
}
return super.onOptionsItemSelected(item)
}

View file

@ -45,11 +45,12 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
val extension = presenter.extension ?: return
val context = view.context
extension.getApplicationIcon(context)?.let { binding.extensionIcon.setImageDrawable(it) }
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.getSourceDisplayName(extension.lang, context))
binding.extensionPkg.text = extension.pkgName
extension.getApplicationIcon(context)?.let { binding.extensionIcon.setImageDrawable(it) }
binding.extensionUninstallButton.clicks()
.onEach { presenter.uninstallExtension() }
.launchIn(scope)

View file

@ -21,11 +21,9 @@ class ExtensionFilterController : SettingsController() {
val availableLangs =
Injekt.get<ExtensionManager>().availableExtensions.groupBy {
it.lang
}.keys.minus("all").partition {
it in activeLangs
}.let {
it.first + it.second
}
}.keys
.minus("all")
.sortedWith(compareBy({ it !in activeLangs }, { LocaleHelper.getSourceDisplayName(it, context) }))
availableLangs.forEach {
switchPreference {
@ -38,11 +36,11 @@ class ExtensionFilterController : SettingsController() {
val checked = newValue as Boolean
val currentActiveLangs = preferences.enabledLanguages().get()
if (checked) {
preferences.enabledLanguages().set(currentActiveLangs + it)
preferences.enabledLanguages().set(if (checked) {
currentActiveLangs + it
} else {
preferences.enabledLanguages().set(currentActiveLangs - it)
}
currentActiveLangs - it
})
true
}
}

View file

@ -30,8 +30,7 @@ class SettingsSourcesController : SettingsController() {
val sourcesByLang = onlineSources.groupByTo(TreeMap(), { it.lang })
// Order first by active languages, then inactive ones
val orderedLangs = sourcesByLang.keys.filter { it in activeLangsCodes } +
sourcesByLang.keys.filterNot { it in activeLangsCodes }
val orderedLangs = sourcesByLang.keys.sortedWith(compareBy({ it !in activeLangsCodes }, { LocaleHelper.getSourceDisplayName(it, context) }))
orderedLangs.forEach { lang ->
val sources = sourcesByLang[lang].orEmpty().sortedBy { it.name }