Commit 0a06d0ea authored by Ricki Hirner's avatar Ricki Hirner 🐑

Account settings: always allow client certificate selection

parent 737af880
Pipeline #216499813 passed with stage
in 7 minutes and 39 seconds
......@@ -212,36 +212,29 @@ class SettingsActivity: AppCompatActivity() {
val prefPassword = findPreference<EditTextPreference>("password")!!
val prefCertAlias = findPreference<Preference>("certificate_alias")!!
model.credentials.observe(viewLifecycleOwner, { credentials ->
if (credentials.userName != null && credentials.password != null) {
prefUserName.isVisible = true
prefUserName.summary = credentials.userName
prefUserName.text = credentials.userName
prefUserName.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newUserName ->
model.updateCredentials(Credentials(newUserName as String, credentials.password, credentials.certificateAlias))
false
}
prefUserName.summary = credentials.userName
prefUserName.text = credentials.userName
prefUserName.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newUserName ->
model.updateCredentials(Credentials(newUserName as String, credentials.password, credentials.certificateAlias))
false
}
if (credentials.userName != null) {
prefPassword.isVisible = true
prefPassword.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newPassword ->
model.updateCredentials(Credentials(credentials.userName, newPassword as String, credentials.certificateAlias))
false
}
} else {
prefUserName.isVisible = false
} else
prefPassword.isVisible = false
}
if (credentials.certificateAlias != null) {
prefCertAlias.isVisible = true
prefCertAlias.summary = credentials.certificateAlias
prefCertAlias.setOnPreferenceClickListener {
KeyChain.choosePrivateKeyAlias(requireActivity(), { newAlias ->
model.updateCredentials(Credentials(credentials.userName, credentials.password, newAlias))
}, null, null, null, -1, credentials.certificateAlias)
true
}
} else
prefCertAlias.isVisible = false
prefCertAlias.summary = credentials.certificateAlias ?: getString(R.string.settings_certificate_alias_empty)
prefCertAlias.setOnPreferenceClickListener {
KeyChain.choosePrivateKeyAlias(requireActivity(), { newAlias ->
model.updateCredentials(Credentials(credentials.userName, credentials.password, newAlias))
}, null, null, null, -1, credentials.certificateAlias)
true
}
})
// preference group: CalDAV
......
......@@ -295,6 +295,7 @@
<string name="settings_enter_password">Enter your password:</string>
<string name="settings_certificate_alias_key" translatable="false">certificate_alias</string>
<string name="settings_certificate_alias">Client certificate alias</string>
<string name="settings_certificate_alias_empty">No certificate selected</string>
<string name="settings_caldav_key" translatable="false">caldav</string>
<string name="settings_caldav">CalDAV</string>
<string name="settings_sync_time_range_past_key" translatable="false">time_range_past_days</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment