feat: 优化

pull/254/head
gedoor 4 years ago
parent ede9917488
commit d3da122d30
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 4
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 7
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@ -45,6 +45,7 @@ object PreferKey {
const val readBodyToLh = "readBodyToLh"
const val textFullJustify = "textFullJustify"
const val autoReadSpeed = "autoReadSpeed"
const val barElevation = "barElevation"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

@ -125,11 +125,11 @@ object AppConfig {
var elevation: Int
@SuppressLint("PrivateResource")
get() = App.INSTANCE.getPrefInt(
"elevation",
PreferKey.barElevation,
App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
)
set(value) {
App.INSTANCE.putPrefInt("elevation", value)
App.INSTANCE.putPrefInt(PreferKey.barElevation, value)
}
val autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true)

@ -38,7 +38,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
preferenceScreen.removePreference(it)
}
}
upPreferenceSummary("barElevation", AppConfig.elevation.toString())
upPreferenceSummary(PreferKey.barElevation, AppConfig.elevation.toString())
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -133,7 +133,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
"defaultTheme" -> changeTheme()
"barElevation" -> NumberPickerDialog(requireContext())
PreferKey.barElevation -> NumberPickerDialog(requireContext())
.setTitle(getString(R.string.bar_elevation))
.setMaxValue(32)
.setMinValue(0)
@ -231,7 +231,8 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
private fun upPreferenceSummary(preferenceKey: String, value: String?) {
val preference = findPreference<Preference>(preferenceKey) ?: return
when (preferenceKey) {
"barElevation" -> preference.summary = getString(R.string.bar_elevation_s, value)
PreferKey.barElevation -> preference.summary =
getString(R.string.bar_elevation_s, value)
}
}
}
Loading…
Cancel
Save