pull/32/head
GKF 6 years ago
parent 4bf2279d1a
commit 5ea88df3c5
  1. 20
      app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt

@ -7,11 +7,13 @@ import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.ui.about.AboutActivity import io.legado.app.ui.about.AboutActivity
import io.legado.app.ui.about.DonateActivity
import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigActivity
import io.legado.app.ui.config.ConfigViewModel import io.legado.app.ui.config.ConfigViewModel
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { class PreferenceFragment : PreferenceFragmentCompat(),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_main) addPreferencesFromResource(R.xml.pref_main)
@ -38,22 +40,18 @@ class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnShare
override fun onPreferenceTreeClick(preference: Preference?): Boolean { override fun onPreferenceTreeClick(preference: Preference?): Boolean {
preference?.let { preference?.let {
when (preference.key) { when (preference.key) {
"setting" -> { "setting" -> context?.startActivity<ConfigActivity>(
requireContext().startActivity<ConfigActivity>(
Pair("configType", ConfigViewModel.TYPE_CONFIG) Pair("configType", ConfigViewModel.TYPE_CONFIG)
) )
} "web_dav_setting" -> context?.startActivity<ConfigActivity>(
"web_dav_setting" -> {
requireContext().startActivity<ConfigActivity>(
Pair("configType", ConfigViewModel.TYPE_WEB_DAV_CONFIG) Pair("configType", ConfigViewModel.TYPE_WEB_DAV_CONFIG)
) )
} "theme_setting" -> context?.startActivity<ConfigActivity>(
"theme_setting" -> {
requireContext().startActivity<ConfigActivity>(
Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG) Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG)
) )
} "donate" -> context?.startActivity<DonateActivity>()
"about" -> requireContext().startActivity<AboutActivity>() "about" -> context?.startActivity<AboutActivity>()
else -> null
} }
} }
return super.onPreferenceTreeClick(preference) return super.onPreferenceTreeClick(preference)

Loading…
Cancel
Save