feat: 修复夜间底栏颜色调整无效的bug

pull/274/head
gedoor 4 years ago
parent daefd81e80
commit b15e0e0711
  1. 2
      app/src/main/java/io/legado/app/App.kt
  2. 25
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@ -97,7 +97,7 @@ class App : Application() {
} }
var bBackground = var bBackground =
getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
if (!ColorUtils.isColorLight(bBackground)) { if (ColorUtils.isColorLight(bBackground)) {
bBackground = getCompatColor(R.color.md_grey_850) bBackground = getCompatColor(R.color.md_grey_850)
putPrefInt(PreferKey.cNBBackground, bBackground) putPrefInt(PreferKey.cNBBackground, bBackground)
} }

@ -26,6 +26,7 @@ import io.legado.app.ui.widget.prefs.IconListPreference
import io.legado.app.utils.* import io.legado.app.utils.*
@Suppress("SameParameterValue")
class ThemeConfigFragment : PreferenceFragmentCompat(), class ThemeConfigFragment : PreferenceFragmentCompat(),
SharedPreferences.OnSharedPreferenceChangeListener { SharedPreferences.OnSharedPreferenceChangeListener {
@ -86,13 +87,8 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
title = "白天背景太暗" title = "白天背景太暗"
message = "将会恢复默认背景?" message = "将会恢复默认背景?"
yesButton { yesButton {
putPrefInt(
PreferKey.cBackground,
getCompatColor(R.color.md_grey_100)
)
upTheme(false) upTheme(false)
} }
noButton { noButton {
upTheme(false) upTheme(false)
} }
@ -110,13 +106,8 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
title = "夜间背景太亮" title = "夜间背景太亮"
message = "将会恢复默认背景?" message = "将会恢复默认背景?"
yesButton { yesButton {
putPrefInt(
PreferKey.cNBackground,
getCompatColor(R.color.md_grey_800)
)
upTheme(true) upTheme(true)
} }
noButton { noButton {
upTheme(true) upTheme(true)
} }
@ -199,19 +190,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean {
return !ColorUtils.isColorLight( return !ColorUtils.isColorLight(
sharedPreferences.getInt( sharedPreferences.getInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100))
PreferKey.cBackground, ) && !ColorUtils.isColorLight(
getCompatColor(R.color.md_grey_100) sharedPreferences.getInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200))
)
) )
} }
private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean { private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean {
return ColorUtils.isColorLight( return ColorUtils.isColorLight(
sharedPreferences.getInt( sharedPreferences.getInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_800))
PreferKey.cNBackground, ) && ColorUtils.isColorLight(
getCompatColor(R.color.md_grey_800) sharedPreferences.getInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
)
) )
} }

Loading…
Cancel
Save