From 8427f0b7ff7f62cfc9b8559e6df066549a911cb1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 17 Sep 2019 22:20:36 +0800 Subject: [PATCH] up --- .../app/ui/config/WebDavConfigFragment.kt | 31 +++++++++++-------- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_config_web_dav.xml | 4 +-- 3 files changed, 22 insertions(+), 15 deletions(-) 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 index 52837150d..cbea0803b 100644 --- a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt @@ -46,23 +46,28 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference } override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { - newValue?.let { - val stringValue = it.toString() - if (preference?.key == "web_dav_password") { - if (stringValue.isBlank()) { - preference.summary = getString(R.string.web_dav_pw_s) - } else { - preference.summary = "*".repeat(stringValue.length) - } + when { + preference?.key == "web_dav_password" -> if (newValue == null) { + preference.summary = getString(R.string.web_dav_pw_s) + } else { + preference.summary = "*".repeat(newValue.toString().length) + } + preference?.key == "web_dav_url" -> if (newValue == null) { + preference.summary = getString(R.string.web_dav_url_s) + } else { + preference.summary = newValue.toString() } - if (preference is ListPreference) { - val index = preference.findIndexOfValue(stringValue) + preference?.key == "web_dav_account" -> if (newValue == null) { + preference.summary = getString(R.string.web_dav_account_s) + } else { + preference.summary = newValue.toString() + } + preference is ListPreference -> { + val index = preference.findIndexOfValue(newValue?.toString()) // Set the summary to reflect the new value. preference.setSummary(if (index >= 0) preference.entries[index] else null) - } else { - // For all other preferences, set the summary to the value's - preference?.summary = stringValue } + else -> preference?.summary = newValue?.toString() } return true } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a66f806b6..f95f3b249 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -502,5 +502,7 @@ 禁用所选 TTS 输入你的WebDav授权密码 + 输入你的服务器地址 + 输入你的WebDav账号 diff --git a/app/src/main/res/xml/pref_config_web_dav.xml b/app/src/main/res/xml/pref_config_web_dav.xml index 84cb363ca..9591ca1b4 100644 --- a/app/src/main/res/xml/pref_config_web_dav.xml +++ b/app/src/main/res/xml/pref_config_web_dav.xml @@ -5,13 +5,13 @@