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 =
getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
if (!ColorUtils.isColorLight(bBackground)) {
if (ColorUtils.isColorLight(bBackground)) {
bBackground = getCompatColor(R.color.md_grey_850)
putPrefInt(PreferKey.cNBBackground, bBackground)
}

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

Loading…
Cancel
Save