Make the application settings more configurable

- Update after review
This commit is contained in:
Gil Eluard
2021-04-01 14:16:06 +02:00
parent 885dac920d
commit 37984e76fb
5 changed files with 192 additions and 55 deletions

View File

@@ -329,7 +329,7 @@ TableViewSectionsDelegate>
// Crypto sessions section
if (!RiotSettings.shared.accountManagedExternally)
if (RiotSettings.shared.settingsSecurityScreenShowSessions)
{
Section *sessionsSection = [Section sectionWithTag:SECTION_CRYPTO_SESSIONS];
@@ -353,30 +353,36 @@ TableViewSectionsDelegate>
// Secure backup
if (!RiotSettings.shared.accountManagedExternally)
Section *secureBackupSection = [Section sectionWithTag:SECTION_SECURE_BACKUP];
secureBackupSection.headerTitle = NSLocalizedStringFromTable(@"security_settings_secure_backup", @"Vector", nil);
[secureBackupSection addRowsWithCount:[self numberOfRowsInSecureBackupSection]];
if (secureBackupSection.rows.count)
{
Section *secureBackupSection = [Section sectionWithTag:SECTION_SECURE_BACKUP];
secureBackupSection.headerTitle = NSLocalizedStringFromTable(@"security_settings_secure_backup", @"Vector", nil);
[secureBackupSection addRowsWithCount:[self numberOfRowsInSecureBackupSection]];
[sections addObject:secureBackupSection];
}
// Cryptograhpy
if (!RiotSettings.shared.accountManagedExternally)
Section *cryptograhpySection = [Section sectionWithTag:SECTION_CRYPTOGRAPHY];
cryptograhpySection.headerTitle = NSLocalizedStringFromTable(@"security_settings_cryptography", @"Vector", nil);
if (RiotSettings.shared.settingsSecurityScreenShowCryptographyInfo)
{
Section *cryptograhpySection = [Section sectionWithTag:SECTION_CRYPTOGRAPHY];
cryptograhpySection.headerTitle = NSLocalizedStringFromTable(@"security_settings_cryptography", @"Vector", nil);
[cryptograhpySection addRowWithTag:CRYPTOGRAPHY_INFO];
[cryptograhpySection addRowWithTag:CRYPTOGRAPHY_EXPORT];
[sections addObject:cryptograhpySection];
}
if (RiotSettings.shared.settingsSecurityScreenShowCryptographyExport)
{
[cryptograhpySection addRowWithTag:CRYPTOGRAPHY_EXPORT];
}
if (cryptograhpySection.rows.count)
{
[sections addObject:cryptograhpySection];
}
#ifdef CROSS_SIGNING_AND_BACKUP_DEV
// Cross-Signing
@@ -401,17 +407,20 @@ TableViewSectionsDelegate>
// Advanced
if (!RiotSettings.shared.accountManagedExternally)
Section *advancedSection = [Section sectionWithTag:SECTION_ADVANCED];
advancedSection.headerTitle = NSLocalizedStringFromTable(@"security_settings_advanced", @"Vector", nil);
if (RiotSettings.shared.settingsSecurityScreenShowAdvancedUnverifiedDevices)
{
Section *advancedSection = [Section sectionWithTag:SECTION_ADVANCED];
advancedSection.headerTitle = NSLocalizedStringFromTable(@"security_settings_advanced", @"Vector", nil);
[advancedSection addRowWithTag:ADVANCED_BLACKLIST_UNVERIFIED_DEVICES];
[advancedSection addRowWithTag:ADVANCED_BLACKLIST_UNVERIFIED_DEVICES_DESCRIPTION];
}
if (advancedSection.rows.count)
{
[sections addObject:advancedSection];
}
// Update sections
self.tableViewSections.sections = sections;
@@ -868,28 +877,36 @@ TableViewSectionsDelegate>
- (void)refreshSecureBackupSectionData
{
MXRecoveryService *recoveryService = self.mainSession.crypto.recoveryService;
NSMutableArray *secureBackupSectionState = [NSMutableArray new];
if (recoveryService.hasRecovery)
{
secureBackupSectionState = @[
@(SECURE_BACKUP_RESTORE),
@(SECURE_BACKUP_DELETE),
@(SECURE_BACKUP_DESCRIPTION),
//@(SECURE_BACKUP_MANAGE_MANUALLY),
];
if (RiotSettings.shared.settingsSecurityScreenShowRestoreBackup)
{
[secureBackupSectionState addObject:@(SECURE_BACKUP_RESTORE)];
}
if (RiotSettings.shared.settingsSecurityScreenShowDeleteBackup)
{
[secureBackupSectionState addObject:@(SECURE_BACKUP_DELETE)];
}
}
else
{
secureBackupSectionState = @[
@(SECURE_BACKUP_SETUP),
@(SECURE_BACKUP_DESCRIPTION),
//@(SECURE_BACKUP_MANAGE_MANUALLY),
];
if (RiotSettings.shared.settingsSecurityScreenShowSetupBackup)
{
[secureBackupSectionState addObject:@(SECURE_BACKUP_SETUP)];
}
}
if (secureBackupSectionState.count)
{
[secureBackupSectionState addObject:@(SECURE_BACKUP_DESCRIPTION)];
}
#ifdef CROSS_SIGNING_AND_BACKUP_DEV
secureBackupSectionState = [@[@(SECURE_BACKUP_INFO)] arrayByAddingObjectsFromArray:secureBackupSectionState];
[secureBackupSectionState addObject:@(SECURE_BACKUP_INFO)];
#endif
self->secureBackupSectionState = secureBackupSectionState;
}
- (NSUInteger)secureBackupSectionEnumForRow:(NSUInteger)row