fix: 背景图片
This commit is contained in:
@@ -7,7 +7,7 @@ import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.LocaleList
|
||||
import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.utils.getPrefInt
|
||||
import io.legado.app.ui.config.themeConfig.ThemeConfig
|
||||
import io.legado.app.utils.getPrefString
|
||||
import io.legado.app.utils.sysConfiguration
|
||||
import java.util.*
|
||||
@@ -42,7 +42,7 @@ object AppContextWrapper {
|
||||
|
||||
|
||||
fun getFontScale(context: Context): Float {
|
||||
var fontScale = context.getPrefInt(PreferKey.fontScale) / 10f
|
||||
var fontScale = ThemeConfig.fontScale / 10f
|
||||
if (fontScale !in 0.8f..1.6f) {
|
||||
fontScale = sysConfiguration.fontScale
|
||||
}
|
||||
|
||||
@@ -853,10 +853,10 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
}
|
||||
|
||||
val hasLightBg: Boolean
|
||||
get() = !appCtx.getPrefString(PreferKey.bgImage).isNullOrEmpty()
|
||||
get() = !ThemeConfig.bgImageLight.isNullOrEmpty()
|
||||
|
||||
val hasDarkBg: Boolean
|
||||
get() = !appCtx.getPrefString(PreferKey.bgImageN).isNullOrEmpty()
|
||||
get() = !ThemeConfig.bgImageDark.isNullOrEmpty()
|
||||
|
||||
val hasImageBg: Boolean
|
||||
get() = hasLightBg && hasDarkBg
|
||||
|
||||
@@ -60,13 +60,13 @@ object ThemeConfigStore {
|
||||
fun getBgImage(context: Context, metrics: DisplayMetrics): Bitmap? {
|
||||
val bgCfg = when (getTheme()) {
|
||||
Theme.Light -> Pair(
|
||||
context.getPrefString(PreferKey.bgImage),
|
||||
context.getPrefInt(PreferKey.bgImageBlurring, 0)
|
||||
ThemeConfig.bgImageLight,
|
||||
ThemeConfig.bgImageBlurring
|
||||
)
|
||||
|
||||
Theme.Dark -> Pair(
|
||||
context.getPrefString(PreferKey.bgImageN),
|
||||
context.getPrefInt(PreferKey.bgImageNBlurring, 0)
|
||||
ThemeConfig.bgImageDark,
|
||||
ThemeConfig.bgImageNBlurring
|
||||
)
|
||||
|
||||
else -> null
|
||||
@@ -146,13 +146,13 @@ object ThemeConfigStore {
|
||||
* 清理无用背景图片
|
||||
*/
|
||||
fun clearBg() {
|
||||
val bgImagePath = appCtx.getPrefString(PreferKey.bgImage)
|
||||
val bgImagePath = ThemeConfig.bgImageLight
|
||||
appCtx.externalFiles.getFile(PreferKey.bgImage).listFiles()?.forEach {
|
||||
if (it.absolutePath != bgImagePath) {
|
||||
it.delete()
|
||||
}
|
||||
}
|
||||
val bgImageNPath = appCtx.getPrefString(PreferKey.bgImageN)
|
||||
val bgImageNPath = ThemeConfig.bgImageDark
|
||||
appCtx.externalFiles.getFile(PreferKey.bgImageN).listFiles()?.forEach {
|
||||
if (it.absolutePath != bgImageNPath) {
|
||||
it.delete()
|
||||
@@ -184,9 +184,9 @@ object ThemeConfigStore {
|
||||
val bBackground =
|
||||
context.getPrefInt(PreferKey.cBBackground, context.getCompatColor(R.color.md_grey_200))
|
||||
val bgImgPath =
|
||||
context.getPrefString(PreferKey.bgImage)
|
||||
ThemeConfig.bgImageLight
|
||||
val bgImgBlur =
|
||||
context.getPrefInt(PreferKey.bgImageBlurring, 0)
|
||||
ThemeConfig.bgImageBlurring
|
||||
|
||||
return Config(
|
||||
themeName = name,
|
||||
@@ -216,9 +216,9 @@ object ThemeConfigStore {
|
||||
val bBackground =
|
||||
context.getPrefInt(PreferKey.cNBBackground, context.getCompatColor(R.color.md_grey_850))
|
||||
val bgImgPath =
|
||||
context.getPrefString(PreferKey.bgImageN)
|
||||
ThemeConfig.bgImageDark
|
||||
val bgImgBlur =
|
||||
context.getPrefInt(PreferKey.bgImageNBlurring, 0)
|
||||
ThemeConfig.bgImageNBlurring
|
||||
return Config(
|
||||
themeName = name,
|
||||
isNightTheme = true,
|
||||
|
||||
@@ -83,8 +83,8 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
|
||||
holder.card.setOnClickListener {
|
||||
if (value != currentValue) {
|
||||
if (value == "13") {
|
||||
val hasLightBg = !appCtx.getPrefString(PreferKey.bgImage).isNullOrEmpty()
|
||||
val hasDarkBg = !appCtx.getPrefString(PreferKey.bgImageN).isNullOrEmpty()
|
||||
val hasLightBg = !ThemeConfig.bgImageLight.isNullOrEmpty()
|
||||
val hasDarkBg = !ThemeConfig.bgImageDark.isNullOrEmpty()
|
||||
if (!hasLightBg || !hasDarkBg) {
|
||||
context.toastOnUi(R.string.transparent_theme_alarm)
|
||||
return@setOnClickListener
|
||||
|
||||
Reference in New Issue
Block a user