|
|
|
@ -7,6 +7,8 @@ import androidx.preference.ListPreference |
|
|
|
|
import androidx.preference.Preference |
|
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.help.storage.Backup |
|
|
|
|
import io.legado.app.help.storage.WebDavHelp |
|
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
|
import io.legado.app.lib.theme.prefs.ATEEditTextPreference |
|
|
|
|
import io.legado.app.utils.getPrefString |
|
|
|
@ -19,6 +21,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference |
|
|
|
|
bindPreferenceSummaryToValue(findPreference("web_dav_account")) |
|
|
|
|
findPreference<ATEEditTextPreference>("web_dav_password")?.let { |
|
|
|
|
it.inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT |
|
|
|
|
bindPreferenceSummaryToValue(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -28,8 +31,15 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { |
|
|
|
|
val stringValue = newValue.toString() |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (preference is ListPreference) { |
|
|
|
|
val index = preference.findIndexOfValue(stringValue) |
|
|
|
|
// Set the summary to reflect the new value. |
|
|
|
@ -38,6 +48,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference |
|
|
|
|
// For all other preferences, set the summary to the value's |
|
|
|
|
preference?.summary = stringValue |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -51,4 +62,12 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
|
when (preference?.key) { |
|
|
|
|
"web_dav_backup" -> Backup.backup() |
|
|
|
|
"web_dav_restore" -> WebDavHelp.showRestoreDialog(requireContext()) |
|
|
|
|
} |
|
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |