mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Sort sources/extensions filter languages
This commit is contained in:
parent
7dd9a0211b
commit
0bf14fd31c
4 changed files with 10 additions and 13 deletions
|
@ -91,7 +91,6 @@ open class ExtensionController :
|
|||
ExtensionFilterController().withFadeTransaction()
|
||||
)
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue