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
@@ -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
+14 -7
View File
@@ -300,7 +300,7 @@ TableViewSectionsDelegate>
Section *sectionUserSettings = [Section sectionWithTag:SECTION_TAG_USER_SETTINGS];
[sectionUserSettings addRowWithTag:USER_SETTINGS_PROFILE_PICTURE_INDEX];
[sectionUserSettings addRowWithTag:USER_SETTINGS_DISPLAYNAME_INDEX];
if (!RiotSettings.shared.accountManagedExternally)
if (RiotSettings.shared.settingsScreenShowChangePassword)
{
[sectionUserSettings addRowWithTag:USER_SETTINGS_CHANGE_PASSWORD_INDEX];
}
@@ -335,7 +335,7 @@ TableViewSectionsDelegate>
{
[sectionUserSettings addRowWithTag:USER_SETTINGS_THREEPIDS_INFORMATION_INDEX];
}
if (!RiotSettings.shared.inviteFriendsNotAllowed)
if (RiotSettings.shared.settingsScreenShowInviteFriends)
{
[sectionUserSettings addRowWithTag:USER_SETTINGS_INVITE_FRIENDS_INDEX];
}
@@ -357,14 +357,21 @@ TableViewSectionsDelegate>
sectionNotificationSettings.headerTitle = NSLocalizedStringFromTable(@"settings_notifications_settings", @"Vector", nil);
[tmpSections addObject:sectionNotificationSettings];
if (BuildSettings.allowVoIPUsage && BuildSettings.stunServerFallbackUrlString
&& !RiotSettings.shared.callsSettingsManagedExternally)
if (BuildSettings.allowVoIPUsage && BuildSettings.stunServerFallbackUrlString)
{
Section *sectionCalls = [Section sectionWithTag:SECTION_TAG_CALLS];
[sectionCalls addRowWithTag:CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX];
[sectionCalls addRowWithTag:CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX];
sectionCalls.headerTitle = NSLocalizedStringFromTable(@"settings_calls_settings", @"Vector", nil);
[tmpSections addObject:sectionCalls];
if (RiotSettings.shared.settingsScreenShowEnableStunServerFallback)
{
[sectionCalls addRowWithTag:CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX];
[sectionCalls addRowWithTag:CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX];
}
if (sectionCalls.rows.count)
{
[tmpSections addObject:sectionCalls];
}
}
if (BuildSettings.settingsScreenShowDiscoverySettings)