Change sources sort to case-insensitive (#3743)

This commit is contained in:
scb261 2020-09-04 05:20:27 +03:00 committed by GitHub
parent 565e8cf00b
commit 4b493ebbaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View file

@ -112,7 +112,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
.forEach {
val preferenceBlock = {
it.value
.sortedWith(compareBy({ !it.isEnabled() }, { it.name }))
.sortedWith(compareBy({ !it.isEnabled() }, { it.name.toLowerCase() }))
.forEach { source ->
val sourcePrefs = mutableListOf<Preference>()

View file

@ -29,7 +29,7 @@ class MigrationSourcesPresenter(
val header = SelectionHeader()
return library.map { it.source }.toSet()
.mapNotNull { if (it != LocalSource.ID) sourceManager.getOrStub(it) else null }
.sortedBy { it.name }
.sortedBy { it.name.toLowerCase() }
.map { SourceItem(it, header) }
}
}

View file

@ -42,7 +42,7 @@ class SourceFilterController : SettingsController() {
)
orderedLangs.forEach { lang ->
val sources = sourcesByLang[lang].orEmpty().sortedBy { it.name }
val sources = sourcesByLang[lang].orEmpty().sortedBy { it.name.toLowerCase() }
// Create a preference group and set initial state and change listener
switchPreferenceCategory {

View file

@ -128,7 +128,7 @@ class SourcePresenter(
return sourceManager.getCatalogueSources()
.filter { it.lang in languages }
.filterNot { it.id.toString() in disabledSourceIds }
.sortedBy { "(${it.lang}) ${it.name}" } +
.sortedBy { "(${it.lang}) ${it.name.toLowerCase()}" } +
sourceManager.get(LocalSource.ID) as LocalSource
}

View file

@ -108,7 +108,7 @@ open class GlobalSearchPresenter(
return sourceManager.getCatalogueSources()
.filter { it.lang in languages }
.filterNot { it.id.toString() in disabledSourceIds }
.sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "${it.name} (${it.lang})" }))
.sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "${it.name.toLowerCase()} (${it.lang})" }))
}
private fun getSourcesToQuery(): List<CatalogueSource> {
@ -188,7 +188,7 @@ open class GlobalSearchPresenter(
{ it.results.isNullOrEmpty() },
// Same as initial sort, i.e. pinned first then alphabetically
{ it.source.id.toString() !in pinnedSourceIds },
{ "${it.source.name} (${it.source.lang})" }
{ "${it.source.name.toLowerCase()} (${it.source.lang})" }
)
)
}