Skip to content

Commit

Permalink
Merge pull request element-hq#1075 from vector-im/alert-about-encryption
Browse files Browse the repository at this point in the history
RoomViewController: Display an alert warning about the beta state of …
  • Loading branch information
manuroe authored Mar 8, 2017
2 parents 3e85e1f + 8e38e01 commit 70ab051
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Vector/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"room_event_action_cancel_upload" = "Cancel Upload";
"room_event_action_cancel_download" = "Cancel Download";
"room_event_action_view_encryption" = "Encryption Information";
"room_warning_about_encryption" = "End-to-end encryption is in beta and may not be reliable.\n\nYou should not yet trust it to secure data.\n\nDevices will not yet be able to decrypt history from before they joined the room.\n\nEncrypted messages will not be visible on clients that do not yet implement encryption.";

// Unknown devices
"unknown_devices_alert_title" = "Room contains unknown devices";
Expand Down Expand Up @@ -366,7 +367,6 @@
"room_details_advanced_e2e_encryption_enabled"="Encryption is enabled in this room";
"room_details_advanced_e2e_encryption_disabled"="Encryption is not enabled in this room.";
"room_details_advanced_e2e_encryption_blacklist_unverified_devices"="Encrypt to verified devices only";
"room_details_advanced_e2e_encryption_prompt_title"="Warning!";
"room_details_advanced_e2e_encryption_prompt_message"="End-to-end encryption is experimental and may not be reliable.\n\nYou should not yet trust it to secure data.\n\nDevices will not yet be able to decrypt history from before they joined the room.\n\nOnce encryption is enabled for a room it cannot be turned off again (for now).\n\nEncrypted messages will not be visible on clients that do not yet implement encryption.";
"room_details_fail_to_update_avatar" = "Fail to update the room photo";
"room_details_fail_to_update_room_name" = "Fail to update the room name";
Expand Down
2 changes: 1 addition & 1 deletion Vector/ViewController/RoomSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3051,7 +3051,7 @@ - (void)onSwitchUpdate:(UISwitch*)theSwitch

[currentAlert dismiss:NO];

currentAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"room_details_advanced_e2e_encryption_prompt_title", @"Vector", nil)
currentAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"warning", @"Vector", nil)
message:NSLocalizedStringFromTable(@"room_details_advanced_e2e_encryption_prompt_message", @"Vector", nil)
style:MXKAlertStyleAlert];

Expand Down
28 changes: 28 additions & 0 deletions Vector/ViewController/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,33 @@ - (void)viewDidAppear:(BOOL)animated

}];
[self refreshMissedDiscussionsCount:YES];

// Warn about the beta state of e2e encryption when entering the first time in an encrypted room
MXKAccount *account = [[MXKAccountManager sharedManager] accountForUserId:self.roomDataSource.mxSession.myUser.userId];
if (account && !account.isWarnedAboutEncryption && self.roomDataSource.room.state.isEncrypted)
{
[currentAlert dismiss:NO];

__weak __typeof(self) weakSelf = self;
currentAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"warning", @"Vector", nil)
message:NSLocalizedStringFromTable(@"room_warning_about_encryption", @"Vector", nil)
style:MXKAlertStyleAlert];

currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {

if (weakSelf)
{
__strong __typeof(weakSelf)self = weakSelf;
self->currentAlert = nil;

account.warnedAboutEncryption = YES;
}

}];

currentAlert.mxkAccessibilityIdentifier = @"RoomVCEncryptionAlert";
[currentAlert showInViewController:self];
}
}

- (void)viewDidDisappear:(BOOL)animated
Expand Down Expand Up @@ -3173,6 +3200,7 @@ - (void)eventDidChangeSentState:(NSNotification *)notif
}
}


- (void)resendAllUnsentMessages
{
// List unsent event ids
Expand Down

0 comments on commit 70ab051

Please sign in to comment.