pull/34/head
kunfei 5 years ago
parent ae0e1ca578
commit 8427f0b7ff
  1. 25
      app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt
  2. 2
      app/src/main/res/values/strings.xml
  3. 4
      app/src/main/res/xml/pref_config_web_dav.xml

@ -46,23 +46,28 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference
} }
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
newValue?.let { when {
val stringValue = it.toString() preference?.key == "web_dav_password" -> if (newValue == null) {
if (preference?.key == "web_dav_password") {
if (stringValue.isBlank()) {
preference.summary = getString(R.string.web_dav_pw_s) preference.summary = getString(R.string.web_dav_pw_s)
} else { } else {
preference.summary = "*".repeat(stringValue.length) 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()
}
preference?.key == "web_dav_account" -> if (newValue == null) {
preference.summary = getString(R.string.web_dav_account_s)
} else {
preference.summary = newValue.toString()
} }
if (preference is ListPreference) { preference is ListPreference -> {
val index = preference.findIndexOfValue(stringValue) val index = preference.findIndexOfValue(newValue?.toString())
// Set the summary to reflect the new value. // Set the summary to reflect the new value.
preference.setSummary(if (index >= 0) preference.entries[index] else null) 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 return true
} }

@ -502,5 +502,7 @@
<string name="disable_selection">禁用所选</string> <string name="disable_selection">禁用所选</string>
<string name="tts">TTS</string> <string name="tts">TTS</string>
<string name="web_dav_pw_s">输入你的WebDav授权密码</string> <string name="web_dav_pw_s">输入你的WebDav授权密码</string>
<string name="web_dav_url_s">输入你的服务器地址</string>
<string name="web_dav_account_s">输入你的WebDav账号</string>
</resources> </resources>

@ -5,13 +5,13 @@
<androidx.preference.EditTextPreference <androidx.preference.EditTextPreference
android:key="web_dav_url" android:key="web_dav_url"
android:title="WebDav 服务器地址" android:title="WebDav 服务器地址"
android:summary="输入你的服务器地址" android:summary="@string/web_dav_url_s"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<androidx.preference.EditTextPreference <androidx.preference.EditTextPreference
android:key="web_dav_account" android:key="web_dav_account"
android:title="WebDav 账号" android:title="WebDav 账号"
android:summary="输入你的WebDav账号" android:summary="@string/web_dav_account_s"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<androidx.preference.EditTextPreference <androidx.preference.EditTextPreference

Loading…
Cancel
Save