From 8e022db36cb6a0ac93d68deedb241b8c0aa4ce67 Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Thu, 16 Nov 2023 20:58:30 +0100 Subject: [PATCH] Add a cancel option when verifying device if no other verified device can be reached --- ...ionSelfVerifyWaitViewController.storyboard | 56 +++++++++++++++++-- ...ficationSelfVerifyWaitViewController.swift | 29 +++++++++- .../Localizations/fr.lproj/Tchap.strings | 6 +- 3 files changed, 83 insertions(+), 8 deletions(-) diff --git a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard index d52f967b9..4c00dd497 100644 --- a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard +++ b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard @@ -1,10 +1,11 @@ - + - + + @@ -17,13 +18,13 @@ - + - + - + diff --git a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.swift b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.swift index f97bc6cfa..96f8505c6 100644 --- a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.swift +++ b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.swift @@ -43,6 +43,16 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController { @IBOutlet private weak var recoverSecretsButton: RoundedButton! @IBOutlet private weak var recoverSecretsAdditionalInformationLabel: UILabel! + // Tchap: UI to enable user to cancel this view if no recover secrets method is available + // It can happen on an account created before setting `secureBackupRequired` to true. + // This account can have cross-signing activated but no more session connected (all devices disconnected). + // The application will ask the user to verifiy the session with another device because cross-signing is activated. + // But as no other device is still connected, the user has no way to perform the verification, + // because SecureBackup is not activated: we are in the process of activating it. + @IBOutlet weak var tchapNoRecoverSecretsMethodAvailableContainerView: UIView! + @IBOutlet weak var tchapNoRecoverSecretsMethodAvailableInformationLabel: UILabel! + @IBOutlet weak var tchapNoRecoverSecretsMethodAvailableButton: RoundedButton! + // MARK: Private private var viewModel: KeyVerificationSelfVerifyWaitViewModelType! @@ -101,6 +111,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController { self.mobileClientImageView.tintColor = theme.tintColor self.recoverSecretsAvailabilityLoadingLabel.textColor = theme.textSecondaryColor self.recoverSecretsAvailabilityActivityIndicatorView.color = theme.tintColor + + // Tchap: + self.tchapNoRecoverSecretsMethodAvailableInformationLabel.textColor = theme.textSecondaryColor + } private func registerThemeServiceDidChangeThemeNotification() { @@ -188,6 +202,19 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController { self.recoverSecretsAvailabilityActivityIndicatorView.stopAnimating() self.recoverSecretsContainerView.isHidden = hideRecoverSecrets self.recoverSecretsButton.setTitle(recoverSecretsButtonTitle, for: .normal) + + // Tchap: show no recovery secrets method available only if hideRecoverSecrets is true. + // The UI will propose the user to verify is session with another device. + // Offer the user to cancel if no device is available to him. + self.tchapNoRecoverSecretsMethodAvailableContainerView.isHidden = !hideRecoverSecrets + self.tchapNoRecoverSecretsMethodAvailableInformationLabel.text = TchapL10n.deviceVerificationSelfVerifyNoOtherVerifiedSessionAvailable + self.tchapNoRecoverSecretsMethodAvailableButton.setTitle(VectorL10n.cancel, for: .normal) + + if (hideRecoverSecrets) + { + self.tchapNoRecoverSecretsMethodAvailableButton.addTarget(self, action: #selector(cancelButtonAction), for: .touchUpInside) + } + } private func renderCancelled(reason: MXTransactionCancelCode) { @@ -217,7 +244,7 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController { // MARK: - Actions - private func cancelButtonAction() { + @objc private func cancelButtonAction() { self.viewModel.process(viewAction: .cancel) } diff --git a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings index 61610e5e6..58f6c5bf5 100644 --- a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings +++ b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings @@ -305,7 +305,11 @@ //////////////////////////////////////////////////////////////////////////////// // MARK: Secret Setup Recovery Key "secrets_setup_recovery_key_export_action_done" = "Clé copiée"; -"secrets_setup_recovery_key_warning" = "Attention : c'est la seule fois que votre code est affiché !"; // Tchap +"secrets_setup_recovery_key_warning" = "Attention : c'est la seule fois que votre code est affiché !"; + +//////////////////////////////////////////////////////////////////////////////// +// MARK: Key Verification Self Verify +"device_verification_self_verify_no_other_verified_session_available" = "Si vous n'avez accès à aucun autre appareil vérifié de votre compte, vous pouvez essayer d'activer la signature croisée dans vos paramètres."; //////////////////////////////////////////////////////////////////////////////// // MARK: Room Decryption error