Browse Source

Prioritize "all" ("Multi") lang in extensions lists

Fixes #8811
Fixes #8812
arkon 2 years ago
parent
commit
50d46fe7f6

+ 1 - 4
app/src/main/java/eu/kanade/domain/extension/interactor/GetExtensionLanguages.kt

@@ -25,10 +25,7 @@ class GetExtensionLanguages(
                 }
                 .distinct()
                 .sortedWith(
-                    compareBy(
-                        { it !in enabledLanguage },
-                        { LocaleHelper.getDisplayName(it) },
-                    ),
+                    compareBy<String> { it !in enabledLanguage }.then(LocaleHelper.comparator),
                 )
         }
     }

+ 1 - 4
app/src/main/java/eu/kanade/domain/source/interactor/GetLanguagesWithSources.kt

@@ -25,10 +25,7 @@ class GetLanguagesWithSources(
 
             sortedSources.groupBy { it.lang }
                 .toSortedMap(
-                    compareBy(
-                        { it !in enabledLanguage },
-                        { LocaleHelper.getDisplayName(it) },
-                    ),
+                    compareBy<String> { it !in enabledLanguage }.then(LocaleHelper.comparator),
                 )
         }
     }

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt

@@ -82,11 +82,11 @@ class ExtensionsScreenModel(
 
                 val languagesWithExtensions = _available
                     .filter(queryFilter(searchQuery))
-                    .groupBy { LocaleHelper.getSourceDisplayName(it.lang, context) }
-                    .toSortedMap()
+                    .groupBy { it.lang }
+                    .toSortedMap(LocaleHelper.comparator)
                     .flatMap { (lang, exts) ->
                         listOf(
-                            ExtensionUiModel.Header.Text(lang),
+                            ExtensionUiModel.Header.Text(LocaleHelper.getSourceDisplayName(lang, context)),
                             *exts.map(extensionMapper(downloads)).toTypedArray(),
                         )
                     }

+ 5 - 0
app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt

@@ -11,6 +11,11 @@ import java.util.Locale
  */
 object LocaleHelper {
 
+    val comparator = compareBy<String>(
+        { getDisplayName(it) },
+        { it == "all" },
+    )
+
     /**
      * Returns display name of a string language code.
      */