From db7368214137824c91ba6505ed25cf7c7884955d Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 18 Oct 2020 22:22:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseFragment.kt | 1 + .../java/io/legado/app/base/BaseService.kt | 4 +- .../java/io/legado/app/base/BaseViewModel.kt | 1 + .../app/base/adapter/CommonRecyclerAdapter.kt | 1 + .../base/adapter/InfiniteScrollListener.kt | 1 + .../legado/app/base/adapter/ItemAnimation.kt | 1 + .../java/io/legado/app/help/ActivityHelp.kt | 1 + .../io/legado/app/help/BlurTransformation.kt | 2 +- .../main/java/io/legado/app/help/BookHelp.kt | 27 ++++-- .../java/io/legado/app/help/EventMessage.kt | 3 +- .../java/io/legado/app/help/IntentHelp.kt | 1 + .../java/io/legado/app/help/LayoutManager.kt | 1 + .../app/help/coroutine/CompositeCoroutine.kt | 1 + .../io/legado/app/help/coroutine/Coroutine.kt | 1 + .../io/legado/app/help/http/CookieStore.kt | 2 + .../io/legado/app/help/http/HttpHelper.kt | 6 +- .../java/io/legado/app/help/http/SSLHelper.kt | 1 + .../legado/app/help/permission/Permissions.kt | 1 + .../app/help/permission/PermissionsCompat.kt | 9 +- .../legado/app/help/storage/ImportOldData.kt | 2 +- .../io/legado/app/help/storage/OldRule.kt | 1 + .../main/java/io/legado/app/lib/theme/ATH.kt | 1 + .../io/legado/app/lib/theme/DrawableUtils.kt | 1 + .../app/lib/theme/MaterialValueHelper.kt | 2 + .../app/lib/theme/NavigationViewUtils.kt | 1 + .../java/io/legado/app/lib/theme/Selector.kt | 6 +- .../io/legado/app/lib/theme/ThemeStore.kt | 1 + .../io/legado/app/lib/theme/TintHelper.kt | 92 +++++++++++-------- .../java/io/legado/app/lib/theme/ViewUtils.kt | 1 + .../java/io/legado/app/lib/webdav/WebDav.kt | 5 +- .../model/analyzeRule/AnalyzeByJSonPath.kt | 1 + .../legado/app/model/rss/RssParserDefault.kt | 1 + .../ui/book/read/page/entities/TextLine.kt | 1 + .../app/ui/filechooser/adapter/FileAdapter.kt | 8 +- .../app/ui/filechooser/adapter/PathAdapter.kt | 2 +- .../ui/filechooser/utils/FilePickerIcon.java | 10 +- 36 files changed, 127 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseFragment.kt b/app/src/main/java/io/legado/app/base/BaseFragment.kt index 155bb6076..eb7805029 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -15,6 +15,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlin.coroutines.CoroutineContext +@Suppress("MemberVisibilityCanBePrivate") abstract class BaseFragment(layoutID: Int) : Fragment(layoutID), CoroutineScope { lateinit var job: Job diff --git a/app/src/main/java/io/legado/app/base/BaseService.kt b/app/src/main/java/io/legado/app/base/BaseService.kt index f00540526..192737447 100644 --- a/app/src/main/java/io/legado/app/base/BaseService.kt +++ b/app/src/main/java/io/legado/app/base/BaseService.kt @@ -18,7 +18,9 @@ abstract class BaseService : Service(), CoroutineScope by MainScope() { block: suspend CoroutineScope.() -> T ) = Coroutine.async(scope, context) { block() } - override fun onBind(intent: Intent?) = null + override fun onBind(intent: Intent?): IBinder? { + return null + } override fun onDestroy() { super.onDestroy() diff --git a/app/src/main/java/io/legado/app/base/BaseViewModel.kt b/app/src/main/java/io/legado/app/base/BaseViewModel.kt index c8332e0cc..e5432e204 100644 --- a/app/src/main/java/io/legado/app/base/BaseViewModel.kt +++ b/app/src/main/java/io/legado/app/base/BaseViewModel.kt @@ -11,6 +11,7 @@ import org.jetbrains.anko.AnkoLogger import org.jetbrains.anko.toast import kotlin.coroutines.CoroutineContext +@Suppress("unused") open class BaseViewModel(application: Application) : AndroidViewModel(application), CoroutineScope by MainScope(), AnkoLogger { diff --git a/app/src/main/java/io/legado/app/base/adapter/CommonRecyclerAdapter.kt b/app/src/main/java/io/legado/app/base/adapter/CommonRecyclerAdapter.kt index 0ae540837..4fd0fd520 100644 --- a/app/src/main/java/io/legado/app/base/adapter/CommonRecyclerAdapter.kt +++ b/app/src/main/java/io/legado/app/base/adapter/CommonRecyclerAdapter.kt @@ -15,6 +15,7 @@ import java.util.* * * 通用的adapter 可添加header,footer,以及不同类型item */ +@Suppress("unused", "MemberVisibilityCanBePrivate") abstract class CommonRecyclerAdapter(protected val context: Context) : RecyclerView.Adapter() { diff --git a/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt b/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt index a679f3e08..08f9716f3 100644 --- a/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt +++ b/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt @@ -8,6 +8,7 @@ import androidx.recyclerview.widget.RecyclerView * * 上拉加载更多 */ +@Suppress("unused") abstract class InfiniteScrollListener() : RecyclerView.OnScrollListener() { private val loadMoreRunnable = Runnable { onLoadMore() } diff --git a/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt index e2c37d708..3f70ca3ea 100644 --- a/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt @@ -7,6 +7,7 @@ import io.legado.app.base.adapter.animations.* /** * Created by Invincible on 2017/12/15. */ +@Suppress("unused") class ItemAnimation private constructor() { var itemAnimEnabled = false diff --git a/app/src/main/java/io/legado/app/help/ActivityHelp.kt b/app/src/main/java/io/legado/app/help/ActivityHelp.kt index 8d07a3500..9c9cb0175 100644 --- a/app/src/main/java/io/legado/app/help/ActivityHelp.kt +++ b/app/src/main/java/io/legado/app/help/ActivityHelp.kt @@ -10,6 +10,7 @@ import java.util.* /** * Activity管理器,管理项目中Activity的状态 */ +@Suppress("unused") object ActivityHelp : Application.ActivityLifecycleCallbacks { private val activities: MutableList> = arrayListOf() diff --git a/app/src/main/java/io/legado/app/help/BlurTransformation.kt b/app/src/main/java/io/legado/app/help/BlurTransformation.kt index 4493228c4..74de12038 100644 --- a/app/src/main/java/io/legado/app/help/BlurTransformation.kt +++ b/app/src/main/java/io/legado/app/help/BlurTransformation.kt @@ -28,7 +28,7 @@ class BlurTransformation(context: Context, private val radius: Int) : CenterCrop //图片缩小1/2 val width = (min(outWidth, transform.width) / 2f).roundToInt() val height = (min(outHeight, transform.height) / 2f).roundToInt() - val blurredBitmap = Bitmap.createScaledBitmap(transform, width, height, false); + val blurredBitmap = Bitmap.createScaledBitmap(transform, width, height, false) // Allocate memory for Renderscript to work with //分配用于渲染脚本的内存 val input = Allocation.createFromBitmap( diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 32d5262ce..4f1a2ba9f 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -267,8 +267,9 @@ object BookHelp { } } - private val chapterNamePattern = + private val chapterNamePattern by lazy { Pattern.compile("^(.*?第([\\d零〇一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟0-9\\s]+)[章节篇回集])[、,。 ::.\\s]*") + } private fun getChapterNum(chapterName: String?): Int { if (chapterName != null) { @@ -280,15 +281,25 @@ object BookHelp { return -1 } - private fun getPureChapterName(chapterName: String?): String { + @Suppress("SpellCheckingInspection") + private val regexOther by lazy { // 所有非字母数字中日韩文字 CJK区+扩展A-F区 + return@lazy "[^\\w\\u4E00-\\u9FEF〇\\u3400-\\u4DBF\\u20000-\\u2A6DF\\u2A700-\\u2EBEF]".toRegex() + } + + private val regexA by lazy { + return@lazy "\\s".toRegex() + } + + private val regexB by lazy { + return@lazy "^第.*?章|[(\\[][^()\\[\\]]{2,}[)\\]]$".toRegex() + } + + private fun getPureChapterName(chapterName: String?): String { return if (chapterName == null) "" else StringUtils.fullToHalf(chapterName) - .replace("\\s".toRegex(), "") - .replace("^第.*?章|[(\\[][^()\\[\\]]{2,}[)\\]]$".toRegex(), "") - .replace( - "[^\\w\\u4E00-\\u9FEF〇\\u3400-\\u4DBF\\u20000-\\u2A6DF\\u2A700-\\u2EBEF]".toRegex(), - "" - ) + .replace(regexA, "") + .replace(regexB, "") + .replace(regexOther, "") } private var bookName: String? = null diff --git a/app/src/main/java/io/legado/app/help/EventMessage.kt b/app/src/main/java/io/legado/app/help/EventMessage.kt index fe9c80994..9e2606ea5 100644 --- a/app/src/main/java/io/legado/app/help/EventMessage.kt +++ b/app/src/main/java/io/legado/app/help/EventMessage.kt @@ -2,8 +2,7 @@ package io.legado.app.help import android.text.TextUtils -import java.util.Arrays - +@Suppress("unused") class EventMessage { var what: Int?=null diff --git a/app/src/main/java/io/legado/app/help/IntentHelp.kt b/app/src/main/java/io/legado/app/help/IntentHelp.kt index d7ed03af1..05b580272 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -7,6 +7,7 @@ import android.os.Bundle import io.legado.app.R import org.jetbrains.anko.toast +@Suppress("unused") object IntentHelp { diff --git a/app/src/main/java/io/legado/app/help/LayoutManager.kt b/app/src/main/java/io/legado/app/help/LayoutManager.kt index e633993c7..79b54bb0c 100644 --- a/app/src/main/java/io/legado/app/help/LayoutManager.kt +++ b/app/src/main/java/io/legado/app/help/LayoutManager.kt @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.StaggeredGridLayoutManager +@Suppress("unused") object LayoutManager { interface LayoutManagerFactory { diff --git a/app/src/main/java/io/legado/app/help/coroutine/CompositeCoroutine.kt b/app/src/main/java/io/legado/app/help/coroutine/CompositeCoroutine.kt index 1eb1102ba..14c123378 100644 --- a/app/src/main/java/io/legado/app/help/coroutine/CompositeCoroutine.kt +++ b/app/src/main/java/io/legado/app/help/coroutine/CompositeCoroutine.kt @@ -1,5 +1,6 @@ package io.legado.app.help.coroutine +@Suppress("unused") class CompositeCoroutine : CoroutineContainer { private var resources: HashSet>? = null diff --git a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt index 0811eee10..a31c9d1e0 100644 --- a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt +++ b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt @@ -5,6 +5,7 @@ import kotlinx.coroutines.* import kotlin.coroutines.CoroutineContext +@Suppress("unused") class Coroutine( val scope: CoroutineScope, context: CoroutineContext = Dispatchers.IO, diff --git a/app/src/main/java/io/legado/app/help/http/CookieStore.kt b/app/src/main/java/io/legado/app/help/http/CookieStore.kt index 067435ddb..2f2bfaaec 100644 --- a/app/src/main/java/io/legado/app/help/http/CookieStore.kt +++ b/app/src/main/java/io/legado/app/help/http/CookieStore.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package io.legado.app.help.http import android.text.TextUtils diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index 1d9252164..3728f4819 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -112,7 +112,7 @@ object HttpHelper { proxy: String? = null ): Retrofit { val r = Regex("(http|socks4|socks5)://(.*):(\\d{2,5})(@.*@.*)?") - val ms = proxy?.let { r.findAll(it) }; + val ms = proxy?.let { r.findAll(it) } val group = ms?.first() var type = "direct" //直接连接 var host = "127.0.0.1" //代理服务器hostname @@ -135,9 +135,9 @@ object HttpHelper { val builder = client.newBuilder() if (type != "direct" && host != "") { if (type == "http") { - builder.proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress(host, port))); + builder.proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress(host, port))) } else { - builder.proxy(Proxy(Proxy.Type.SOCKS, InetSocketAddress(host, port))); + builder.proxy(Proxy(Proxy.Type.SOCKS, InetSocketAddress(host, port))) } if (username != "" && password != "") { builder.proxyAuthenticator { _, response -> //设置代理服务器账号密码 diff --git a/app/src/main/java/io/legado/app/help/http/SSLHelper.kt b/app/src/main/java/io/legado/app/help/http/SSLHelper.kt index 800304b62..52a131c71 100644 --- a/app/src/main/java/io/legado/app/help/http/SSLHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/SSLHelper.kt @@ -12,6 +12,7 @@ import java.security.cert.CertificateFactory import java.security.cert.X509Certificate import javax.net.ssl.* +@Suppress("unused") object SSLHelper { /** diff --git a/app/src/main/java/io/legado/app/help/permission/Permissions.kt b/app/src/main/java/io/legado/app/help/permission/Permissions.kt index 236691f7f..978541f69 100644 --- a/app/src/main/java/io/legado/app/help/permission/Permissions.kt +++ b/app/src/main/java/io/legado/app/help/permission/Permissions.kt @@ -1,5 +1,6 @@ package io.legado.app.help.permission +@Suppress("unused") object Permissions { const val READ_CALENDAR = "android.permission.READ_CALENDAR" diff --git a/app/src/main/java/io/legado/app/help/permission/PermissionsCompat.kt b/app/src/main/java/io/legado/app/help/permission/PermissionsCompat.kt index 17104108b..1d118fd0e 100644 --- a/app/src/main/java/io/legado/app/help/permission/PermissionsCompat.kt +++ b/app/src/main/java/io/legado/app/help/permission/PermissionsCompat.kt @@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import java.util.* +@Suppress("unused") class PermissionsCompat private constructor() { private var request: Request? = null @@ -16,11 +17,11 @@ class PermissionsCompat private constructor() { companion object { // 检查权限, 如果已经拥有返回 true fun check(activity: AppCompatActivity, vararg permissions: String): Boolean { - var request = Request(activity) - var pers = ArrayList() + val request = Request(activity) + val pers = ArrayList() pers.addAll(listOf(*permissions)) - var data = request.getDeniedPermissions(pers.toTypedArray()) - return data == null; + val data = request.getDeniedPermissions(pers.toTypedArray()) + return data == null } } diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index a1741c845..6648363df 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -100,7 +100,7 @@ object ImportOldData { return bookSources.size } - fun importOldReplaceRule(json: String): Int { + private fun importOldReplaceRule(json: String): Int { val rules = OldReplace.jsonToReplaceRules(json) App.db.replaceRuleDao().insert(*rules.toTypedArray()) return rules.size diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 83084d5f3..616d0d359 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -9,6 +9,7 @@ import io.legado.app.help.storage.Restore.jsonPath import io.legado.app.utils.* import java.util.regex.Pattern +@Suppress("RegExpRedundantEscape") object OldRule { private val headerPattern = Pattern.compile("@Header:\\{.+?\\}", Pattern.CASE_INSENSITIVE) private val jsPattern = Pattern.compile("\\{\\{.+?\\}\\}", Pattern.CASE_INSENSITIVE) diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index f69c5d40a..a7a3bd6d7 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -30,6 +30,7 @@ import org.jetbrains.anko.backgroundColor /** * @author Karim Abou Zeid (kabouzeid) */ +@Suppress("unused", "MemberVisibilityCanBePrivate") object ATH { @SuppressLint("CommitPrefEdits") diff --git a/app/src/main/java/io/legado/app/lib/theme/DrawableUtils.kt b/app/src/main/java/io/legado/app/lib/theme/DrawableUtils.kt index 660448088..d1bf3c499 100644 --- a/app/src/main/java/io/legado/app/lib/theme/DrawableUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/DrawableUtils.kt @@ -11,6 +11,7 @@ import androidx.core.graphics.drawable.DrawableCompat /** * @author Karim Abou Zeid (kabouzeid) */ +@Suppress("unused") object DrawableUtils { fun createTransitionDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int): TransitionDrawable { diff --git a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt index 018e3dd60..5dadc5d85 100644 --- a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package io.legado.app.lib.theme import android.annotation.SuppressLint diff --git a/app/src/main/java/io/legado/app/lib/theme/NavigationViewUtils.kt b/app/src/main/java/io/legado/app/lib/theme/NavigationViewUtils.kt index c199ba855..28def35f1 100644 --- a/app/src/main/java/io/legado/app/lib/theme/NavigationViewUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/NavigationViewUtils.kt @@ -8,6 +8,7 @@ import com.google.android.material.navigation.NavigationView /** * @author Karim Abou Zeid (kabouzeid) */ +@Suppress("unused") object NavigationViewUtils { fun setItemIconColors(navigationView: NavigationView, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) { diff --git a/app/src/main/java/io/legado/app/lib/theme/Selector.kt b/app/src/main/java/io/legado/app/lib/theme/Selector.kt index 89a71198b..f98508b62 100644 --- a/app/src/main/java/io/legado/app/lib/theme/Selector.kt +++ b/app/src/main/java/io/legado/app/lib/theme/Selector.kt @@ -13,6 +13,7 @@ import androidx.annotation.DrawableRes import androidx.annotation.IntDef import androidx.core.content.ContextCompat +@Suppress("unused") object Selector { fun shapeBuild(): ShapeSelector { return ShapeSelector() @@ -260,7 +261,8 @@ object Selector { * @author hjy * created at 2017/12/11 22:34 */ - class DrawableSelector constructor() { + @Suppress("MemberVisibilityCanBePrivate") + class DrawableSelector { private var mDefaultDrawable: Drawable? = null private var mDisabledDrawable: Drawable? = null @@ -355,7 +357,7 @@ object Selector { * @author hjy * created at 2017/12/11 22:26 */ - class ColorSelector constructor() { + class ColorSelector { private var mDefaultColor: Int = 0 private var mDisabledColor: Int = 0 diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 92ce315ed..182db2d40 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -16,6 +16,7 @@ import io.legado.app.utils.ColorUtils /** * @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid) */ +@Suppress("unused") class ThemeStore @SuppressLint("CommitPrefEdits") private constructor(private val mContext: Context) : ThemeStoreInterface { private val mEditor: SharedPreferences.Editor diff --git a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt index 76313cd46..a719cc1b1 100644 --- a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt @@ -23,6 +23,7 @@ import io.legado.app.utils.ColorUtils /** * @author afollestad, plusCubed */ +@Suppress("MemberVisibilityCanBePrivate") object TintHelper { @SuppressLint("PrivateResource") @@ -37,7 +38,10 @@ object TintHelper { ) } - private fun getDisabledColorStateList(@ColorInt normal: Int, @ColorInt disabled: Int): ColorStateList { + private fun getDisabledColorStateList( + @ColorInt normal: Int, + @ColorInt disabled: Int + ): ColorStateList { return ColorStateList( arrayOf( intArrayOf(-android.R.attr.state_enabled), @@ -61,48 +65,52 @@ object TintHelper { ) val sl: ColorStateList - if (view is Button) { - sl = getDisabledColorStateList(color, disabled) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view.getBackground() is RippleDrawable) { - val rd = view.getBackground() as RippleDrawable - rd.setColor(ColorStateList.valueOf(rippleColor)) - } + when (view) { + is Button -> { + sl = getDisabledColorStateList(color, disabled) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view.getBackground() is RippleDrawable) { + val rd = view.getBackground() as RippleDrawable + rd.setColor(ColorStateList.valueOf(rippleColor)) + } - // Disabled text color state for buttons, may get overridden later by ATE tags - view.setTextColor( - getDisabledColorStateList( - textColor, - ContextCompat.getColor( - view.getContext(), - if (useDarkTheme) R.color.ate_button_text_disabled_dark else R.color.ate_button_text_disabled_light + // Disabled text color state for buttons, may get overridden later by ATE tags + view.setTextColor( + getDisabledColorStateList( + textColor, + ContextCompat.getColor( + view.getContext(), + if (useDarkTheme) R.color.ate_button_text_disabled_dark else R.color.ate_button_text_disabled_light + ) ) ) - ) - } else if (view is FloatingActionButton) { - // FloatingActionButton doesn't support disabled state? - sl = ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_pressed), - intArrayOf(android.R.attr.state_pressed) - ), intArrayOf(color, pressed) - ) + } + is FloatingActionButton -> { + // FloatingActionButton doesn't support disabled state? + sl = ColorStateList( + arrayOf( + intArrayOf(-android.R.attr.state_pressed), + intArrayOf(android.R.attr.state_pressed) + ), intArrayOf(color, pressed) + ) - view.rippleColor = rippleColor - view.backgroundTintList = sl - if (view.drawable != null) - view.setImageDrawable(createTintedDrawable(view.drawable, textColor)) - return - } else { - sl = ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_enabled), - intArrayOf(android.R.attr.state_enabled), - intArrayOf(android.R.attr.state_enabled, android.R.attr.state_pressed), - intArrayOf(android.R.attr.state_enabled, android.R.attr.state_activated), - intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked) - ), - intArrayOf(disabled, color, pressed, activated, activated) - ) + view.rippleColor = rippleColor + view.backgroundTintList = sl + if (view.drawable != null) + view.setImageDrawable(createTintedDrawable(view.drawable, textColor)) + return + } + else -> { + sl = ColorStateList( + arrayOf( + intArrayOf(-android.R.attr.state_enabled), + intArrayOf(android.R.attr.state_enabled), + intArrayOf(android.R.attr.state_enabled, android.R.attr.state_pressed), + intArrayOf(android.R.attr.state_enabled, android.R.attr.state_activated), + intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked) + ), + intArrayOf(disabled, color, pressed, activated, activated) + ) + } } var drawable: Drawable? = view.background @@ -386,7 +394,11 @@ object TintHelper { return createTintedDrawable(from, sl) } - fun setTint(switchView: Switch, @ColorInt color: Int, useDarker: Boolean) { + fun setTint( + @SuppressLint("UseSwitchCompatOrMaterialCode") switchView: Switch, + @ColorInt color: Int, + useDarker: Boolean + ) { if (switchView.trackDrawable != null) { switchView.trackDrawable = modifySwitchDrawable( switchView.context, diff --git a/app/src/main/java/io/legado/app/lib/theme/ViewUtils.kt b/app/src/main/java/io/legado/app/lib/theme/ViewUtils.kt index f3afa243c..bcbb794a1 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ViewUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ViewUtils.kt @@ -10,6 +10,7 @@ import androidx.annotation.ColorInt /** * @author Karim Abou Zeid (kabouzeid) */ +@Suppress("unused") object ViewUtils { fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) { diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index 03fc0d974..ab4f3303c 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -14,6 +14,7 @@ import java.net.URL import java.net.URLEncoder import java.util.* +@Suppress("unused") class WebDav(urlStr: String) { companion object { // 指定返回哪些属性 @@ -60,9 +61,9 @@ class WebDav(urlStr: String) { return field } - fun getPath() = url.toString() + val path get() = url.toString() - fun getHost() = url.host + val host: String? get() = url.host /** * 填充文件信息。实例化WebDAVFile对象时,并没有将远程文件的信息填充到实例中。需要手动填充! diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt index e4c2829e8..85b4e1649 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt @@ -8,6 +8,7 @@ import io.legado.app.utils.splitNotBlank import java.util.* import java.util.regex.Pattern +@Suppress("RegExpRedundantEscape") @Keep class AnalyzeByJSonPath { private lateinit var ctx: ReadContext diff --git a/app/src/main/java/io/legado/app/model/rss/RssParserDefault.kt b/app/src/main/java/io/legado/app/model/rss/RssParserDefault.kt index 2a02c2bdc..2cb3d6c17 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParserDefault.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParserDefault.kt @@ -8,6 +8,7 @@ import org.xmlpull.v1.XmlPullParserFactory import java.io.IOException import java.io.StringReader +@Suppress("unused") object RssParserDefault { @Throws(XmlPullParserException::class, IOException::class) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 9457bff37..7610ad9d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -4,6 +4,7 @@ import android.text.TextPaint import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ChapterProvider.textHeight +@Suppress("unused") data class TextLine( var text: String = "", val textChars: ArrayList = arrayListOf(), diff --git a/app/src/main/java/io/legado/app/ui/filechooser/adapter/FileAdapter.kt b/app/src/main/java/io/legado/app/ui/filechooser/adapter/FileAdapter.kt index 4458b692e..12c45477a 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/adapter/FileAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/adapter/FileAdapter.kt @@ -23,10 +23,10 @@ class FileAdapter(context: Context, val callBack: CallBack) : private var rootPath: String? = null var currentPath: String? = null private set - private val homeIcon = ConvertUtils.toDrawable(FilePickerIcon.getHOME()) - private val upIcon = ConvertUtils.toDrawable(FilePickerIcon.getUPDIR()) - private val folderIcon = ConvertUtils.toDrawable(FilePickerIcon.getFOLDER()) - private val fileIcon = ConvertUtils.toDrawable(FilePickerIcon.getFILE()) + private val homeIcon = ConvertUtils.toDrawable(FilePickerIcon.getHome()) + private val upIcon = ConvertUtils.toDrawable(FilePickerIcon.getUpDir()) + private val folderIcon = ConvertUtils.toDrawable(FilePickerIcon.getFolder()) + private val fileIcon = ConvertUtils.toDrawable(FilePickerIcon.getFile()) private val primaryTextColor = context.getPrimaryTextColor(!AppConfig.isNightTheme) private val disabledTextColor = context.getPrimaryDisabledTextColor(!AppConfig.isNightTheme) diff --git a/app/src/main/java/io/legado/app/ui/filechooser/adapter/PathAdapter.kt b/app/src/main/java/io/legado/app/ui/filechooser/adapter/PathAdapter.kt index 86ccf67c0..9d8cf6fab 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/adapter/PathAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/adapter/PathAdapter.kt @@ -17,7 +17,7 @@ class PathAdapter(context: Context, val callBack: CallBack) : private val paths = LinkedList() @Suppress("DEPRECATION") private val sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath - private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getARROW()) + private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow()) fun getPath(position: Int): String { val tmp = StringBuilder("$sdCardDirectory/") diff --git a/app/src/main/java/io/legado/app/ui/filechooser/utils/FilePickerIcon.java b/app/src/main/java/io/legado/app/ui/filechooser/utils/FilePickerIcon.java index 6732626e4..c53ab6631 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/utils/FilePickerIcon.java +++ b/app/src/main/java/io/legado/app/ui/filechooser/utils/FilePickerIcon.java @@ -8,23 +8,23 @@ package io.legado.app.ui.filechooser.utils; */ public class FilePickerIcon { - public static byte[] getFILE() { + public static byte[] getFile() { return FILE; } - public static byte[] getFOLDER() { + public static byte[] getFolder() { return FOLDER; } - public static byte[] getHOME() { + public static byte[] getHome() { return HOME; } - public static byte[] getUPDIR() { + public static byte[] getUpDir() { return UPDIR; } - public static byte[] getARROW() { + public static byte[] getArrow() { return ARROW; }