pull/32/head
gedoor 6 years ago
parent 5b1f4ad4a2
commit a7c6e1ba62
  1. 23
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

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

Loading…
Cancel
Save