Procházet zdrojové kódy

Address some Kotlin language warnings

arkon před 3 roky
rodič
revize
3854995ef2

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt

@@ -84,9 +84,9 @@ class LocalSource(private val context: Context) : CatalogueSource {
         when (state?.index) {
             0 -> {
                 mangaDirs = if (state.ascending) {
-                    mangaDirs.sortedBy { it.name.toLowerCase(Locale.ENGLISH) }
+                    mangaDirs.sortedBy { it.name.lowercase(Locale.ENGLISH) }
                 } else {
-                    mangaDirs.sortedByDescending { it.name.toLowerCase(Locale.ENGLISH) }
+                    mangaDirs.sortedByDescending { it.name.lowercase(Locale.ENGLISH) }
                 }
             }
             1 -> {
@@ -238,7 +238,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
     }
 
     private fun isSupportedFile(extension: String): Boolean {
-        return extension.toLowerCase(Locale.ROOT) in SUPPORTED_ARCHIVE_TYPES
+        return extension.lowercase() in SUPPORTED_ARCHIVE_TYPES
     }
 
     fun getFormat(chapter: SChapter): Format {

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt

@@ -54,7 +54,7 @@ abstract class HttpSource : CatalogueSource {
      * Note the generated id sets the sign bit to 0.
      */
     override val id by lazy {
-        val key = "${name.toLowerCase()}/$lang/$versionId"
+        val key = "${name.lowercase()}/$lang/$versionId"
         val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
         (0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
     }
@@ -80,7 +80,7 @@ abstract class HttpSource : CatalogueSource {
     /**
      * Visible name of the source.
      */
-    override fun toString() = "$name (${lang.toUpperCase()})"
+    override fun toString() = "$name (${lang.uppercase()})"
 
     /**
      * Returns an observable containing a page with a list of manga. Normally it's not needed to

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt

@@ -40,7 +40,7 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
             extension is Extension.Installed && extension.isObsolete -> itemView.context.getString(R.string.ext_obsolete)
             extension.isNsfw && shouldLabelNsfw -> itemView.context.getString(R.string.ext_nsfw_short)
             else -> ""
-        }.toUpperCase()
+        }.uppercase()
 
         binding.image.clear()
         if (extension is Extension.Available) {

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt

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

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt

@@ -34,7 +34,7 @@ class MigrationSourcesPresenter(
                 val source = sourceManager.getOrStub(it.key)
                 SourceItem(source, it.value.size, header)
             }
-            .sortedBy { it.source.name.toLowerCase() }
+            .sortedBy { it.source.name.lowercase() }
             .toList()
     }
 }

+ 1 - 1
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.toLowerCase() }
+            val sources = sourcesByLang[lang].orEmpty().sortedBy { it.name.lowercase() }
 
             // Create a preference group and set initial state and change listener
             switchPreferenceCategory {

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt

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

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt

@@ -105,7 +105,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.toLowerCase()} (${it.lang})" }))
+            .sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "${it.name.lowercase()} (${it.lang})" }))
     }
 
     private fun getSourcesToQuery(): List<CatalogueSource> {
@@ -185,7 +185,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.toLowerCase()} (${it.source.lang})" }
+                            { "${it.source.name.lowercase()} (${it.source.lang})" }
                         )
                     )
             }

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt

@@ -44,7 +44,7 @@ object ChapterRecognition {
         }
 
         // Get chapter title with lower case
-        var name = chapter.name.toLowerCase()
+        var name = chapter.name.lowercase()
 
         // Remove comma's from chapter.
         name = name.replace(',', '.')
@@ -77,7 +77,7 @@ object ChapterRecognition {
         }
 
         // Remove manga title from chapter title.
-        val nameWithoutManga = name.replace(manga.title.toLowerCase(), "").trim()
+        val nameWithoutManga = name.replace(manga.title.lowercase(), "").trim()
 
         // Check if first value is number after title remove.
         if (updateChapter(withoutManga.find(nameWithoutManga), chapter)) {
@@ -147,6 +147,6 @@ object ChapterRecognition {
      * x.a -> x.1, x.b -> x.2, etc
      */
     private fun parseAlphaPostFix(alpha: Char): Float {
-        return ("0." + (alpha.toInt() - 96).toString()).toFloat()
+        return ("0." + (alpha.code - 96).toString()).toFloat()
     }
 }