|
|
@ -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") { |
|
|
|
preference.summary = getString(R.string.web_dav_pw_s) |
|
|
|
if (stringValue.isBlank()) { |
|
|
|
} else { |
|
|
|
preference.summary = getString(R.string.web_dav_pw_s) |
|
|
|
preference.summary = "*".repeat(newValue.toString().length) |
|
|
|
} else { |
|
|
|
} |
|
|
|
preference.summary = "*".repeat(stringValue.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) { |
|
|
|
preference?.key == "web_dav_account" -> if (newValue == null) { |
|
|
|
val index = preference.findIndexOfValue(stringValue) |
|
|
|
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. |
|
|
|
// 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 |
|
|
|
} |
|
|
|
} |
|
|
|