diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index b3c6f6d68..3e28526c5 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.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" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 5e98ae482..bf8713c8c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -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) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 81fc16204..6d9d94027 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -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(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) } } } \ No newline at end of file