Try to improve readability

This commit is contained in:
Benoit Marty 2020-07-11 13:19:43 +02:00
parent 352662d19a
commit 7193db8344
1 changed files with 34 additions and 39 deletions

View File

@ -129,15 +129,12 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
} }
private fun refresh4SSection(info: SecretsSynchronisationInfo) { private fun refresh4SSection(info: SecretsSynchronisationInfo) {
secureBackupCategory.isVisible = false
// it's a lot of if / else if / else // it's a lot of if / else if / else
// But it's not yet clear how to manage all cases // But it's not yet clear how to manage all cases
if (!info.isCrossSigningEnabled) { if (!info.isCrossSigningEnabled) {
// There is not cross signing, so we can remove the section // There is not cross signing, so we can remove the section
secureBackupCategory.isVisible = false
} else { } else {
secureBackupCategory.isVisible = true
if (!info.isBackupSetup) { if (!info.isBackupSetup) {
if (info.isCrossSigningEnabled && info.allPrivateKeysKnown) { if (info.isCrossSigningEnabled && info.allPrivateKeysKnown) {
// You can setup recovery! // You can setup recovery!
@ -154,26 +151,40 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
// you should synchronize to get gossips // you should synchronize to get gossips
secureBackupCategory.isVisible = false secureBackupCategory.isVisible = false
} }
return } else {
} // so here we know that 4S is setup
if (info.isCrossSigningTrusted && info.allPrivateKeysKnown) {
// so here we know that 4S is setup // Looks like we have all cross signing secrets and session is trusted
if (info.isCrossSigningTrusted && info.allPrivateKeysKnown) { // Let's see if there is a megolm backup
// Looks like we have all cross signing secrets and session is trusted if (!info.megolmBackupAvailable || info.megolmSecretKnown) {
// Let's see if there is a megolm backup // Only option here is to create a new backup if you want?
if (!info.megolmBackupAvailable || info.megolmSecretKnown) { // aka reset
// Only option here is to create a new backup if you want? secureBackupCategory.isVisible = true
// aka reset secureBackupPreference.isVisible = true
secureBackupCategory.isVisible = true secureBackupPreference.title = getString(R.string.settings_secure_backup_reset)
secureBackupPreference.isVisible = true secureBackupPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
secureBackupPreference.title = getString(R.string.settings_secure_backup_reset) BootstrapBottomSheet.show(parentFragmentManager, initCrossSigningOnly = false, forceReset4S = true)
secureBackupPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener { true
BootstrapBottomSheet.show(parentFragmentManager, initCrossSigningOnly = false, forceReset4S = true) }
true } else if (!info.megolmSecretKnown) {
// megolm backup is available but we don't have key
// you could try to synchronize to get missing megolm key ?
secureBackupCategory.isVisible = true
secureBackupPreference.isVisible = true
secureBackupPreference.title = getString(R.string.settings_secure_backup_enter_to_setup)
secureBackupPreference.isEnabled = true
secureBackupPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
(requireActivity() as? VectorBaseActivity)?.let {
it.navigator.requestSelfSessionVerification(it)
}
true
}
} else {
secureBackupCategory.isVisible = false
} }
} else if (!info.megolmSecretKnown) { } else {
// megolm backup is available but we don't have key // there is a backup, but this session is not trusted, or is missing some secrets
// you could try to synchronize to get missing megolm key ? // you should enter passphrase to get them or verify against another session
secureBackupCategory.isVisible = true secureBackupCategory.isVisible = true
secureBackupPreference.isVisible = true secureBackupPreference.isVisible = true
secureBackupPreference.title = getString(R.string.settings_secure_backup_enter_to_setup) secureBackupPreference.title = getString(R.string.settings_secure_backup_enter_to_setup)
@ -184,22 +195,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
} }
true true
} }
} else {
secureBackupCategory.isVisible = false
}
return
} else {
// there is a backup, but this session is not trusted, or is missing some secrets
// you should enter passphrase to get them or verify against another session
secureBackupCategory.isVisible = true
secureBackupPreference.isVisible = true
secureBackupPreference.title = getString(R.string.settings_secure_backup_enter_to_setup)
secureBackupPreference.isEnabled = true
secureBackupPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
(requireActivity() as? VectorBaseActivity)?.let {
it.navigator.requestSelfSessionVerification(it)
}
true
} }
} }
} }