Skip to content

Commit

Permalink
Fix #4415 - Cannot disable Face ID after disabling pin. Fixed securit…
Browse files Browse the repository at this point in the history
…y vc cell tags comparisons.
  • Loading branch information
stefanceriu committed Sep 21, 2021
1 parent f9ec121 commit 46fdb64
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
44 changes: 23 additions & 21 deletions Riot/Modules/Settings/Security/SecurityViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ - (void)updateSections
// Rows
[pinCodeSection addRowWithTag:PIN_CODE_SETTING];
[pinCodeSection addRowWithTag:PIN_CODE_DESCRIPTION];
if ([PinCodePreferences shared].isPinSet) {

if ([PinCodePreferences shared].isPinSet)
{
[pinCodeSection addRowWithTag:PIN_CODE_CHANGE];
}

Expand Down Expand Up @@ -1186,17 +1188,17 @@ - (MXKTableViewCellWithButton *)buttonCellWithTitle:(NSString*)title
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *tagsIndexPath = [self.tableViewSections tagsIndexPathFromTableViewIndexPath:indexPath];
NSInteger section = tagsIndexPath.section;
NSInteger row = tagsIndexPath.row;
NSInteger sectionTag = tagsIndexPath.section;
NSInteger rowTag = tagsIndexPath.row;

// set the cell to a default value to avoid application crashes
UITableViewCell *cell = [[UITableViewCell alloc] init];
cell.backgroundColor = [UIColor redColor];

MXSession* session = self.mainSession;
if (section == SECTION_PIN_CODE)
if (sectionTag == SECTION_PIN_CODE)
{
if (indexPath.row == PIN_CODE_SETTING)
if (rowTag == PIN_CODE_SETTING)
{
if ([PinCodePreferences shared].forcePinProtection)
{
Expand All @@ -1216,7 +1218,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else if (indexPath.row == PIN_CODE_DESCRIPTION)
else if (rowTag == PIN_CODE_DESCRIPTION)
{
if ([PinCodePreferences shared].isPinSet)
{
Expand All @@ -1228,11 +1230,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [self descriptionCellForTableView:tableView withText:nil];
}
}
else if (indexPath.row == PIN_CODE_CHANGE)
else if (rowTag == PIN_CODE_CHANGE)
{
cell = [self buttonCellWithTitle:NSLocalizedStringFromTable(@"pin_protection_settings_change_pin", @"Vector", nil) action:@selector(changePinCode: ) forTableView:tableView atIndexPath:indexPath];
}
else if (indexPath.row == PIN_CODE_BIOMETRICS)
else if (rowTag == PIN_CODE_BIOMETRICS)
{
MXKTableViewCellWithLabelAndSwitch *switchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];

Expand All @@ -1245,11 +1247,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = switchCell;
}
}
else if (section == SECTION_CRYPTO_SESSIONS)
else if (sectionTag == SECTION_CRYPTO_SESSIONS)
{
if (self.showLoadingDevicesInformation)
{
if (indexPath.row == 0)
if (rowTag == 0)
{
cell = [self descriptionCellForTableView:tableView
withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_loading", @"Vector", nil) ];
Expand All @@ -1262,31 +1264,31 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
else
{
if (row < devicesArray.count)
if (rowTag < devicesArray.count)
{
cell = [self deviceCellWithDevice:devicesArray[row] forTableView:tableView];
cell = [self deviceCellWithDevice:devicesArray[rowTag] forTableView:tableView];
}
else if (row == devicesArray.count)
else if (rowTag == devicesArray.count)
{
cell = [self descriptionCellForTableView:tableView
withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_description_2", @"Vector", nil) ];

}
}
}
else if (section == SECTION_SECURE_BACKUP)
else if (sectionTag == SECTION_SECURE_BACKUP)
{
cell = [secureBackupSection cellForRowAtRow:row];
cell = [secureBackupSection cellForRowAtRow:rowTag];
}
#ifdef CROSS_SIGNING_AND_BACKUP_DEV
else if (section == SECTION_KEYBACKUP)
{
cell = [keyBackupSection cellForRowAtRow:row];
}
#endif
else if (section == SECTION_CROSSSIGNING)
else if (sectionTag == SECTION_CROSSSIGNING)
{
switch (row)
switch (rowTag)
{
case CROSSSIGNING_INFO:
{
Expand All @@ -1303,9 +1305,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
break;
}
}
else if (section == SECTION_CRYPTOGRAPHY)
else if (sectionTag == SECTION_CRYPTOGRAPHY)
{
switch (row)
switch (rowTag)
{
case CRYPTOGRAPHY_INFO:
{
Expand All @@ -1325,9 +1327,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
}
}
else if (section == SECTION_ADVANCED)
else if (sectionTag == SECTION_ADVANCED)
{
switch (row)
switch (rowTag)
{
case ADVANCED_BLACKLIST_UNVERIFIED_DEVICES:
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4415.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cannot disable Face ID after disabling pin.
1 change: 1 addition & 0 deletions changelog.d/4461.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes "PIN & (NULL)" security section header when device biometrics are not available or not enrolled into.

0 comments on commit 46fdb64

Please sign in to comment.