Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different title for scan button for self verification #4525

Merged
merged 6 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changes to be released in next version
* Fix crash on Apple Silicon Macs.
* Media Picker: Generate video thumbnails with the correct orientation (#4515).
* Directory List (pop-up one): Fix duplicate rooms being shown (#4537).
* Use different title for scan button for self verification (#4525)

⚠️ API Changes
*
Expand Down
1 change: 1 addition & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ Tap the + to start adding people.";
"key_verification_verify_qr_code_information_other_device" = "Scan the code below to verify:";
"key_verification_verify_qr_code_emoji_information" = "Verify by comparing unique emoji.";
"key_verification_verify_qr_code_scan_code_action" = "Scan their code";
"key_verification_verify_qr_code_scan_code_other_device_action" = "Scan with this device";
"key_verification_verify_qr_code_cannot_scan_action" = "Can't scan?";
"key_verification_verify_qr_code_start_emoji_action" = "Verify by emoji";

Expand Down
4 changes: 4 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,10 @@ internal enum VectorL10n {
internal static var keyVerificationVerifyQrCodeScanCodeAction: String {
return VectorL10n.tr("Vector", "key_verification_verify_qr_code_scan_code_action")
}
/// Scan with this device
internal static var keyVerificationVerifyQrCodeScanCodeOtherDeviceAction: String {
return VectorL10n.tr("Vector", "key_verification_verify_qr_code_scan_code_other_device_action")
}
/// QR code has been successfully validated.
internal static var keyVerificationVerifyQrCodeScanOtherCodeSuccessMessage: String {
return VectorL10n.tr("Vector", "key_verification_verify_qr_code_scan_other_code_success_message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
self.titleLabel.text = VectorL10n.keyVerificationVerifyQrCodeTitle
self.informationLabel.text = VectorL10n.keyVerificationVerifyQrCodeInformation

self.scanCodeButton.setTitle(VectorL10n.keyVerificationVerifyQrCodeScanCodeAction, for: .normal)
// Hide until we have the type of the verification request
self.scanCodeButton.isHidden = true

self.cannotScanButton.setTitle(VectorL10n.keyVerificationVerifyQrCodeCannotScanAction, for: .normal)
}

Expand All @@ -157,8 +159,8 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
self.render(error: error)
case .scannedCodeValidated(let isValid):
self.renderScannedCode(valid: isValid)
case .cancelled(let reason):
self.renderCancelled(reason: reason)
case .cancelled(let reason, let verificationKind):
self.renderCancelled(reason: reason, verificationKind: verificationKind)
case .cancelledByMe(let reason):
self.renderCancelledByMe(reason: reason)
}
Expand Down Expand Up @@ -195,10 +197,13 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
switch viewData.verificationKind {
case .user:
informationText = VectorL10n.keyVerificationVerifyQrCodeInformation
self.scanCodeButton.setTitle(VectorL10n.keyVerificationVerifyQrCodeScanCodeAction, for: .normal)
default:
informationText = VectorL10n.keyVerificationVerifyQrCodeInformationOtherDevice
self.scanCodeButton.setTitle(VectorL10n.keyVerificationVerifyQrCodeScanCodeOtherDeviceAction, for: .normal)
}

self.scanCodeButton.isHidden = false
self.informationLabel.text = informationText
}
}
Expand Down Expand Up @@ -231,12 +236,21 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
}
}

private func renderCancelled(reason: MXTransactionCancelCode) {
private func renderCancelled(reason: MXTransactionCancelCode,
verificationKind: KeyVerificationKind) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)

self.stopQRCodeScanningIfPresented()

self.errorPresenter.presentError(from: self.alertPresentingViewController, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
// if we're verifying with someone else, let the user know they cancelled.
// if we're verifying our own device, assume the user probably knows since it was them who
// cancelled on their other device
if verificationKind == .user {
self.errorPresenter.presentError(from: self.alertPresentingViewController, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
self.dismissQRCodeScanningIfPresented(animated: false)
self.viewModel.process(viewAction: .cancel)
}
} else {
self.dismissQRCodeScanningIfPresented(animated: false)
self.viewModel.process(viewAction: .cancel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca
return
}
self.unregisterTransactionDidStateChangeNotification()
self.update(viewState: .cancelled(reason))
self.update(viewState: .cancelled(cancelCode: reason, verificationKind: verificationKind))
case MXSASTransactionStateCancelledByMe:
guard let reason = transaction.reasonCancelCode else {
return
Expand All @@ -251,7 +251,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca
return
}
self.unregisterTransactionDidStateChangeNotification()
self.update(viewState: .cancelled(reason))
self.update(viewState: .cancelled(cancelCode: reason, verificationKind: verificationKind))
case .cancelledByMe:
guard let reason = transaction.reasonCancelCode else {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum KeyVerificationVerifyByScanningViewState {
case loading
case loaded(viewData: KeyVerificationVerifyByScanningViewData)
case scannedCodeValidated(isValid: Bool)
case cancelled(MXTransactionCancelCode)
case cancelled(cancelCode: MXTransactionCancelCode, verificationKind: KeyVerificationKind)
case cancelledByMe(MXTransactionCancelCode)
case error(Error)
}