|
|
@ -35,7 +35,6 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
sharedPreferences ?: return |
|
|
|
sharedPreferences ?: return |
|
|
|
activity ?: return |
|
|
|
|
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|
"colorPrimary", "colorAccent", "colorBackground" -> |
|
|
|
"colorPrimary", "colorAccent", "colorBackground" -> |
|
|
|
if (!ColorUtils.isColorLight( |
|
|
|
if (!ColorUtils.isColorLight( |
|
|
@ -45,15 +44,20 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
AlertDialog.Builder(activity!!) |
|
|
|
activity?.let { |
|
|
|
.setTitle("白天背景太暗") |
|
|
|
AlertDialog.Builder(it) |
|
|
|
.setMessage("将会恢复默认背景?") |
|
|
|
.setTitle("白天背景太暗") |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
.setMessage("将会恢复默认背景?") |
|
|
|
App.INSTANCE.putPrefInt("colorBackground", App.INSTANCE.getCompatColor(R.color.md_grey_100)) |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
upTheme(false) |
|
|
|
App.INSTANCE.putPrefInt( |
|
|
|
} |
|
|
|
"colorBackground", |
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(false) } |
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_100) |
|
|
|
.show().upTint |
|
|
|
) |
|
|
|
|
|
|
|
upTheme(false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(false) } |
|
|
|
|
|
|
|
.show().upTint |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
upTheme(false) |
|
|
|
upTheme(false) |
|
|
|
} |
|
|
|
} |
|
|
@ -65,18 +69,20 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
AlertDialog.Builder(activity!!) |
|
|
|
activity?.let { |
|
|
|
.setTitle("夜间背景太亮") |
|
|
|
AlertDialog.Builder(it) |
|
|
|
.setMessage("将会恢复默认背景?") |
|
|
|
.setTitle("夜间背景太亮") |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
.setMessage("将会恢复默认背景?") |
|
|
|
App.INSTANCE.putPrefInt( |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
"colorBackgroundNight", |
|
|
|
App.INSTANCE.putPrefInt( |
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_800) |
|
|
|
"colorBackgroundNight", |
|
|
|
) |
|
|
|
App.INSTANCE.getCompatColor(R.color.md_grey_800) |
|
|
|
upTheme(true) |
|
|
|
) |
|
|
|
} |
|
|
|
upTheme(true) |
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(true) } |
|
|
|
} |
|
|
|
.show() |
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(true) } |
|
|
|
|
|
|
|
.show().upTint |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
upTheme(true) |
|
|
|
upTheme(true) |
|
|
|
} |
|
|
|
} |
|
|
@ -87,25 +93,26 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
when (preference?.key) { |
|
|
|
when (preference?.key) { |
|
|
|
"defaultTheme" -> { |
|
|
|
"defaultTheme" -> { |
|
|
|
AlertDialog.Builder(activity!!) |
|
|
|
activity?.let { |
|
|
|
.setTitle("恢复默认主题") |
|
|
|
AlertDialog.Builder(it) |
|
|
|
.setMessage("是否确认恢复?") |
|
|
|
.setTitle("恢复默认主题") |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
.setMessage("是否确认恢复?") |
|
|
|
preferenceManager.sharedPreferences.edit() |
|
|
|
.setPositiveButton(R.string.ok) { _, _ -> |
|
|
|
.putInt("colorPrimary", App.INSTANCE.getCompatColor(R.color.md_grey_100)) |
|
|
|
preferenceManager.sharedPreferences.edit() |
|
|
|
.putInt("colorAccent", App.INSTANCE.getCompatColor(R.color.md_pink_600)) |
|
|
|
.putInt("colorPrimary", App.INSTANCE.getCompatColor(R.color.md_grey_100)) |
|
|
|
.putInt("colorBackground", App.INSTANCE.getCompatColor(R.color.md_grey_100)) |
|
|
|
.putInt("colorAccent", App.INSTANCE.getCompatColor(R.color.md_pink_600)) |
|
|
|
.putInt("colorPrimaryNight", App.INSTANCE.getCompatColor(R.color.md_grey_800)) |
|
|
|
.putInt("colorBackground", App.INSTANCE.getCompatColor(R.color.md_grey_100)) |
|
|
|
.putInt("colorAccentNight", App.INSTANCE.getCompatColor(R.color.md_pink_800)) |
|
|
|
.putInt("colorPrimaryNight", App.INSTANCE.getCompatColor(R.color.md_grey_800)) |
|
|
|
.putInt("colorBackgroundNight", App.INSTANCE.getCompatColor(R.color.md_grey_800)) |
|
|
|
.putInt("colorAccentNight", App.INSTANCE.getCompatColor(R.color.md_pink_800)) |
|
|
|
.apply() |
|
|
|
.putInt("colorBackgroundNight", App.INSTANCE.getCompatColor(R.color.md_grey_800)) |
|
|
|
App.INSTANCE.upThemeStore() |
|
|
|
.apply() |
|
|
|
LiveEventBus.get().with(Bus.recreate).post("") |
|
|
|
App.INSTANCE.upThemeStore() |
|
|
|
Handler().postDelayed({ activity?.recreate() }, 100) |
|
|
|
LiveEventBus.get().with(Bus.recreate).post("") |
|
|
|
} |
|
|
|
Handler().postDelayed({ activity?.recreate() }, 100) |
|
|
|
.setNegativeButton(R.string.cancel, null) |
|
|
|
} |
|
|
|
.show() |
|
|
|
.setNegativeButton(R.string.cancel, null) |
|
|
|
.upTint |
|
|
|
.show().upTint |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|