mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 00:02:47 +00:00
Merge pull request #793 from vector-im/vector_723
End-to-end encryption UI/UX
This commit is contained in:
commit
ad8b2a4446
4 changed files with 57 additions and 8 deletions
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,15 @@
|
|||
<action selector="onButtonPressed:" destination="8VI-1E-fge" eventType="touchUpInside" id="j21-e2-e3C"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="L4h-aG-8UN">
|
||||
<rect key="frame" x="506" y="560" width="40" height="30"/>
|
||||
<state key="normal" title="Verify">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onButtonPressed:" destination="8VI-1E-fge" eventType="touchUpInside" id="nKr-w7-ECp"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
|
@ -67,9 +76,11 @@
|
|||
<constraint firstItem="4nG-AI-PEC" firstAttribute="top" secondItem="8VI-1E-fge" secondAttribute="top" constant="10" id="AsZ-Vi-ffo"/>
|
||||
<constraint firstAttribute="bottom" secondItem="qkC-t0-Qd0" secondAttribute="bottom" constant="10" id="DyR-rX-nt0"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Ump-1C-SzI" secondAttribute="bottom" constant="10" id="Nfo-nh-gvW"/>
|
||||
<constraint firstAttribute="bottom" secondItem="L4h-aG-8UN" secondAttribute="bottom" constant="10" id="Owt-zM-W2X"/>
|
||||
<constraint firstAttribute="centerX" secondItem="Ump-1C-SzI" secondAttribute="centerX" multiplier="4" id="YMC-ob-tqT"/>
|
||||
<constraint firstAttribute="bottom" secondItem="IdO-jn-iTV" secondAttribute="bottom" constant="10" id="YcV-iN-9WU"/>
|
||||
<constraint firstAttribute="trailing" secondItem="4nG-AI-PEC" secondAttribute="trailing" constant="10" id="aQF-F6-6lU"/>
|
||||
<constraint firstAttribute="centerX" secondItem="L4h-aG-8UN" secondAttribute="centerX" multiplier="0.57" id="g1v-Mg-fQ6"/>
|
||||
<constraint firstAttribute="centerX" secondItem="IdO-jn-iTV" secondAttribute="centerX" multiplier="0.57" id="gAm-ph-zPW"/>
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
|
@ -78,7 +89,8 @@
|
|||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="blockButton" destination="IdO-jn-iTV" id="HI0-ZU-esJ"/>
|
||||
<outlet property="okButton" destination="Ump-1C-SzI" id="nXR-dU-t3K"/>
|
||||
<outlet property="cancelButton" destination="Ump-1C-SzI" id="U8M-nT-JiK"/>
|
||||
<outlet property="confirmVerifyButton" destination="L4h-aG-8UN" id="GX6-dB-JG6"/>
|
||||
<outlet property="textView" destination="3Vk-Jx-L6Y" id="uOw-Bq-neN"/>
|
||||
<outlet property="verifyButton" destination="qkC-t0-Qd0" id="6LD-04-WgO"/>
|
||||
</connections>
|
||||
|
|
Loading…
Reference in a new issue