Change sources sort to case-insensitive (#3743)

(cherry picked from commit 4b493ebbaf879a532305a5e6b13930dc6784d721)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt
This commit is contained in:
scb261 2020-09-04 05:20:27 +03:00 committed by Jobobby04
parent a5a79c1127
commit d83361dfe3
5 changed files with 6 additions and 6 deletions

View File

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

View File

@ -32,7 +32,7 @@ class MigrationSourcesPresenter(
return library.map { it.source }.toSet() return library.map { it.source }.toSet()
// SY --> // SY -->
.mapNotNull { if (it != LocalSource.ID && it != MERGED_SOURCE_ID) sourceManager.getOrStub(it) else null } .mapNotNull { if (it != LocalSource.ID && it != MERGED_SOURCE_ID) sourceManager.getOrStub(it) else null }
.sortedBy { it.name.toLowerCase(Locale.ROOT) } .sortedBy { it.name.toLowerCase() }
// SY <-- // SY <--
.map { SourceItem(it, header) } .map { SourceItem(it, header) }
} }

View File

@ -217,7 +217,7 @@ class SourceFilterController : SettingsController() {
} }
private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> { private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> {
val sourceAlpha = sources.orEmpty().sortedBy { it.name } val sourceAlpha = sources.orEmpty().sortedBy { it.name.toLowerCase() }
return if (sorting == SourcesSort.Enabled) { return if (sorting == SourcesSort.Enabled) {
val disabledSourceIds = preferences.disabledSources().get() val disabledSourceIds = preferences.disabledSources().get()
sourceAlpha.filter { it.id.toString() !in disabledSourceIds } + sourceAlpha.filter { it.id.toString() !in disabledSourceIds } +

View File

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

View File

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