From 1e34f1fa5ae3f39fca91fa050f6e36ab3ca0b868 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 26 Aug 2019 18:02:33 +0200 Subject: [PATCH 1/3] Settings: Cryptography section: Make clear that device names are publicly readable vector-im/riot-ios/issues/2662 --- CHANGES.rst | 2 ++ Riot/Assets/en.lproj/Vector.strings | 4 ++-- Riot/Generated/Strings.swift | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5da0df8661..0ea296cb4c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,7 +2,9 @@ Changes in 0.9.3 (2019-08-) =============================================== Improvements: + * Upgrade MatrixKit version ([v0.11.0](https://github.com/matrix-org/matrix-ios-kit/releases/tag/v0.11.0)). * Prompt to accept integration manager policies on use (#2600). + * Make clear that device names are publicly readable (#2662). Changes in 0.9.2 (2019-08-08) =============================================== diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 51f8928dd0..009cf46562 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -446,9 +446,9 @@ "settings_fail_to_update_password" = "Fail to update password"; "settings_password_updated" = "Your password has been updated"; -"settings_crypto_device_name" = "Device name: "; +"settings_crypto_device_name" = "Device Public Name: "; "settings_crypto_device_id" = "\nDevice ID: "; -"settings_crypto_device_key" = "\nDevice key: "; +"settings_crypto_device_key" = "\nDevice key:\n"; "settings_crypto_export" = "Export keys"; "settings_crypto_blacklist_unverified_devices" = "Encrypt to verified devices only"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index a5e541b5f0..53b282b016 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -74,7 +74,7 @@ internal enum VectorL10n { internal static var authForgotPassword: String { return VectorL10n.tr("Vector", "auth_forgot_password") } - /// No Identity Server is configured: add one to reset your password. + /// No identity server is configured: add one to reset your password. internal static var authForgotPasswordErrorNoConfiguredIdentityServer: String { return VectorL10n.tr("Vector", "auth_forgot_password_error_no_configured_identity_server") } @@ -1502,7 +1502,7 @@ internal enum VectorL10n { internal static var roomCreationAppearancePicture: String { return VectorL10n.tr("Vector", "room_creation_appearance_picture") } - /// No Identity Server is configured so you cannot add a participant with an email. + /// No identity server is configured so you cannot add a participant with an email. internal static var roomCreationErrorInviteUserByEmailWithoutIdentityServer: String { return VectorL10n.tr("Vector", "room_creation_error_invite_user_by_email_without_identity_server") } @@ -2126,7 +2126,7 @@ internal enum VectorL10n { internal static var roomParticipantsRemoveThirdPartyInviteMsg: String { return VectorL10n.tr("Vector", "room_participants_remove_third_party_invite_msg") } - /// No Identity Server is configured so you cannot start a chat with a contact using an email. + /// No identity server is configured so you cannot start a chat with a contact using an email. internal static var roomParticipantsStartNewChatErrorUsingUserEmailWithoutIdentityServer: String { return VectorL10n.tr("Vector", "room_participants_start_new_chat_error_using_user_email_without_identity_server") } @@ -2450,11 +2450,11 @@ internal enum VectorL10n { internal static var settingsCryptoDeviceId: String { return VectorL10n.tr("Vector", "settings_crypto_device_id") } - /// \nDevice key: + /// \nDevice key:\n internal static var settingsCryptoDeviceKey: String { return VectorL10n.tr("Vector", "settings_crypto_device_key") } - /// Device name: + /// Device Public Name: internal static var settingsCryptoDeviceName: String { return VectorL10n.tr("Vector", "settings_crypto_device_name") } From 118ec78f23c3dce5ac9cc99a29876be5705fbb9d Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 26 Aug 2019 18:03:26 +0200 Subject: [PATCH 2/3] Settings: Display device fingerprint with a space every 4 chars like other Riot apps --- Riot/Modules/Settings/SettingsViewController.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 1ede84ee11..4c9d1c3519 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -1008,6 +1008,10 @@ - (NSAttributedString*)cryptographyInformation attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.textPrimaryColor, NSFontAttributeName: [UIFont systemFontOfSize:17]}]]; NSString *fingerprint = account.mxSession.crypto.deviceEd25519Key; + if (fingerprint) + { + fingerprint = [MXTools addWhiteSpacesToString:fingerprint every:4]; + } [cryptoInformationString appendAttributedString:[[NSMutableAttributedString alloc] initWithString:fingerprint ? fingerprint : @"" attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.textPrimaryColor, From b2bae552d355d4dd377989da897b0199e2aece22 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 26 Aug 2019 18:37:43 +0200 Subject: [PATCH 3/3] Settings: Device section: Make clear that device names are publicly readable in a kind of a "section header" header vector-im/riot-ios/issues/2662 --- Riot/Assets/en.lproj/Vector.strings | 2 + Riot/Generated/Strings.swift | 4 ++ .../Modules/Settings/SettingsViewController.m | 60 ++++++++++++++----- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 009cf46562..0451b075fc 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -479,6 +479,8 @@ "settings_key_backup_delete_confirmation_prompt_title" = "Delete Backup"; "settings_key_backup_delete_confirmation_prompt_msg" = "Are you sure? You will lose your encrypted messages if your keys are not backed up properly."; +"settings_devices_description" = "A device's public name is visible to people you communicate with"; + // Room Details "room_details_title" = "Room Details"; "room_details_people" = "Members"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 53b282b016..c1660708c0 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -2478,6 +2478,10 @@ internal enum VectorL10n { internal static var settingsDevices: String { return VectorL10n.tr("Vector", "settings_devices") } + /// A device's public name is visible to people you communicate with + internal static var settingsDevicesDescription: String { + return VectorL10n.tr("Vector", "settings_devices_description") + } /// Display Name internal static var settingsDisplayName: String { return VectorL10n.tr("Vector", "settings_display_name") diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 4c9d1c3519..abea03d9aa 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -128,6 +128,11 @@ CRYPTOGRAPHY_COUNT }; +enum +{ + DEVICES_DESCRIPTION_INDEX = 0 +}; + #define SECTION_TITLE_PADDING_WHEN_HIDDEN 0.01f typedef void (^blockSettingsViewController_onReadyToDestroy)(void); @@ -1320,6 +1325,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger else if (section == SETTINGS_SECTION_DEVICES_INDEX) { count = devicesArray.count; + if (count) + { + // For some description (DEVICES_DESCRIPTION_INDEX) + count++; + } } else if (section == SETTINGS_SECTION_CRYPTOGRAPHY_INDEX) { @@ -1406,6 +1416,7 @@ - (MXKTableViewCell*)getDefaultTableViewCell:(UITableView*)tableView cell.textLabel.accessibilityIdentifier = nil; cell.textLabel.font = [UIFont systemFontOfSize:17]; cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + cell.contentView.backgroundColor = UIColor.clearColor; return cell; } @@ -2198,22 +2209,39 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } else if (section == SETTINGS_SECTION_DEVICES_INDEX) { - MXKTableViewCell *deviceCell = [self getDefaultTableViewCell:tableView]; - - if (row < devicesArray.count) + if (row == DEVICES_DESCRIPTION_INDEX) { - NSString *name = devicesArray[row].displayName; - NSString *deviceId = devicesArray[row].deviceId; - deviceCell.textLabel.text = (name.length ? [NSString stringWithFormat:@"%@ (%@)", name, deviceId] : [NSString stringWithFormat:@"(%@)", deviceId]); - deviceCell.textLabel.numberOfLines = 0; - - if ([deviceId isEqualToString:self.mainSession.matrixRestClient.credentials.deviceId]) + MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView]; + descriptionCell.textLabel.text = NSLocalizedStringFromTable(@"settings_devices_description", @"Vector", nil); + descriptionCell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + descriptionCell.textLabel.font = [UIFont systemFontOfSize:15]; + descriptionCell.textLabel.numberOfLines = 0; + descriptionCell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; + descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone; + + cell = descriptionCell; + } + else + { + NSUInteger deviceIndex = row - 1; + + MXKTableViewCell *deviceCell = [self getDefaultTableViewCell:tableView]; + if (deviceIndex < devicesArray.count) { - deviceCell.textLabel.font = [UIFont boldSystemFontOfSize:17]; + NSString *name = devicesArray[deviceIndex].displayName; + NSString *deviceId = devicesArray[deviceIndex].deviceId; + deviceCell.textLabel.text = (name.length ? [NSString stringWithFormat:@"%@ (%@)", name, deviceId] : [NSString stringWithFormat:@"(%@)", deviceId]); + deviceCell.textLabel.numberOfLines = 0; + + if ([deviceId isEqualToString:self.mainSession.matrixRestClient.credentials.deviceId]) + { + deviceCell.textLabel.font = [UIFont boldSystemFontOfSize:17]; + } } + + cell = deviceCell; } - - cell = deviceCell; + } else if (section == SETTINGS_SECTION_CRYPTOGRAPHY_INDEX) { @@ -2700,9 +2728,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } else if (section == SETTINGS_SECTION_DEVICES_INDEX) { - if (row < devicesArray.count) + if (row > DEVICES_DESCRIPTION_INDEX) { - [self showDeviceDetails:devicesArray[row]]; + NSUInteger deviceIndex = row - 1; + if (deviceIndex < devicesArray.count) + { + [self showDeviceDetails:devicesArray[deviceIndex]]; + } } } else if (section == SETTINGS_SECTION_CONTACTS_INDEX)