diff --git a/app/build.gradle b/app/build.gradle index 1edcc0755..59657b0f8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -160,7 +160,7 @@ dependencies { testImplementation "androidx.room:room-testing:$room_version" //paging - implementation 'androidx.paging:paging-runtime-ktx:3.0.0' + implementation 'androidx.paging:paging-runtime-ktx:2.1.2' //liveEventBus implementation 'com.jeremyliao:live-event-bus-x:1.5.7' diff --git a/app/src/main/java/io/legado/app/base/BasePreferenceFragment.kt b/app/src/main/java/io/legado/app/base/BasePreferenceFragment.kt index b2e467b7c..6166b7a5d 100644 --- a/app/src/main/java/io/legado/app/base/BasePreferenceFragment.kt +++ b/app/src/main/java/io/legado/app/base/BasePreferenceFragment.kt @@ -54,6 +54,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() { } } f.setTargetFragment(this, 0) + f.show(parentFragmentManager, dialogFragmentTag) } diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 851660fdf..43fcd60a9 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -318,7 +318,7 @@ interface JsExtensions { if (font1 == null || font2 == null) return text val contentArray = text.toCharArray() contentArray.forEachIndexed { index, s -> - val oldCode = s.toInt() + val oldCode = s.code if (font1.inLimit(s)) { val code = font2.getCodeByGlyf(font1.getGlyfByCode(oldCode)) if (code != 0) contentArray[index] = code.toChar() diff --git a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt index 6affe0b88..1f544425c 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt @@ -51,7 +51,7 @@ object RssParserByRule { Debug.log(sourceUrl, "└列表大小:${collections.size}") if (!rssSource.ruleNextPage.isNullOrEmpty()) { Debug.log(sourceUrl, "┌获取下一页链接") - if (rssSource.ruleNextPage!!.toUpperCase(Locale.getDefault()) == "PAGE") { + if (rssSource.ruleNextPage!!.uppercase(Locale.getDefault()) == "PAGE") { nextUrl = sortUrl } else { nextUrl = analyzeRule.getString(rssSource.ruleNextPage) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index e4b2d6724..c070e4361 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -141,7 +141,7 @@ class FontSelectDialog : BaseDialogFragment(), val fontDir = FileUtils.createFolderIfNotExist(requireContext().externalFilesDir, "font") fontDir.listFiles { pathName -> - pathName.name.toLowerCase(Locale.getDefault()).matches(fontRegex) + pathName.name.lowercase(Locale.getDefault()).matches(fontRegex) }?.forEach { fontItems.add( DocItem( @@ -161,7 +161,7 @@ class FontSelectDialog : BaseDialogFragment(), val fontItems = arrayListOf() val docItems = DocumentUtils.listFiles(appCtx, doc.uri) docItems.forEach { item -> - if (item.name.toLowerCase(Locale.getDefault()).matches(fontRegex)) { + if (item.name.lowercase(Locale.getDefault()).matches(fontRegex)) { fontItems.add(item) } } @@ -188,7 +188,7 @@ class FontSelectDialog : BaseDialogFragment(), val fontItems = arrayListOf() val file = File(path) file.listFiles { pathName -> - pathName.name.toLowerCase(Locale.getDefault()).matches(fontRegex) + pathName.name.lowercase(Locale.getDefault()).matches(fontRegex) }?.forEach { fontItems.add( DocItem( diff --git a/app/src/main/java/io/legado/app/utils/ACache.kt b/app/src/main/java/io/legado/app/utils/ACache.kt index 5011a713d..934e0b1f1 100644 --- a/app/src/main/java/io/legado/app/utils/ACache.kt +++ b/app/src/main/java/io/legado/app/utils/ACache.kt @@ -525,7 +525,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) } fun hasDateInfo(data: ByteArray?): Boolean { - return (data != null && data.size > 15 && data[13] == '-'.toByte() + return (data != null && data.size > 15 && data[13] == '-'.code.toByte() && indexOf(data, mSeparator) > 14) } @@ -546,7 +546,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) @Suppress("SameParameterValue") private fun indexOf(data: ByteArray, c: Char): Int { for (i in data.indices) { - if (data[i] == c.toByte()) { + if (data[i] == c.code.toByte()) { return i } } diff --git a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt index 976f1c1be..aafdb0d98 100644 --- a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt +++ b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt @@ -12,7 +12,7 @@ object EncoderUtils { fun escape(src: String): String { val tmp = StringBuilder() for (char in src) { - val charCode = char.toInt() + val charCode = char.code if (charCode in 48..57 || charCode in 65..90 || charCode in 97..122) { tmp.append(char) continue diff --git a/app/src/main/java/io/legado/app/utils/EncodingDetect.kt b/app/src/main/java/io/legado/app/utils/EncodingDetect.kt index 22f6c79d4..de698c8e0 100644 --- a/app/src/main/java/io/legado/app/utils/EncodingDetect.kt +++ b/app/src/main/java/io/legado/app/utils/EncodingDetect.kt @@ -26,14 +26,14 @@ object EncodingDetect { } val content = metaTag.attr("content") val httpEquiv = metaTag.attr("http-equiv") - if (httpEquiv.toLowerCase(Locale.getDefault()) == "content-type") { - charsetStr = if (content.toLowerCase(Locale.getDefault()).contains("charset")) { + if (httpEquiv.lowercase(Locale.getDefault()) == "content-type") { + charsetStr = if (content.lowercase(Locale.getDefault()).contains("charset")) { content.substring( - content.toLowerCase(Locale.getDefault()) + content.lowercase(Locale.getDefault()) .indexOf("charset") + "charset=".length ) } else { - content.substring(content.toLowerCase(Locale.getDefault()).indexOf(";") + 1) + content.substring(content.lowercase(Locale.getDefault()).indexOf(";") + 1) } if (!TextUtils.isEmpty(charsetStr)) { return charsetStr diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index 87be05e05..4bc22d456 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -12,17 +12,17 @@ object NetworkUtils { private val notNeedEncoding: BitSet by lazy { val bitSet = BitSet(256) - for (i in 'a'.toInt()..'z'.toInt()) { + for (i in 'a'.code..'z'.code) { bitSet.set(i) } - for (i in 'A'.toInt()..'Z'.toInt()) { + for (i in 'A'.code..'Z'.code) { bitSet.set(i) } - for (i in '0'.toInt()..'9'.toInt()) { + for (i in '0'.code..'9'.code) { bitSet.set(i) } for (char in "+-_.$:()!*@&#,[]") { - bitSet.set(char.toInt()) + bitSet.set(char.code) } return@lazy bitSet } @@ -38,7 +38,7 @@ object NetworkUtils { var i = 0 while (i < str.length) { val c = str[i] - if (notNeedEncoding.get(c.toInt())) { + if (notNeedEncoding.get(c.code)) { i++ continue } diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index feb428337..3a2bda745 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -114,7 +114,7 @@ object StringUtils { @SuppressLint("DefaultLocale") fun toFirstCapital(str: String): String { - return str.substring(0, 1).toUpperCase() + str.substring(1) + return str.substring(0, 1).uppercase(Locale.getDefault()) + str.substring(1) } /** @@ -123,7 +123,7 @@ object StringUtils { fun halfToFull(input: String): String { val c = input.toCharArray() for (i in c.indices) { - if (c[i].toInt() == 32) + if (c[i].code == 32) //半角空格 { c[i] = 12288.toChar() @@ -133,9 +133,9 @@ object StringUtils { //if (c[i] == 46) //半角点号,不转换 // continue; - if (c[i].toInt() in 33..126) + if (c[i].code in 33..126) //其他符号都转换为全角 - c[i] = (c[i].toInt() + 65248).toChar() + c[i] = (c[i].code + 65248).toChar() } return String(c) } @@ -144,15 +144,15 @@ object StringUtils { fun fullToHalf(input: String): String { val c = input.toCharArray() for (i in c.indices) { - if (c[i].toInt() == 12288) + if (c[i].code == 12288) //全角空格 { c[i] = 32.toChar() continue } - if (c[i].toInt() in 65281..65374) - c[i] = (c[i].toInt() - 65248).toChar() + if (c[i].code in 65281..65374) + c[i] = (c[i].code - 65248).toChar() } return String(c) } @@ -255,10 +255,10 @@ object StringUtils { var start = 0 val len = s.length var end = len - 1 - while (start < end && (s[start].toInt() <= 0x20 || s[start] == ' ')) { + while (start < end && (s[start].code <= 0x20 || s[start] == ' ')) { ++start } - while (start < end && (s[end].toInt() <= 0x20 || s[end] == ' ')) { + while (start < end && (s[end].code <= 0x20 || s[end] == ' ')) { --end } if (end < len) ++end diff --git a/build.gradle b/build.gradle index 7305a5fc4..f826dc95c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { ext.kotlin_version = '1.5.0' repositories { google() - maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } + maven { url 'https://maven.aliyun.com/repository/public/'} maven { url "https://s3.amazonaws.com/fabric-artifacts/public" } maven { url "https://maven.aliyun.com/repository/gradle-plugin" } maven { url "https://plugins.gradle.org/m2/" } @@ -19,10 +19,9 @@ buildscript { allprojects { repositories { google() - maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } + maven { url 'https://maven.aliyun.com/repository/public/'} maven { url "https://jitpack.io" } maven { url "https://maven.google.com/" } - //maven { url "https://github.com/psiegman/mvn-repo/raw/master/releases" } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ef1aa2fdc..f96ca89e9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Oct 13 11:35:54 CST 2020 +#Fri May 07 15:24:46 CST 2021 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +zipStoreBase=GRADLE_USER_HOME