|
|
@ -37,13 +37,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
sharedPreferences ?: return |
|
|
|
sharedPreferences ?: return |
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|
"colorPrimary", "colorAccent", "colorBackground" -> |
|
|
|
"colorPrimary", "colorAccent", "colorBackground" -> |
|
|
|
if (!ColorUtils.isColorLight( |
|
|
|
if (backgroundIsDark(sharedPreferences)) { |
|
|
|
sharedPreferences.getInt( |
|
|
|
|
|
|
|
"colorBackground", |
|
|
|
|
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_100) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
activity?.let { |
|
|
|
activity?.let { |
|
|
|
AlertDialog.Builder(it) |
|
|
|
AlertDialog.Builder(it) |
|
|
|
.setTitle("白天背景太暗") |
|
|
|
.setTitle("白天背景太暗") |
|
|
@ -62,13 +56,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
upTheme(false) |
|
|
|
upTheme(false) |
|
|
|
} |
|
|
|
} |
|
|
|
"colorPrimaryNight", "colorAccentNight", "colorBackgroundNight" -> |
|
|
|
"colorPrimaryNight", "colorAccentNight", "colorBackgroundNight" -> |
|
|
|
if (ColorUtils.isColorLight( |
|
|
|
if (backgroundIsLight(sharedPreferences)) { |
|
|
|
sharedPreferences.getInt( |
|
|
|
|
|
|
|
"colorBackgroundNight", |
|
|
|
|
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_800) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
activity?.let { |
|
|
|
activity?.let { |
|
|
|
AlertDialog.Builder(it) |
|
|
|
AlertDialog.Builder(it) |
|
|
|
.setTitle("夜间背景太亮") |
|
|
|
.setTitle("夜间背景太亮") |
|
|
@ -118,6 +106,24 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { |
|
|
|
|
|
|
|
return !ColorUtils.isColorLight( |
|
|
|
|
|
|
|
sharedPreferences.getInt( |
|
|
|
|
|
|
|
"colorBackground", |
|
|
|
|
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_100) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean { |
|
|
|
|
|
|
|
return ColorUtils.isColorLight( |
|
|
|
|
|
|
|
sharedPreferences.getInt( |
|
|
|
|
|
|
|
"colorBackgroundNight", |
|
|
|
|
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_800) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upTheme(isNightTheme: Boolean) { |
|
|
|
private fun upTheme(isNightTheme: Boolean) { |
|
|
|
if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) { |
|
|
|
if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) { |
|
|
|
App.INSTANCE.upThemeStore() |
|
|
|
App.INSTANCE.upThemeStore() |
|
|
|