From 4b493ebbaf879a532305a5e6b13930dc6784d721 Mon Sep 17 00:00:00 2001 From: scb261 <65343233+scb261@users.noreply.github.com> Date: Fri, 4 Sep 2020 05:20:27 +0300 Subject: [PATCH] Change sources sort to case-insensitive (#3743) --- .../ui/browse/extension/details/ExtensionDetailsController.kt | 2 +- .../ui/browse/migration/sources/MigrationSourcesPresenter.kt | 2 +- .../tachiyomi/ui/browse/source/SourceFilterController.kt | 2 +- .../eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt | 2 +- .../ui/browse/source/globalsearch/GlobalSearchPresenter.kt | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index 2fb7f7a645..e7b5e25cd9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt index 1d724d2f81..72a3a25264 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt @@ -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) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt index 1edf4969e6..11d6fa6ecc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt index c39c14254c..b1fb9e7198 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index bedf58add4..7042dcb578 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -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 { @@ -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})" } ) ) }