添加总是显示默认封面配置

pull/985/head
gedoor 4 years ago
parent 106c30e1ae
commit a0d282453f
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 59
      app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt
  4. 2
      app/src/main/res/values-zh-rHK/strings.xml
  5. 2
      app/src/main/res/values-zh-rTW/strings.xml
  6. 2
      app/src/main/res/values-zh/strings.xml
  7. 2
      app/src/main/res/values/strings.xml
  8. 9
      app/src/main/res/xml/pref_config_other.xml

@ -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"

@ -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)

@ -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<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
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<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
loadFailed = true
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
loadFailed = false
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
loadFailed = false
return false
}
})
.centerCrop()
.into(this)
})
.centerCrop()
.into(this)
}
}
companion object {

@ -825,5 +825,7 @@
<string name="export_all">导出所有</string>
<string name="complete">完成</string>
<string name="show_unread">显示未读标志</string>
<string name="use_default_cover">总是使用默认封面</string>
<string name="use_default_cover_s">总是显示默认封面,不显示网络封面</string>
</resources>

@ -829,5 +829,7 @@
<string name="export_all">导出所有</string>
<string name="complete">完成</string>
<string name="show_unread">显示未读标志</string>
<string name="use_default_cover">总是使用默认封面</string>
<string name="use_default_cover_s">总是显示默认封面,不显示网络封面</string>
</resources>

@ -829,5 +829,7 @@
<string name="export_all">导出所有</string>
<string name="complete">完成</string>
<string name="show_unread">显示未读标志</string>
<string name="use_default_cover">总是使用默认封面</string>
<string name="use_default_cover_s">总是显示默认封面,不显示网络封面</string>
</resources>

@ -830,5 +830,7 @@
<string name="export_all">export_all</string>
<string name="complete">complete</string>
<string name="show_unread">Show unread</string>
<string name="use_default_cover">always use default cover</string>
<string name="use_default_cover_s">always use default cover,not use network</string>
</resources>

@ -43,6 +43,15 @@
app:allowDividerBelow="false"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="useDefaultCover"
android:title="@string/use_default_cover"
android:summary="@string/use_default_cover_s"
app:allowDividerAbove="false"
app:allowDividerBelow="false"
app:iconSpaceReserved="false" />
</io.legado.app.ui.widget.prefs.PreferenceCategory>
<io.legado.app.ui.widget.prefs.PreferenceCategory

Loading…
Cancel
Save