pull/34/head
kunfei 5 years ago
parent ae0e1ca578
commit 8427f0b7ff
  1. 31
      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 {
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
}

@ -502,5 +502,7 @@
<string name="disable_selection">禁用所选</string>
<string name="tts">TTS</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>

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

Loading…
Cancel
Save