From 3854995ef23df814da32ef7bc6522007e7882f35 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 1 Jun 2021 17:53:51 -0400 Subject: [PATCH] Address some Kotlin language warnings --- app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt | 6 +++--- .../java/eu/kanade/tachiyomi/source/online/HttpSource.kt | 4 ++-- .../kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt | 2 +- .../browse/extension/details/ExtensionDetailsController.kt | 2 +- .../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 ++-- .../eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index a0f2c0056..77b093605 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index 81f705c66..14252049d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt index 708a58591..e99e17487 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt +++ b/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) { 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 69762a591..3107c58e1 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 @@ -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() 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 15ce71e07..ed6fb52d2 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 @@ -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() } } 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 4781db7f1..fa3a49e03 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.toLowerCase() } + val sources = sourcesByLang[lang].orEmpty().sortedBy { it.name.lowercase() } // 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 dd465efe1..9c924408f 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 @@ -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 } 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 3a6d1bf9c..923f07833 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 @@ -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 { @@ -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})" } ) ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt index bb1524f0b..dd44f42be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterRecognition.kt +++ b/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() } }