feat: 优化

pull/254/head
gedoor 4 years ago
parent 9dde645644
commit 7a52ea78b9
  1. 24
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@ -77,17 +77,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
when (key) { when (key) {
PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key)) PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key))
"transparentStatusBar" -> recreateActivities() "transparentStatusBar" -> recreateActivities()
"colorPrimary", PreferKey.cPrimary,
"colorAccent", PreferKey.cAccent,
"colorBackground", PreferKey.cBackground,
"colorBottomBackground" -> { PreferKey.cBBackground -> {
if (backgroundIsDark(sharedPreferences)) { if (backgroundIsDark(sharedPreferences)) {
alert { alert {
title = "白天背景太暗" title = "白天背景太暗"
message = "将会恢复默认背景?" message = "将会恢复默认背景?"
yesButton { yesButton {
putPrefInt( putPrefInt(
"colorBackground", PreferKey.cBackground,
getCompatColor(R.color.md_grey_100) getCompatColor(R.color.md_grey_100)
) )
upTheme(false) upTheme(false)
@ -101,17 +101,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
upTheme(false) upTheme(false)
} }
} }
"colorPrimaryNight", PreferKey.cNPrimary,
"colorAccentNight", PreferKey.cNAccent,
"colorBackgroundNight", PreferKey.cNBackground,
"colorBottomBackgroundNight" -> { PreferKey.cNBBackground -> {
if (backgroundIsLight(sharedPreferences)) { if (backgroundIsLight(sharedPreferences)) {
alert { alert {
title = "夜间背景太亮" title = "夜间背景太亮"
message = "将会恢复默认背景?" message = "将会恢复默认背景?"
yesButton { yesButton {
putPrefInt( putPrefInt(
"colorBackgroundNight", PreferKey.cNBackground,
getCompatColor(R.color.md_grey_800) getCompatColor(R.color.md_grey_800)
) )
upTheme(true) upTheme(true)
@ -200,7 +200,7 @@ 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(
"colorBackground", PreferKey.cBackground,
getCompatColor(R.color.md_grey_100) getCompatColor(R.color.md_grey_100)
) )
) )
@ -209,7 +209,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean { private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean {
return ColorUtils.isColorLight( return ColorUtils.isColorLight(
sharedPreferences.getInt( sharedPreferences.getInt(
"colorBackgroundNight", PreferKey.cNBackground,
getCompatColor(R.color.md_grey_800) getCompatColor(R.color.md_grey_800)
) )
) )

Loading…
Cancel
Save