From f94b843d92543a8b3139ad74264a1d31e1c38d31 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 5 Jun 2019 19:59:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/config/ConfigActivity.kt | 13 +++++++-- .../legado/app/ui/config/ConfigViewModel.kt | 1 + .../app/ui/config/WebDavConfigFragment.kt | 13 +++++++++ .../ui/main/myconfig/PreferenceFragment.kt | 13 ++++++--- app/src/main/res/xml/pref_config_web_dav.xml | 29 +++++++++++++++++++ app/src/main/res/xml/pref_main.xml | 6 ++++ 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt create mode 100644 app/src/main/res/xml/pref_config_web_dav.xml diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt index d4fc7734e..4c7d1552c 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt @@ -22,11 +22,20 @@ class ConfigActivity : BaseActivity() { when (viewModel.configType) { ConfigViewModel.TYPE_CONFIG -> { title_bar.title = "设置" - supportFragmentManager.beginTransaction().replace(R.id.configFrameLayout, ConfigFragment()).commit() + supportFragmentManager.beginTransaction() + .replace(R.id.configFrameLayout, ConfigFragment()) + .commit() } ConfigViewModel.TYPE_THEME_CONFIG -> { title_bar.title = "主题设置" - supportFragmentManager.beginTransaction().replace(R.id.configFrameLayout, ThemeConfigFragment()) + supportFragmentManager.beginTransaction() + .replace(R.id.configFrameLayout, ThemeConfigFragment()) + .commit() + } + ConfigViewModel.TYPE_WEBDAV_CONFIG -> { + title_bar.title = "WebDav设置" + supportFragmentManager.beginTransaction() + .replace(R.id.configFrameLayout, WebDavConfigFragment()) .commit() } } diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt b/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt index b9a085099..79fca0303 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt @@ -7,6 +7,7 @@ class ConfigViewModel(application: Application) : AndroidViewModel(application) companion object { val TYPE_CONFIG = 0 val TYPE_THEME_CONFIG = 1 + val TYPE_WEBDAV_CONFIG = 2 } var configType: Int = TYPE_CONFIG diff --git a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt new file mode 100644 index 000000000..d933ea16d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt @@ -0,0 +1,13 @@ +package io.legado.app.ui.config + +import android.os.Bundle +import androidx.preference.PreferenceFragmentCompat +import io.legado.app.R + +class WebDavConfigFragment : PreferenceFragmentCompat() { + + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + addPreferencesFromResource(R.xml.pref_config_web_dav) + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt b/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt index c6ec73393..f3daf9c21 100644 --- a/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt @@ -38,13 +38,18 @@ class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnShare preference?.let { when (preference.key) { "setting" -> { + requireContext().startActivity( + Pair("configType", ConfigViewModel.TYPE_CONFIG) + ) + } + "web_dav_setting" -> { + requireContext().startActivity( + Pair("configType", ConfigViewModel.TYPE_WEBDAV_CONFIG) + ) } "theme_setting" -> { requireContext().startActivity( - Pair( - "configType", - ConfigViewModel.TYPE_THEME_CONFIG - ) + Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG) ) } } diff --git a/app/src/main/res/xml/pref_config_web_dav.xml b/app/src/main/res/xml/pref_config_web_dav.xml new file mode 100644 index 000000000..e2584df4f --- /dev/null +++ b/app/src/main/res/xml/pref_config_web_dav.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index ba6f6ac78..52da7f3a8 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -9,6 +9,12 @@ android:summary="与功能相关的一些设置" app:iconSpaceReserved="false"/> + +