Skip to content

Commit

Permalink
Settings: Device section: Make clear that device names are publicly r…
Browse files Browse the repository at this point in the history
…eadable in a kind of a "section header" header

/issues/2662
  • Loading branch information
manuroe committed Aug 26, 2019
1 parent 118ec78 commit b2bae55
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 4 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
60 changes: 46 additions & 14 deletions Riot/Modules/Settings/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
CRYPTOGRAPHY_COUNT
};

enum
{
DEVICES_DESCRIPTION_INDEX = 0
};

#define SECTION_TITLE_PADDING_WHEN_HIDDEN 0.01f

typedef void (^blockSettingsViewController_onReadyToDestroy)(void);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b2bae55

Please sign in to comment.