pull/32/head
gedoor 6 years ago
parent e3b9686fc5
commit f94b843d92
  1. 13
      app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
  2. 1
      app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt
  3. 13
      app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt
  4. 13
      app/src/main/java/io/legado/app/ui/main/myconfig/PreferenceFragment.kt
  5. 29
      app/src/main/res/xml/pref_config_web_dav.xml
  6. 6
      app/src/main/res/xml/pref_main.xml

@ -22,11 +22,20 @@ class ConfigActivity : BaseActivity<ConfigViewModel>() {
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()
}
}

@ -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

@ -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)
}
}

@ -38,13 +38,18 @@ class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnShare
preference?.let {
when (preference.key) {
"setting" -> {
requireContext().startActivity<ConfigActivity>(
Pair("configType", ConfigViewModel.TYPE_CONFIG)
)
}
"web_dav_setting" -> {
requireContext().startActivity<ConfigActivity>(
Pair("configType", ConfigViewModel.TYPE_WEBDAV_CONFIG)
)
}
"theme_setting" -> {
requireContext().startActivity<ConfigActivity>(
Pair(
"configType",
ConfigViewModel.TYPE_THEME_CONFIG
)
Pair("configType", ConfigViewModel.TYPE_THEME_CONFIG)
)
}
}

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.EditTextPreference
android:key="web_dav_url"
android:title="WebDav 服务器地址"
android:summary="输入你的服务器地址"
android:singleLine="true"/>
<androidx.preference.EditTextPreference
android:key="web_dav_account"
android:title="WebDav 账号"
android:summary="输入你的WebDav账号"
android:singleLine="true"/>
<androidx.preference.EditTextPreference
android:key="web_dav_password"
android:title="WebDav 密码"
android:summary="输入你的WebDav授权密码"
android:singleLine="true"
android:password="true" />
<androidx.preference.Preference
android:key="web_dav_restore"
android:title="恢复"
android:summary="从WebDav恢复"/>
</androidx.preference.PreferenceScreen>

@ -9,6 +9,12 @@
android:summary="与功能相关的一些设置"
app:iconSpaceReserved="false"/>
<androidx.preference.Preference
android:key="web_dav_setting"
android:title="云备份设置"
android:summary="通过WebDav云备份"
app:iconSpaceReserved="false"/>
<androidx.preference.Preference
android:key="theme_setting"
android:title="主题设置"

Loading…
Cancel
Save