diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index fc2b19ab8..9592084c4 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -215,6 +215,9 @@ "room_event_encryption_info_unverify" = "Unverify"; "room_event_encryption_info_block" = "Block"; "room_event_encryption_info_unblock" = "Unblock"; +"room_event_encryption_verify_title" = "Verify device\n\n"; +"room_event_encryption_verify_message" = "To verify that this device can be trusted, please contact its owner using\nsome other means (e.g. in person or a phone call) and ask them\nwhether the key they see in their User Settings for this device matches\nthe key below:\n\n\tDevice name: %@\n\tDevice ID: %@\n\tDevice key: %@\n\nIf it matches, press the verify button below. If it doesnt, then someone\nelse is intercepting this device and you probably want to press the block\nbutton instead.\n\nIn future this verification process will be more sophisticated."; +"room_event_encryption_verify_ok" = "Verify"; // Room Title "room_title_new_room" = "New room"; diff --git a/Vector/Views/EncryptionInfoView/EncryptionInfoView.h b/Vector/Views/EncryptionInfoView/EncryptionInfoView.h index 01bd3af24..c1f47650e 100644 --- a/Vector/Views/EncryptionInfoView/EncryptionInfoView.h +++ b/Vector/Views/EncryptionInfoView/EncryptionInfoView.h @@ -19,9 +19,10 @@ @interface EncryptionInfoView : UIView @property (weak, nonatomic) IBOutlet UITextView *textView; -@property (weak, nonatomic) IBOutlet UIButton *okButton; +@property (weak, nonatomic) IBOutlet UIButton *cancelButton; @property (weak, nonatomic) IBOutlet UIButton *verifyButton; @property (weak, nonatomic) IBOutlet UIButton *blockButton; +@property (weak, nonatomic) IBOutlet UIButton *confirmVerifyButton; - (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)session; diff --git a/Vector/Views/EncryptionInfoView/EncryptionInfoView.m b/Vector/Views/EncryptionInfoView/EncryptionInfoView.m index c4e198d3a..b252bb3c7 100644 --- a/Vector/Views/EncryptionInfoView/EncryptionInfoView.m +++ b/Vector/Views/EncryptionInfoView/EncryptionInfoView.m @@ -47,8 +47,11 @@ static NSAttributedString *verticalWhitespace = nil; [super awakeFromNib]; // Localize string - [_okButton setTitle:[NSBundle mxk_localizedStringForKey:@"ok"] forState:UIControlStateNormal]; - [_okButton setTitle:[NSBundle mxk_localizedStringForKey:@"ok"] forState:UIControlStateHighlighted]; + [_cancelButton setTitle:[NSBundle mxk_localizedStringForKey:@"ok"] forState:UIControlStateNormal]; + [_cancelButton setTitle:[NSBundle mxk_localizedStringForKey:@"ok"] forState:UIControlStateHighlighted]; + + [_confirmVerifyButton setTitle:NSLocalizedStringFromTable(@"room_event_encryption_verify_ok", @"Vector", nil) forState:UIControlStateNormal]; + [_confirmVerifyButton setTitle:NSLocalizedStringFromTable(@"room_event_encryption_verify_ok", @"Vector", nil) forState:UIControlStateHighlighted]; } - (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)session @@ -324,11 +327,16 @@ static NSAttributedString *verticalWhitespace = nil; - (IBAction)onButtonPressed:(id)sender { - if (sender == _okButton) + if (sender == _cancelButton) { [self removeFromSuperview]; } - else + else if (sender == _confirmVerifyButton && deviceInfo) + { + [mxSession.crypto setDeviceVerification:MXDeviceVerified forDevice:deviceInfo.deviceId ofUser:deviceInfo.userId]; + [self removeFromSuperview]; + } + else if (deviceInfo) { MXDeviceVerification verificationStatus; @@ -347,8 +355,33 @@ static NSAttributedString *verticalWhitespace = nil; return; } - [mxSession.crypto setDeviceVerification:verificationStatus forDevice:deviceInfo.deviceId ofUser:deviceInfo.userId]; - [self removeFromSuperview]; + if (verificationStatus == MXDeviceVerified) + { + // Prompt user + NSMutableAttributedString *textViewAttributedString = [[NSMutableAttributedString alloc] + initWithString:NSLocalizedStringFromTable(@"room_event_encryption_verify_title", @"Vector", nil) + attributes:@{NSForegroundColorAttributeName : kVectorTextColorBlack, + NSFontAttributeName: [UIFont boldSystemFontOfSize:17]}]; + + NSString *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_event_encryption_verify_message", @"Vector", nil), deviceInfo.displayName, deviceInfo.deviceId, deviceInfo.fingerprint]; + + [textViewAttributedString appendAttributedString:[[NSMutableAttributedString alloc] + initWithString:message + attributes:@{NSForegroundColorAttributeName : kVectorTextColorBlack, + NSFontAttributeName: [UIFont systemFontOfSize:14]}]]; + + self.textView.attributedText = textViewAttributedString; + + [_cancelButton setTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] forState:UIControlStateNormal]; + [_cancelButton setTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] forState:UIControlStateHighlighted]; + _verifyButton.hidden = _blockButton.hidden = YES; + _confirmVerifyButton.hidden = NO; + } + else + { + [mxSession.crypto setDeviceVerification:verificationStatus forDevice:deviceInfo.deviceId ofUser:deviceInfo.userId]; + [self removeFromSuperview]; + } } } diff --git a/Vector/Views/EncryptionInfoView/EncryptionInfoView.xib b/Vector/Views/EncryptionInfoView/EncryptionInfoView.xib index a6ef27252..3dd31bdba 100644 --- a/Vector/Views/EncryptionInfoView/EncryptionInfoView.xib +++ b/Vector/Views/EncryptionInfoView/EncryptionInfoView.xib @@ -58,6 +58,15 @@ + @@ -67,9 +76,11 @@ + + @@ -78,7 +89,8 @@ - + +