From a0d282453f3277cea456f7d6eaff901fe97d72cb Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 14 May 2021 10:24:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=80=BB=E6=98=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=BB=98=E8=AE=A4=E5=B0=81=E9=9D=A2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../main/java/io/legado/app/help/AppConfig.kt | 3 + .../app/ui/widget/image/CoverImageView.kt | 59 +++++++++++-------- app/src/main/res/values-zh-rHK/strings.xml | 2 + app/src/main/res/values-zh-rTW/strings.xml | 2 + app/src/main/res/values-zh/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/pref_config_other.xml | 9 +++ 8 files changed, 54 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index f60b7c361..70b4a6b89 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -5,6 +5,7 @@ object PreferKey { const val themeMode = "themeMode" const val userAgent = "userAgent" const val showUnread = "showUnread" + const val useDefaultCover = "useDefaultCover" const val hideStatusBar = "hideStatusBar" const val clickActionTL = "clickActionTopLeft" const val clickActionTC = "clickActionTopCenter" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 102f9507c..b2c620f63 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -78,6 +78,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefBoolean(PreferKey.showUnread, value) } + val useDefaultCover: Boolean + get() = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false) + val isTransparentStatusBar: Boolean get() = appCtx.getPrefBoolean(PreferKey.transparentStatusBar, true) diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 24bdd08fd..ac4b6159d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -12,6 +12,7 @@ import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target import io.legado.app.R import io.legado.app.constant.PreferKey +import io.legado.app.help.AppConfig import io.legado.app.help.ImageLoader import io.legado.app.utils.getPrefString import splitties.init.appCtx @@ -132,34 +133,40 @@ class CoverImageView @JvmOverloads constructor( fun load(path: String?, name: String?, author: String?) { setText(name, author) - ImageLoader.load(context, path)//Glide自动识别http://,content://和file:// - .placeholder(defaultDrawable) - .error(defaultDrawable) - .listener(object : RequestListener { - override fun onLoadFailed( - e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean - ): Boolean { - loadFailed = true - return false - } + if (AppConfig.useDefaultCover) { + ImageLoader.load(context, defaultDrawable) + .centerCrop() + .into(this) + } else { + ImageLoader.load(context, path)//Glide自动识别http://,content://和file:// + .placeholder(defaultDrawable) + .error(defaultDrawable) + .listener(object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + loadFailed = true + return false + } - override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean - ): Boolean { - loadFailed = false - return false - } + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + loadFailed = false + return false + } - }) - .centerCrop() - .into(this) + }) + .centerCrop() + .into(this) + } } companion object { diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 302969db3..00e5789b7 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -825,5 +825,7 @@ 导出所有 完成 显示未读标志 + 总是使用默认封面 + 总是显示默认封面,不显示网络封面 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b826956ca..55ac557d9 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -829,5 +829,7 @@ 导出所有 完成 显示未读标志 + 总是使用默认封面 + 总是显示默认封面,不显示网络封面 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 1f17b8764..1da9bdf53 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -829,5 +829,7 @@ 导出所有 完成 显示未读标志 + 总是使用默认封面 + 总是显示默认封面,不显示网络封面 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd76c1764..8e891cbb0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -830,5 +830,7 @@ export_all complete Show unread + always use default cover + always use default cover,not use network diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 8dadf0940..32b5aa3c1 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -43,6 +43,15 @@ app:allowDividerBelow="false" app:iconSpaceReserved="false" /> + +