|
|
@ -132,45 +132,62 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), |
|
|
|
@SuppressLint("PrivateResource") |
|
|
|
@SuppressLint("PrivateResource") |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
when (preference?.key) { |
|
|
|
when (preference?.key) { |
|
|
|
"defaultTheme" -> alert(title = "切换默认主题") { |
|
|
|
"defaultTheme" -> changeTheme() |
|
|
|
|
|
|
|
"barElevation" -> NumberPickerDialog(requireContext()) |
|
|
|
|
|
|
|
.setTitle(getString(R.string.bar_elevation)) |
|
|
|
|
|
|
|
.setMaxValue(32) |
|
|
|
|
|
|
|
.setMinValue(0) |
|
|
|
|
|
|
|
.setValue(AppConfig.elevation) |
|
|
|
|
|
|
|
.setCustomButton((R.string.btn_default_s)) { |
|
|
|
|
|
|
|
AppConfig.elevation = |
|
|
|
|
|
|
|
App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() |
|
|
|
|
|
|
|
recreateActivities() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.show { |
|
|
|
|
|
|
|
AppConfig.elevation = it |
|
|
|
|
|
|
|
recreateActivities() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun changeTheme() { |
|
|
|
|
|
|
|
alert(title = "切换默认主题") { |
|
|
|
items(items) { _, which -> |
|
|
|
items(items) { _, which -> |
|
|
|
when (which) { |
|
|
|
when (which) { |
|
|
|
0 -> { |
|
|
|
0 -> { |
|
|
|
putPrefInt("colorPrimary", getCompatColor(R.color.md_grey_100)) |
|
|
|
putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_grey_100)) |
|
|
|
putPrefInt("colorAccent", getCompatColor(R.color.lightBlue_color)) |
|
|
|
putPrefInt(PreferKey.cAccent, getCompatColor(R.color.lightBlue_color)) |
|
|
|
putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) |
|
|
|
putPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) |
|
|
|
|
|
|
|
putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
} |
|
|
|
} |
|
|
|
1 -> { |
|
|
|
1 -> { |
|
|
|
putPrefInt("colorPrimaryNight", getCompatColor(R.color.shine_color)) |
|
|
|
putPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_grey_900)) |
|
|
|
putPrefInt("colorAccentNight", getCompatColor(R.color.lightBlue_color)) |
|
|
|
putPrefInt(PreferKey.cNAccent, getCompatColor(R.color.lightBlue_color)) |
|
|
|
putPrefInt("colorBackgroundNight", getCompatColor(R.color.shine_color)) |
|
|
|
putPrefInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_900)) |
|
|
|
|
|
|
|
putPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_900)) |
|
|
|
AppConfig.isNightTheme = true |
|
|
|
AppConfig.isNightTheme = true |
|
|
|
} |
|
|
|
} |
|
|
|
2 -> { |
|
|
|
2 -> { |
|
|
|
putPrefInt("colorPrimary", getCompatColor(R.color.md_light_blue_500)) |
|
|
|
putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_light_blue_500)) |
|
|
|
putPrefInt("colorAccent", getCompatColor(R.color.md_pink_800)) |
|
|
|
putPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_pink_800)) |
|
|
|
putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) |
|
|
|
putPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) |
|
|
|
|
|
|
|
putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
} |
|
|
|
} |
|
|
|
3 -> { |
|
|
|
3 -> { |
|
|
|
putPrefInt("colorPrimary", getCompatColor(R.color.white)) |
|
|
|
putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.white)) |
|
|
|
putPrefInt("colorAccent", getCompatColor(R.color.black)) |
|
|
|
putPrefInt(PreferKey.cAccent, getCompatColor(R.color.black)) |
|
|
|
putPrefInt("colorBackground", getCompatColor(R.color.white)) |
|
|
|
putPrefInt(PreferKey.cBackground, getCompatColor(R.color.white)) |
|
|
|
putPrefInt("colorBottomBackground", getCompatColor(R.color.white)) |
|
|
|
putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.white)) |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
AppConfig.isNightTheme = false |
|
|
|
} |
|
|
|
} |
|
|
|
4 -> { |
|
|
|
4 -> { |
|
|
|
putPrefInt("colorPrimaryNight", getCompatColor(R.color.black)) |
|
|
|
putPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.black)) |
|
|
|
putPrefInt( |
|
|
|
putPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_grey_500)) |
|
|
|
"colorAccentNight", |
|
|
|
putPrefInt(PreferKey.cNBackground, getCompatColor(R.color.black)) |
|
|
|
getCompatColor(R.color.md_grey_500) |
|
|
|
putPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.black)) |
|
|
|
) |
|
|
|
|
|
|
|
putPrefInt( |
|
|
|
|
|
|
|
"colorBackgroundNight", |
|
|
|
|
|
|
|
getCompatColor(R.color.black) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
putPrefInt("colorBottomBackgroundNight", getCompatColor(R.color.black)) |
|
|
|
|
|
|
|
AppConfig.isNightTheme = true |
|
|
|
AppConfig.isNightTheme = true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -178,21 +195,6 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), |
|
|
|
recreateActivities() |
|
|
|
recreateActivities() |
|
|
|
} |
|
|
|
} |
|
|
|
}.show().applyTint() |
|
|
|
}.show().applyTint() |
|
|
|
"barElevation" -> NumberPickerDialog(requireContext()) |
|
|
|
|
|
|
|
.setTitle(getString(R.string.bar_elevation)) |
|
|
|
|
|
|
|
.setMaxValue(32) |
|
|
|
|
|
|
|
.setMinValue(0) |
|
|
|
|
|
|
|
.setValue(AppConfig.elevation) |
|
|
|
|
|
|
|
.setCustomButton((R.string.btn_default_s)) { |
|
|
|
|
|
|
|
AppConfig.elevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() |
|
|
|
|
|
|
|
recreateActivities() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.show { |
|
|
|
|
|
|
|
AppConfig.elevation = it |
|
|
|
|
|
|
|
recreateActivities() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { |
|
|
|
private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { |
|
|
|