From e3c434cda62653db699b0f377c5f4c176f2e5dbf Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 15 Jul 2020 18:43:00 +0100 Subject: [PATCH 1/8] Use headerTextPrimaryColor in headers and don't override system font size. --- .../Security/ManageSession/ManageSessionViewController.m | 3 +-- Riot/Modules/Settings/Security/SecurityViewController.m | 3 +-- Riot/Modules/Settings/SettingsViewController.m | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index b38d68892..c907a9b43 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -516,8 +516,7 @@ enum { { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - tableViewHeaderFooterView.textLabel.font = [UIFont systemFontOfSize:15]; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; } } diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index c77a2f23b..77c24ac39 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -1368,8 +1368,7 @@ TableViewSectionsDelegate> { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - tableViewHeaderFooterView.textLabel.font = [UIFont systemFontOfSize:15]; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; } } diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 6d91b4357..1392b0c11 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -2524,8 +2524,7 @@ TableViewSectionsDelegate> { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - tableViewHeaderFooterView.textLabel.font = [UIFont systemFontOfSize:15]; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; } } From b9338b4298844cc04a47eaa2552153426b76705a Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 15 Jul 2020 19:07:35 +0100 Subject: [PATCH 2/8] Use footnote text style for description cells to match UITableView's footer style. Match the footer colour to the header colour. Add -[SettingsViewController descriptionCellForTableView:] and use for appropriate cells. --- .../ManageSessionViewController.m | 3 ++- .../Security/SecurityViewController.m | 3 ++- .../Modules/Settings/SettingsViewController.m | 22 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index c907a9b43..42e1d64ac 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -403,7 +403,8 @@ enum { { MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; cell.textLabel.text = text; - cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; + cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; cell.textLabel.numberOfLines = 0; cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; cell.selectionStyle = UITableViewCellSelectionStyleNone; diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index 77c24ac39..a5e082253 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -1112,7 +1112,8 @@ TableViewSectionsDelegate> { MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; cell.textLabel.text = text; - cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; + cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; cell.textLabel.numberOfLines = 0; cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; cell.selectionStyle = UITableViewCellSelectionStyleNone; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 1392b0c11..2daa7c07c 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -1524,6 +1524,18 @@ TableViewSectionsDelegate> return cell; } +- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView +{ + MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; + cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; + cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; + cell.textLabel.numberOfLines = 0; + cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + + return cell; +} + - (MXKTableViewCellWithTextView*)textViewCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath { MXKTableViewCellWithTextView *textViewCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier] forIndexPath:indexPath]; @@ -1828,7 +1840,7 @@ TableViewSectionsDelegate> } else if (row == USER_SETTINGS_THREEPIDS_INFORMATION_INDEX) { - MXKTableViewCell *threePidsInformationCell = [self getDefaultTableViewCell:self.tableView]; + MXKTableViewCell *threePidsInformationCell = [self descriptionCellForTableView:self.tableView]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart1] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart2] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.tintColor}]]; @@ -1968,7 +1980,7 @@ TableViewSectionsDelegate> } else if (row == NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX) { - MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView]; + MXKTableViewCell *globalInfoCell = [self descriptionCellForTableView:tableView]; NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; @@ -2040,7 +2052,7 @@ TableViewSectionsDelegate> // Remove "stun:" stunFallbackHost = [stunFallbackHost componentsSeparatedByString:@":"].lastObject; - MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView]; + MXKTableViewCell *globalInfoCell = [self descriptionCellForTableView:tableView]; globalInfoCell.textLabel.text = [VectorL10n settingsCallsStunServerFallbackDescription:stunFallbackHost]; globalInfoCell.textLabel.numberOfLines = 0; globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -2075,7 +2087,7 @@ TableViewSectionsDelegate> case IDENTITY_SERVER_DESCRIPTION_INDEX: { - MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView]; + MXKTableViewCell *descriptionCell = [self descriptionCellForTableView:tableView]; if (account.mxSession.identityService.identityServer) { @@ -2116,7 +2128,7 @@ TableViewSectionsDelegate> case INTEGRATIONS_DESCRIPTION_INDEX: { - MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView]; + MXKTableViewCell *descriptionCell = [self descriptionCellForTableView:tableView]; NSString *integrationManager = [WidgetManager.sharedManager configForUser:session.myUser.userId].apiUrl; NSString *integrationManagerDomain = [NSURL URLWithString:integrationManager].host; From 7c31b5e219b7d9549fd3542988d7ca831e3549ff Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 14 Oct 2021 11:26:55 +0100 Subject: [PATCH 3/8] Use actual footer titles rather than cells that mimic them. --- Riot/Modules/Common/Models/Section.swift | 1 + .../ManageSessionViewController.m | 16 +- ...SettingsSecureBackupTableViewSection.swift | 29 +-- .../Security/SecurityViewController.m | 161 ++++---------- .../Modules/Settings/SettingsViewController.m | 205 +++++------------- 5 files changed, 107 insertions(+), 305 deletions(-) diff --git a/Riot/Modules/Common/Models/Section.swift b/Riot/Modules/Common/Models/Section.swift index 29eb40500..82ab03984 100644 --- a/Riot/Modules/Common/Models/Section.swift +++ b/Riot/Modules/Common/Models/Section.swift @@ -22,6 +22,7 @@ final class Section: NSObject { let tag: Int var rows: [Row] var headerTitle: String? + var footerTitle: String? init(withTag tag: Int) { self.tag = tag diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index 42e1d64ac..63a7e4bff 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -399,20 +399,6 @@ enum { return cell; } -- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView withText:(NSString*)text -{ - MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; - cell.textLabel.text = text; - cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; - cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; - cell.textLabel.numberOfLines = 0; - cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - - return cell; -} - - - (MXKTableViewCellWithTextView*)textViewCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath { MXKTableViewCellWithTextView *textViewCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier] forIndexPath:indexPath]; @@ -517,7 +503,7 @@ enum { { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; } } diff --git a/Riot/Modules/Settings/Security/SecureBackup/SettingsSecureBackupTableViewSection.swift b/Riot/Modules/Settings/Security/SecureBackup/SettingsSecureBackupTableViewSection.swift index cc23c878c..ffeed2121 100644 --- a/Riot/Modules/Settings/Security/SecureBackup/SettingsSecureBackupTableViewSection.swift +++ b/Riot/Modules/Settings/Security/SecureBackup/SettingsSecureBackupTableViewSection.swift @@ -21,7 +21,6 @@ import UIKit func settingsSecureBackupTableViewSectionDidUpdate(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection) func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, textCellForRow: Int) -> MXKTableViewCellWithTextView - func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, descriptionCellForRow: Int) -> MXKTableViewCell func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, buttonCellForRow: Int) -> MXKTableViewCellWithButton // Secure backup @@ -39,7 +38,6 @@ import UIKit private enum BackupRows { case info(text: String) - case description(text: String) case createSecureBackupAction case resetSecureBackupAction case createKeyBackupAction @@ -96,8 +94,6 @@ private enum BackupRows { switch backupRow { case .info(let text): cell = self.textCell(atRow: row, text: text) - case .description(let text): - cell = self.descriptionCell(atRow: row, text: text) case .createSecureBackupAction: cell = self.buttonCellForCreateSecureBackup(atRow: row) case .resetSecureBackupAction: @@ -130,8 +126,7 @@ private enum BackupRows { switch self.viewState { case .loading: backupRows = [ - .info(text: VectorL10n.securitySettingsSecureBackupInfoChecking), - .description(text: VectorL10n.securitySettingsSecureBackupDescription) + .info(text: VectorL10n.securitySettingsSecureBackupInfoChecking) ] case .noSecureBackup(let keyBackupState): @@ -143,16 +138,14 @@ private enum BackupRows { backupRows = [ .info(text: infoText), - .createSecureBackupAction, - .description(text: VectorL10n.securitySettingsSecureBackupDescription) + .createSecureBackupAction ] case .keyBackup(let keyBackupVersion, _, _), .keyBackupNotTrusted(let keyBackupVersion, _): // Manage the key backup in the same way for the moment backupRows = [ .info(text: VectorL10n.securitySettingsSecureBackupInfoValid), .restoreFromKeyBackupAction(keyBackupVersion: keyBackupVersion, title: VectorL10n.securitySettingsSecureBackupRestore), - .deleteKeyBackupAction(keyBackupVersion: keyBackupVersion), - .description(text: VectorL10n.securitySettingsSecureBackupDescription) + .deleteKeyBackupAction(keyBackupVersion: keyBackupVersion) ] } case .secureBackup(let keyBackupState): @@ -165,8 +158,7 @@ private enum BackupRows { backupRows = [ .info(text: infoText), .createKeyBackupAction, - .resetSecureBackupAction, - .description(text: VectorL10n.securitySettingsSecureBackupDescription) + .resetSecureBackupAction ] case .keyBackup(let keyBackupVersion, _, _), .keyBackupNotTrusted(let keyBackupVersion, _): // Manage the key backup in the same way for the moment @@ -174,8 +166,7 @@ private enum BackupRows { .info(text: VectorL10n.securitySettingsSecureBackupInfoValid), .restoreFromKeyBackupAction(keyBackupVersion: keyBackupVersion, title: VectorL10n.securitySettingsSecureBackupRestore), .deleteKeyBackupAction(keyBackupVersion: keyBackupVersion), - .resetSecureBackupAction, - .description(text: VectorL10n.securitySettingsSecureBackupDescription) + .resetSecureBackupAction ] } } @@ -194,16 +185,6 @@ private enum BackupRows { return cell } - private func descriptionCell(atRow row: Int, text: String) -> UITableViewCell { - guard let delegate = self.delegate else { - return UITableViewCell() - } - - let cell = delegate.settingsSecureBackupTableViewSection(self, descriptionCellForRow: row) - cell.textLabel?.text = text - return cell - } - // MARK: - Button cells private func buttonCellForCreateSecureBackup(atRow row: Int) -> UITableViewCell { diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index a5e082253..a34275df6 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -53,7 +53,6 @@ enum { enum { PIN_CODE_SETTING, - PIN_CODE_DESCRIPTION, PIN_CODE_CHANGE, PIN_CODE_BIOMETRICS, PIN_CODE_COUNT @@ -67,7 +66,6 @@ enum { enum { ADVANCED_BLACKLIST_UNVERIFIED_DEVICES, - ADVANCED_BLACKLIST_UNVERIFIED_DEVICES_DESCRIPTION, ADVANCED_COUNT }; @@ -291,17 +289,20 @@ TableViewSectionsDelegate> Section *pinCodeSection = [Section sectionWithTag:SECTION_PIN_CODE]; - // Header title + // Header and footer if ([PinCodePreferences shared].isBiometricsAvailable) { pinCodeSection.headerTitle = [VectorL10n pinProtectionSettingsSectionHeaderWithBiometrics:[PinCodePreferences shared].localizedBiometricsName]; } else { pinCodeSection.headerTitle = [VectorL10n pinProtectionSettingsSectionHeader]; } + if (PinCodePreferences.shared.isPinSet) + { + pinCodeSection.footerTitle = VectorL10n.pinProtectionSettingsSectionFooter; + } // Rows [pinCodeSection addRowWithTag:PIN_CODE_SETTING]; - [pinCodeSection addRowWithTag:PIN_CODE_DESCRIPTION]; if ([PinCodePreferences shared].isPinSet) { @@ -322,19 +323,16 @@ TableViewSectionsDelegate> Section *sessionsSection = [Section sectionWithTag:SECTION_CRYPTO_SESSIONS]; sessionsSection.headerTitle = [VectorL10n securitySettingsCryptoSessions]; - - NSUInteger sessionsSectionRowsCount; if (self.showLoadingDevicesInformation) { - sessionsSectionRowsCount = 2; + sessionsSection.footerTitle = VectorL10n.securitySettingsCryptoSessionsLoading; } else { - sessionsSectionRowsCount = devicesArray.count + 1; + sessionsSection.footerTitle = VectorL10n.securitySettingsCryptoSessionsDescription2; + [sessionsSection addRowsWithCount:devicesArray.count]; } - - [sessionsSection addRowsWithCount:sessionsSectionRowsCount]; [sections addObject:sessionsSection]; } @@ -343,6 +341,7 @@ TableViewSectionsDelegate> Section *secureBackupSection = [Section sectionWithTag:SECTION_SECURE_BACKUP]; secureBackupSection.headerTitle = [VectorL10n securitySettingsSecureBackup]; + secureBackupSection.footerTitle = VectorL10n.securitySettingsSecureBackupDescription; [secureBackupSection addRowsWithCount:self->secureBackupSection.numberOfRows]; @@ -392,17 +391,13 @@ TableViewSectionsDelegate> // Advanced - Section *advancedSection = [Section sectionWithTag:SECTION_ADVANCED]; - advancedSection.headerTitle = [VectorL10n securitySettingsAdvanced]; - if (RiotSettings.shared.settingsSecurityScreenShowAdvancedUnverifiedDevices) { + Section *advancedSection = [Section sectionWithTag:SECTION_ADVANCED]; + advancedSection.headerTitle = VectorL10n.securitySettingsAdvanced; + advancedSection.footerTitle = VectorL10n.securitySettingsBlacklistUnverifiedDevicesDescription; + [advancedSection addRowWithTag:ADVANCED_BLACKLIST_UNVERIFIED_DEVICES]; - [advancedSection addRowWithTag:ADVANCED_BLACKLIST_UNVERIFIED_DEVICES_DESCRIPTION]; - } - - if (advancedSection.rows.count) - { [sections addObject:advancedSection]; } @@ -1107,21 +1102,6 @@ TableViewSectionsDelegate> return shieldImageForDevice; } - -- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView withText:(NSString*)text -{ - MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; - cell.textLabel.text = text; - cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; - cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; - cell.textLabel.numberOfLines = 0; - cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - - return cell; -} - - - (MXKTableViewCellWithTextView*)textViewCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath { MXKTableViewCellWithTextView *textViewCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier] forIndexPath:indexPath]; @@ -1136,17 +1116,6 @@ TableViewSectionsDelegate> return textViewCell; } -- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath -{ - MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; - cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - cell.textLabel.numberOfLines = 0; - cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - - return cell; -} - - (MXKTableViewCellWithButton *)buttonCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath { MXKTableViewCellWithButton *cell = [self.tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier] forIndexPath:indexPath]; @@ -1219,18 +1188,6 @@ TableViewSectionsDelegate> cell.selectionStyle = UITableViewCellSelectionStyleNone; } - else if (rowTag == PIN_CODE_DESCRIPTION) - { - if ([PinCodePreferences shared].isPinSet) - { - cell = [self descriptionCellForTableView:tableView - withText:[VectorL10n pinProtectionSettingsSectionFooter]]; - } - else - { - cell = [self descriptionCellForTableView:tableView withText:nil]; - } - } else if (rowTag == PIN_CODE_CHANGE) { cell = [self buttonCellWithTitle:[VectorL10n pinProtectionSettingsChangePin] action:@selector(changePinCode:) forTableView:tableView atIndexPath:indexPath]; @@ -1249,32 +1206,7 @@ TableViewSectionsDelegate> } else if (sectionTag == SECTION_CRYPTO_SESSIONS) { - if (self.showLoadingDevicesInformation) - { - if (rowTag == 0) - { - cell = [self descriptionCellForTableView:tableView - withText:[VectorL10n securitySettingsCryptoSessionsLoading]]; - } - else - { - cell = [self descriptionCellForTableView:tableView - withText:[VectorL10n securitySettingsCryptoSessionsDescription2]]; - } - } - else - { - if (rowTag < devicesArray.count) - { - cell = [self deviceCellWithDevice:devicesArray[rowTag] forTableView:tableView]; - } - else if (rowTag == devicesArray.count) - { - cell = [self descriptionCellForTableView:tableView - withText:[VectorL10n securitySettingsCryptoSessionsDescription2]]; - - } - } + cell = [self deviceCellWithDevice:devicesArray[rowTag] forTableView:tableView]; } else if (sectionTag == SECTION_SECURE_BACKUP) { @@ -1344,13 +1276,6 @@ TableViewSectionsDelegate> cell = labelAndSwitchCell; break; } - case ADVANCED_BLACKLIST_UNVERIFIED_DEVICES_DESCRIPTION: - { - cell = [self descriptionCellForTableView:tableView - withText:[VectorL10n securitySettingsBlacklistUnverifiedDevicesDescription]]; - - break; - } } } @@ -1369,7 +1294,23 @@ TableViewSectionsDelegate> { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + } +} + +- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +{ + Section *tableSection = [self.tableViewSections sectionAtIndex:section]; + return tableSection.footerTitle; +} + +- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section +{ + if ([view isKindOfClass:UITableViewHeaderFooterView.class]) + { + // Customize label style + UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; } } @@ -1402,19 +1343,19 @@ TableViewSectionsDelegate> } } -- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section -{ - if (section == SECTION_CRYPTO_SESSIONS) - { - return 44; - } - return 24; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -{ - return 24; -} +//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +//{ +// if (section == SECTION_CRYPTO_SESSIONS) +// { +// return 44; +// } +// return 24; +//} +// +//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section +//{ +// return 24; +//} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { @@ -1620,20 +1561,6 @@ TableViewSectionsDelegate> return cell; } -- (MXKTableViewCell *)settingsSecureBackupTableViewSection:(SettingsSecureBackupTableViewSection *)settingsSecureBackupTableViewSection descriptionCellForRow:(NSInteger)textCellForRow -{ - MXKTableViewCell *cell; - - NSIndexPath *indexPath = [self.tableViewSections exactIndexPathForRowTag:textCellForRow sectionTag:SECTION_SECURE_BACKUP]; - - if (indexPath) - { - cell = [self descriptionCellForTableView:self.tableView atIndexPath:indexPath]; - } - - return cell; -} - - (MXKTableViewCellWithButton *)settingsSecureBackupTableViewSection:(SettingsSecureBackupTableViewSection *)settingsSecureBackupTableViewSection buttonCellForRow:(NSInteger)buttonCellForRow { MXKTableViewCellWithButton *cell; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 2daa7c07c..578fa0a64 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -90,8 +90,7 @@ enum enum { - SENDING_MEDIA_CONFIRM_SIZE = 0, - SENDING_MEDIA_CONFIRM_SIZE_DESCRIPTION, + SENDING_MEDIA_CONFIRM_SIZE = 0 }; enum @@ -105,7 +104,6 @@ enum NOTIFICATION_SETTINGS_ENABLE_PUSH_INDEX = 0, NOTIFICATION_SETTINGS_SYSTEM_SETTINGS, NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT, - NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX, NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX, NOTIFICATION_SETTINGS_PIN_UNREAD_INDEX, NOTIFICATION_SETTINGS_DEFAULT_SETTINGS_INDEX, @@ -115,20 +113,17 @@ enum enum { - CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX=0, - CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX, + CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX = 0 }; enum { - INTEGRATIONS_INDEX, - INTEGRATIONS_DESCRIPTION_INDEX, + INTEGRATIONS_INDEX }; enum { LOCAL_CONTACTS_SYNC_INDEX, - LOCAL_CONTACTS_PHONEBOOK_COUNTRY_INDEX, - LOCAL_CONTACTS_SYNC_DESCRIPTION_INDEX + LOCAL_CONTACTS_PHONEBOOK_COUNTRY_INDEX }; enum @@ -139,8 +134,7 @@ enum enum { - IDENTITY_SERVER_INDEX, - IDENTITY_SERVER_DESCRIPTION_INDEX, + IDENTITY_SERVER_INDEX }; enum @@ -362,7 +356,11 @@ TableViewSectionsDelegate> } if (BuildSettings.settingsScreenShowThreepidExplanatory) { - [sectionUserSettings addRowWithTag:USER_SETTINGS_THREEPIDS_INFORMATION_INDEX]; +#warning implement attributed string footers + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart1] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]; + [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart2] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.tintColor}]]; + [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart3] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]]; + sectionUserSettings.footerTitle = attributedString.string; } if (RiotSettings.shared.settingsScreenShowInviteFriends) { @@ -376,15 +374,15 @@ TableViewSectionsDelegate> { Section *sectionMedia = [Section sectionWithTag:SECTION_TAG_SENDING_MEDIA]; [sectionMedia addRowWithTag:SENDING_MEDIA_CONFIRM_SIZE]; - [sectionMedia addRowWithTag:SENDING_MEDIA_CONFIRM_SIZE_DESCRIPTION]; sectionMedia.headerTitle = [VectorL10n settingsSendingMedia]; + sectionMedia.footerTitle = VectorL10n.settingsConfirmMediaSizeDescription; [tmpSections addObject:sectionMedia]; } Section *sectionLinks = [Section sectionWithTag:SECTION_TAG_LINKS]; [sectionLinks addRowWithTag:LINKS_SHOW_URL_PREVIEWS_INDEX]; - [sectionLinks addRowWithTag:LINKS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX]; sectionLinks.headerTitle = [VectorL10n settingsLinks]; + sectionLinks.footerTitle = VectorL10n.settingsShowUrlPreviewsDescription; [tmpSections addObject:sectionLinks]; Section *sectionSecurity = [Section sectionWithTag:SECTION_TAG_SECURITY]; @@ -401,9 +399,9 @@ TableViewSectionsDelegate> } if (@available(iOS 14.0, *)) { - // Don't add Global settings message for iOS 14+ + // Don't display Global settings footer for iOS 14+ } else { - [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX]; + sectionNotificationSettings.footerTitle = [VectorL10n settingsGlobalSettingsInfo:AppInfo.current.displayName]; } [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX]; @@ -420,21 +418,17 @@ TableViewSectionsDelegate> sectionNotificationSettings.headerTitle = [VectorL10n settingsNotifications]; [tmpSections addObject:sectionNotificationSettings]; - if (BuildSettings.allowVoIPUsage && BuildSettings.stunServerFallbackUrlString) + if (BuildSettings.allowVoIPUsage && BuildSettings.stunServerFallbackUrlString && RiotSettings.shared.settingsScreenShowEnableStunServerFallback) { Section *sectionCalls = [Section sectionWithTag:SECTION_TAG_CALLS]; sectionCalls.headerTitle = [VectorL10n settingsCallsSettings]; - - 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]; - } + // Remove "stun:" + NSString* stunFallbackHost = [BuildSettings.stunServerFallbackUrlString componentsSeparatedByString:@":"].lastObject; + sectionCalls.footerTitle = [VectorL10n settingsCallsStunServerFallbackDescription:stunFallbackHost]; + + [sectionCalls addRowWithTag:CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX]; + [tmpSections addObject:sectionCalls]; } if (BuildSettings.settingsScreenShowDiscoverySettings) @@ -453,8 +447,9 @@ TableViewSectionsDelegate> { Section *sectionIdentityServer = [Section sectionWithTag:SECTION_TAG_IDENTITY_SERVER]; [sectionIdentityServer addRowWithTag:IDENTITY_SERVER_INDEX]; - [sectionIdentityServer addRowWithTag:IDENTITY_SERVER_DESCRIPTION_INDEX]; + sectionIdentityServer.headerTitle = [VectorL10n settingsIdentityServerSettings]; + sectionIdentityServer.footerTitle = account.mxSession.identityService.identityServer ? VectorL10n.settingsIdentityServerDescription : VectorL10n.settingsIdentityServerNoIsDescription; [tmpSections addObject:sectionIdentityServer]; } @@ -466,12 +461,10 @@ TableViewSectionsDelegate> { [sectionLocalContacts addRowWithTag:LOCAL_CONTACTS_PHONEBOOK_COUNTRY_INDEX]; } - else - { - [sectionLocalContacts addRowWithTag:LOCAL_CONTACTS_SYNC_DESCRIPTION_INDEX]; - } + NSString *headerTitle = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone ? VectorL10n.settingsPhoneContacts : VectorL10n.settingsContacts; sectionLocalContacts.headerTitle = headerTitle; + sectionLocalContacts.footerTitle = VectorL10n.settingsContactsEnableSyncDescription; [tmpSections addObject:sectionLocalContacts]; } @@ -491,8 +484,12 @@ TableViewSectionsDelegate> { Section *sectionIntegrations = [Section sectionWithTag:SECTION_TAG_INTEGRATIONS]; [sectionIntegrations addRowWithTag:INTEGRATIONS_INDEX]; - [sectionIntegrations addRowWithTag:INTEGRATIONS_DESCRIPTION_INDEX]; sectionIntegrations.headerTitle = [VectorL10n settingsIntegrations]; + + NSString *integrationManager = [WidgetManager.sharedManager configForUser:session.myUser.userId].apiUrl; + NSString *integrationManagerDomain = [NSURL URLWithString:integrationManager].host; + sectionIntegrations.footerTitle = [VectorL10n settingsIntegrationsAllowDescription:integrationManagerDomain]; + [tmpSections addObject:sectionIntegrations]; } @@ -1524,18 +1521,6 @@ TableViewSectionsDelegate> return cell; } -- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView -{ - MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView]; - cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; - cell.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; - cell.textLabel.numberOfLines = 0; - cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - - return cell; -} - - (MXKTableViewCellWithTextView*)textViewCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath { MXKTableViewCellWithTextView *textViewCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier] forIndexPath:indexPath]; @@ -1838,21 +1823,6 @@ TableViewSectionsDelegate> cell = newPhoneCell; } } - else if (row == USER_SETTINGS_THREEPIDS_INFORMATION_INDEX) - { - MXKTableViewCell *threePidsInformationCell = [self descriptionCellForTableView:self.tableView]; - - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart1] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]; - [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart2] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.tintColor}]]; - [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart3] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]]; - - threePidsInformationCell.textLabel.attributedText = attributedString; - threePidsInformationCell.textLabel.numberOfLines = 0; - - threePidsInformationCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = threePidsInformationCell; - } else if (row == USER_SETTINGS_INVITE_FRIENDS_INDEX) { MXKTableViewCell *inviteFriendsCell = [self getDefaultTableViewCell:tableView]; @@ -1891,15 +1861,6 @@ TableViewSectionsDelegate> cell = labelAndSwitchCell; } - else if (row == SENDING_MEDIA_CONFIRM_SIZE_DESCRIPTION) - { - MXKTableViewCell *infoCell = [self getDefaultTableViewCell:tableView]; - infoCell.textLabel.text = [VectorL10n settingsConfirmMediaSizeDescription]; - infoCell.textLabel.numberOfLines = 0; - infoCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = infoCell; - } } else if (section == SECTION_TAG_LINKS) { @@ -1978,19 +1939,6 @@ TableViewSectionsDelegate> cell = labelAndSwitchCell; } - else if (row == NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX) - { - MXKTableViewCell *globalInfoCell = [self descriptionCellForTableView:tableView]; - - NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; - - globalInfoCell.textLabel.text = [VectorL10n settingsGlobalSettingsInfo:appDisplayName]; - globalInfoCell.textLabel.numberOfLines = 0; - - globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = globalInfoCell; - } else if (row == NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX) { MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; @@ -2046,19 +1994,6 @@ TableViewSectionsDelegate> cell = labelAndSwitchCell; } - else if (row == CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX) - { - NSString *stunFallbackHost = BuildSettings.stunServerFallbackUrlString; - // Remove "stun:" - stunFallbackHost = [stunFallbackHost componentsSeparatedByString:@":"].lastObject; - - MXKTableViewCell *globalInfoCell = [self descriptionCellForTableView:tableView]; - globalInfoCell.textLabel.text = [VectorL10n settingsCallsStunServerFallbackDescription:stunFallbackHost]; - globalInfoCell.textLabel.numberOfLines = 0; - globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = globalInfoCell; - } } else if (section == SECTION_TAG_DISCOVERY) { @@ -2085,25 +2020,6 @@ TableViewSectionsDelegate> break; } - case IDENTITY_SERVER_DESCRIPTION_INDEX: - { - MXKTableViewCell *descriptionCell = [self descriptionCellForTableView:tableView]; - - if (account.mxSession.identityService.identityServer) - { - descriptionCell.textLabel.text = [VectorL10n settingsIdentityServerDescription]; - } - else - { - descriptionCell.textLabel.text = [VectorL10n settingsIdentityServerNoIsDescription]; - } - descriptionCell.textLabel.numberOfLines = 0; - descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = descriptionCell; - break; - } - default: break; } @@ -2126,22 +2042,6 @@ TableViewSectionsDelegate> break; } - case INTEGRATIONS_DESCRIPTION_INDEX: - { - MXKTableViewCell *descriptionCell = [self descriptionCellForTableView:tableView]; - - NSString *integrationManager = [WidgetManager.sharedManager configForUser:session.myUser.userId].apiUrl; - NSString *integrationManagerDomain = [NSURL URLWithString:integrationManager].host; - - NSString *description = [VectorL10n settingsIntegrationsAllowDescription:integrationManagerDomain]; - descriptionCell.textLabel.text = description; - descriptionCell.textLabel.numberOfLines = 0; - descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = descriptionCell; - break; - } - default: break; } @@ -2245,15 +2145,6 @@ TableViewSectionsDelegate> [cell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; cell.selectionStyle = UITableViewCellSelectionStyleDefault; } - else if (row == LOCAL_CONTACTS_SYNC_DESCRIPTION_INDEX) - { - MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView]; - descriptionCell.textLabel.text = VectorL10n.settingsContactsEnableSyncDescription; - descriptionCell.textLabel.numberOfLines = 0; - descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = descriptionCell; - } } else if (section == SECTION_TAG_ADVANCED) { @@ -2536,7 +2427,23 @@ TableViewSectionsDelegate> { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.headerTextPrimaryColor; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + } +} + +- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +{ + Section *sectionObj = [_tableViewSections sectionAtIndex:section]; + return sectionObj.footerTitle; +} + +- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section +{ + if ([view isKindOfClass:UITableViewHeaderFooterView.class]) + { + // Customize label style + UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; + tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; } } @@ -2586,15 +2493,15 @@ TableViewSectionsDelegate> } } -- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section -{ - return 24; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -{ - return 24; -} +//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +//{ +// return 24; +//} +// +//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section +//{ +// return [_tableViewSections sectionAtIndex:section].footerTitle ? UITableViewAutomaticDimension : 24; +//} - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { From 687398ce78dfe88fb370891719d222384d584c93 Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 15 Oct 2021 14:37:55 +0100 Subject: [PATCH 4/8] Update fonts, add attributed strings and add tap gestures back. Footers use subheadline. Headers use footnote. --- DesignKit/Source/FontsUIkit.swift | 2 +- Riot/Modules/Common/Models/Section.swift | 16 ++- .../SectionFooters/SectionFooterView.swift | 41 ++++++ .../SettingsDiscoveryTableViewSection.swift | 37 ++---- .../SettingsDiscoveryViewAction.swift | 1 - .../SettingsDiscoveryViewModel.swift | 2 - .../SettingsDiscoveryViewModelType.swift | 1 - .../ManageSessionViewController.m | 1 + .../Security/SecurityViewController.m | 29 +++-- .../Modules/Settings/SettingsViewController.m | 121 +++++++++--------- .../View/FormSectionFooter.swift | 2 +- .../View/FormSectionHeader.swift | 2 +- 12 files changed, 152 insertions(+), 103 deletions(-) create mode 100644 Riot/Modules/Common/SectionFooters/SectionFooterView.swift diff --git a/DesignKit/Source/FontsUIkit.swift b/DesignKit/Source/FontsUIkit.swift index b39f15f1b..3067d03a1 100644 --- a/DesignKit/Source/FontsUIkit.swift +++ b/DesignKit/Source/FontsUIkit.swift @@ -20,7 +20,7 @@ import UIKit /** ObjC class for holding fonts for use in UIKit. */ -@objc public class FontsUIKit: NSObject, Fonts { +@objcMembers public class FontsUIKit: NSObject, Fonts { public var largeTitle: UIFont diff --git a/Riot/Modules/Common/Models/Section.swift b/Riot/Modules/Common/Models/Section.swift index 82ab03984..c9cae8131 100644 --- a/Riot/Modules/Common/Models/Section.swift +++ b/Riot/Modules/Common/Models/Section.swift @@ -22,7 +22,21 @@ final class Section: NSObject { let tag: Int var rows: [Row] var headerTitle: String? - var footerTitle: String? + var attributedFooterTitle: NSAttributedString? + + var footerTitle: String? { + get { + attributedFooterTitle?.string + } + set { + guard let newValue = newValue else { + attributedFooterTitle = nil + return + } + + attributedFooterTitle = NSAttributedString(string: newValue) + } + } init(withTag tag: Int) { self.tag = tag diff --git a/Riot/Modules/Common/SectionFooters/SectionFooterView.swift b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift new file mode 100644 index 000000000..394207b74 --- /dev/null +++ b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift @@ -0,0 +1,41 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit + +/// A subclass of `UITableViewHeaderFooterView` that conforms `Themable` +/// to create a consistent looking custom footer inside of the app. If using gesture +/// recognizers on the view, be aware that these will be automatically removed on reuse. +@objcMembers +class SectionFooterView: UITableViewHeaderFooterView, Themable { + static var defaultReuseIdentifier: String { + String(describing: Self.self) + } + + override func prepareForReuse() { + super.prepareForReuse() + + for recognizer in gestureRecognizers ?? [] { + removeGestureRecognizer(recognizer) + } + } + + func update(theme: Theme) { + textLabel?.textColor = theme.colors.secondaryContent + textLabel?.font = theme.fonts.subheadline + textLabel?.numberOfLines = 0 + } +} diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift index 6bee0aebe..5d2ca0a18 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift @@ -24,7 +24,6 @@ import Foundation private enum DiscoverySectionRows { case info(text: String) - case attributedInfo(attributedText: NSAttributedString) case button(title: String, action: () -> Void) case threePid(threePid: MX3PID) } @@ -41,6 +40,12 @@ private enum DiscoverySectionRows { @objc weak var delegate: SettingsDiscoveryTableViewSectionDelegate? + @objc var attributedFooterTitle: NSAttributedString? + + @objc var footerShouldScrollToUserSettings: Bool { + attributedFooterTitle != nil + } + // MARK: Private private var theme: Theme! @@ -96,13 +101,6 @@ private enum DiscoverySectionRows { infoCell.selectionStyle = .none cell = infoCell } - case .attributedInfo(attributedText: let infoText): - if let infoCell: MXKTableViewCell = self.cellType(at: row) { - infoCell.textLabel?.numberOfLines = 0 - infoCell.textLabel?.attributedText = infoText - infoCell.selectionStyle = .none - cell = infoCell - } case .button(title: let title, action: let action): if let buttonCell: MXKTableViewCellWithButton = self.cellType(at: row) { buttonCell.mxkButton.setTitle(title, for: .normal) @@ -145,15 +143,6 @@ private enum DiscoverySectionRows { switch discoveryRow { case .threePid(threePid: let threePid): self.viewModel.process(viewAction: .select(threePid: threePid)) - case .attributedInfo(attributedText: _): - if case let .loaded(displayMode) = self.viewState { - switch displayMode { - case .noThreePidsAdded, .threePidsAdded: - self.viewModel.process(viewAction: .tapUserSettingsLink) - default: - break - } - } default: break } @@ -183,6 +172,7 @@ private enum DiscoverySectionRows { private func updateRows() { + attributedFooterTitle = nil; let discoveryRows: [DiscoverySectionRows] switch self.viewState { @@ -202,9 +192,8 @@ private enum DiscoverySectionRows { }) ] case .noThreePidsAdded: - discoveryRows = [ - .attributedInfo(attributedText: self.threePidsManagementInfoAttributedString()) - ] + discoveryRows = [] + attributedFooterTitle = self.threePidsManagementInfoAttributedString() case .threePidsAdded(let emails, let phoneNumbers): let emailThreePids = emails.map { (email) -> DiscoverySectionRows in @@ -218,7 +207,7 @@ private enum DiscoverySectionRows { var threePidsRows: [DiscoverySectionRows] = [] threePidsRows.append(contentsOf: emailThreePids) threePidsRows.append(contentsOf: phoneNumbersThreePids) - threePidsRows.append(.attributedInfo(attributedText: self.threePidsManagementInfoAttributedString())) + attributedFooterTitle = self.threePidsManagementInfoAttributedString() discoveryRows = threePidsRows } @@ -236,11 +225,11 @@ private enum DiscoverySectionRows { private func threePidsManagementInfoAttributedString() -> NSAttributedString { let attributedInfoString = NSMutableAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart1, - attributes: [.foregroundColor: self.theme.textPrimaryColor, .font: Constants.defaultFont]) + attributes: [:]) attributedInfoString.append(NSAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart2, - attributes: [.foregroundColor: self.theme.tintColor, .font: Constants.defaultFont])) + attributes: [.foregroundColor: self.theme.tintColor])) attributedInfoString.append(NSAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart3, - attributes: [.foregroundColor: self.theme.tintColor, .font: Constants.defaultFont])) + attributes: [:])) return attributedInfoString } } diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewAction.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewAction.swift index 2122ee175..d51ddba17 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewAction.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewAction.swift @@ -21,5 +21,4 @@ enum SettingsDiscoveryViewAction { case load case acceptTerms case select(threePid: MX3PID) - case tapUserSettingsLink } diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift index b512992be..8eba596c0 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift @@ -59,8 +59,6 @@ import Foundation self.acceptTerms() case .select(threePid: let threePid): self.coordinatorDelegate?.settingsDiscoveryViewModel(self, didSelectThreePidWith: threePid.medium.identifier, and: threePid.address) - case .tapUserSettingsLink: - self.coordinatorDelegate?.settingsDiscoveryViewModelDidTapUserSettingsLink(self) } } diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift index 0435a5eb5..5acfdfad2 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift @@ -22,7 +22,6 @@ protocol SettingsDiscoveryViewModelViewDelegate: AnyObject { @objc protocol SettingsDiscoveryViewModelCoordinatorDelegate: AnyObject { func settingsDiscoveryViewModel(_ viewModel: SettingsDiscoveryViewModel, didSelectThreePidWith medium: String, and address: String) - func settingsDiscoveryViewModelDidTapUserSettingsLink(_ viewModel: SettingsDiscoveryViewModel) } protocol SettingsDiscoveryViewModelType { diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index 63a7e4bff..930ab5899 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -504,6 +504,7 @@ enum { // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote; } } diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index a34275df6..1f8adbf4c 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -159,10 +159,13 @@ TableViewSectionsDelegate> [self.tableView registerClass:MXKTableViewCellWithLabelAndSwitch.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithTextView.nib forCellReuseIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithButton.nib forCellReuseIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; + [self.tableView registerClass:SectionFooterView.class forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; - // Enable self sizing cells + // Enable self sizing cells and footers self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 50; + self.tableView.sectionFooterHeight = UITableViewAutomaticDimension; + self.tableView.estimatedSectionFooterHeight = 50; if (self.mainSession.crypto.backup) { @@ -1295,26 +1298,26 @@ TableViewSectionsDelegate> // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote; } } -- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { - Section *tableSection = [self.tableViewSections sectionAtIndex:section]; - return tableSection.footerTitle; -} - -- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section -{ - if ([view isKindOfClass:UITableViewHeaderFooterView.class]) + NSString *footerTitle = [_tableViewSections sectionAtIndex:section].footerTitle; + + if (!footerTitle) { - // Customize label style - UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + return nil; } + + SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; + [view updateWithTheme:ThemeService.shared.theme]; + view.textLabel.text = footerTitle; + + return view; } - #pragma mark - UITableView delegate - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 578fa0a64..5372838f5 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -78,7 +78,6 @@ enum USER_SETTINGS_SURNAME_INDEX, USER_SETTINGS_ADD_EMAIL_INDEX, USER_SETTINGS_ADD_PHONENUMBER_INDEX, - USER_SETTINGS_THREEPIDS_INFORMATION_INDEX, USER_SETTINGS_INVITE_FRIENDS_INDEX }; @@ -356,11 +355,10 @@ TableViewSectionsDelegate> } if (BuildSettings.settingsScreenShowThreepidExplanatory) { -#warning implement attributed string footers - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart1] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]; + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart1] attributes:@{}]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart2] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.tintColor}]]; - [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart3] attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.textPrimaryColor}]]; - sectionUserSettings.footerTitle = attributedString.string; + [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart3] attributes:@{}]]; + sectionUserSettings.attributedFooterTitle = attributedString; } if (RiotSettings.shared.settingsScreenShowInviteFriends) { @@ -440,6 +438,7 @@ TableViewSectionsDelegate> [sectionDiscovery addRowWithTag:index]; } sectionDiscovery.headerTitle = [VectorL10n settingsDiscoverySettings]; + sectionDiscovery.attributedFooterTitle = self.settingsDiscoveryTableViewSection.attributedFooterTitle; [tmpSections addObject:sectionDiscovery]; } @@ -597,10 +596,13 @@ TableViewSectionsDelegate> [self.tableView registerClass:TableViewCellWithPhoneNumberTextField.class forCellReuseIdentifier:[TableViewCellWithPhoneNumberTextField defaultReuseIdentifier]]; [self.tableView registerClass:GroupTableViewCellWithSwitch.class forCellReuseIdentifier:[GroupTableViewCellWithSwitch defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithTextView.nib forCellReuseIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; + [self.tableView registerClass:SectionFooterView.class forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; - // Enable self sizing cells + // Enable self sizing cells and footers self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 50; + self.tableView.sectionFooterHeight = UITableViewAutomaticDimension; + self.tableView.estimatedSectionFooterHeight = 50; // Add observer to handle removed accounts removedAccountObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountManagerDidRemoveAccountNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { @@ -1354,6 +1356,38 @@ TableViewSectionsDelegate> return userInteractiveAuthenticationService; } +- (void)scrollToDiscoverySection +{ + // settingsDiscoveryTableViewSection is a dynamic section, so check number of rows before scroll to avoid crashes + if (self.settingsDiscoveryTableViewSection.numberOfRows > 0) + { + NSIndexPath *discoveryIndexPath = [_tableViewSections exactIndexPathForRowTag:0 sectionTag:SECTION_TAG_DISCOVERY]; + if (discoveryIndexPath) + { + [self.tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; + } + } + else + { + // this won't be precise in scroll location, but seems the best option for now + NSIndexPath *discoveryIndexPath = [_tableViewSections nearestIndexPathForRowTag:0 sectionTag:SECTION_TAG_DISCOVERY]; + if (discoveryIndexPath) + { + [self.tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; + } + } +} + +- (void)scrollToUserSettingsSection +{ + NSIndexPath *discoveryIndexPath = [_tableViewSections exactIndexPathForRowTag:USER_SETTINGS_ADD_EMAIL_INDEX + sectionTag:SECTION_TAG_USER_SETTINGS]; + if (discoveryIndexPath) + { + [self.tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; + } +} + #pragma mark - 3Pid Add - (void)showAuthenticationIfNeededForAdding:(MX3PIDMedium)medium withSession:(MXSession*)session completion:(void (^)(NSDictionary* authParams))completion @@ -2428,23 +2462,35 @@ TableViewSectionsDelegate> // Customize label style UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote; } } -- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { - Section *sectionObj = [_tableViewSections sectionAtIndex:section]; - return sectionObj.footerTitle; -} - -- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section -{ - if ([view isKindOfClass:UITableViewHeaderFooterView.class]) + NSAttributedString *attributedFooterTitle = [_tableViewSections sectionAtIndex:section].attributedFooterTitle; + + if (!attributedFooterTitle) { - // Customize label style - UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view; - tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent; + return nil; } + + SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; + [view updateWithTheme:ThemeService.shared.theme]; + view.textLabel.attributedText = attributedFooterTitle; + + if (section == SECTION_TAG_USER_SETTINGS) + { + UIGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollToDiscoverySection)]; + [view addGestureRecognizer:recognizer]; + } + else if (section == SECTION_TAG_DISCOVERY && self.settingsDiscoveryTableViewSection.footerShouldScrollToUserSettings) + { + UIGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollToUserSettingsSection)]; + [view addGestureRecognizer:recognizer]; + } + + return view; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath @@ -2493,16 +2539,6 @@ TableViewSectionsDelegate> } } -//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section -//{ -// return 24; -//} -// -//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -//{ -// return [_tableViewSections sectionAtIndex:section].footerTitle ? UITableViewAutomaticDimension : 24; -//} - - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *tagsIndexPath = [_tableViewSections tagsIndexPathFromTableViewIndexPath:indexPath]; @@ -2559,27 +2595,6 @@ TableViewSectionsDelegate> [self showThemePicker]; } } - else if (section == SECTION_TAG_USER_SETTINGS && row == USER_SETTINGS_THREEPIDS_INFORMATION_INDEX) - { - // settingsDiscoveryTableViewSection is a dynamic section, so check number of rows before scroll to avoid crashes - if (self.settingsDiscoveryTableViewSection.numberOfRows > 0) - { - NSIndexPath *discoveryIndexPath = [_tableViewSections exactIndexPathForRowTag:0 sectionTag:SECTION_TAG_DISCOVERY]; - if (discoveryIndexPath) - { - [tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; - } - } - else - { - // this won't be precise in scroll location, but seems the best option for now - NSIndexPath *discoveryIndexPath = [_tableViewSections nearestIndexPathForRowTag:0 sectionTag:SECTION_TAG_DISCOVERY]; - if (discoveryIndexPath) - { - [tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; - } - } - } else if (section == SECTION_TAG_USER_SETTINGS && row == USER_SETTINGS_INVITE_FRIENDS_INDEX) { UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; @@ -4417,16 +4432,6 @@ TableViewSectionsDelegate> self.discoveryThreePidDetailsPresenter = discoveryThreePidDetailsPresenter; } -- (void)settingsDiscoveryViewModelDidTapUserSettingsLink:(SettingsDiscoveryViewModel *)viewModel -{ - NSIndexPath *discoveryIndexPath = [_tableViewSections exactIndexPathForRowTag:USER_SETTINGS_ADD_EMAIL_INDEX - sectionTag:SECTION_TAG_USER_SETTINGS]; - if (discoveryIndexPath) - { - [self.tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; - } -} - #pragma mark - Local Contacts Sync - (void)checkAccessForContacts diff --git a/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift index 190a397f6..9518e0b51 100644 --- a/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift +++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift @@ -28,7 +28,7 @@ struct FormSectionFooter: View { .padding(.top) .padding(.leading) .padding(.trailing) - .font(theme.fonts.callout) + .font(theme.fonts.subheadline) } } diff --git a/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift index 54bd4def2..a82afd1de 100644 --- a/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift +++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift @@ -28,7 +28,7 @@ struct FormSectionHeader: View { .padding(.top, 32) .padding(.leading) .padding(.bottom, 8) - .font(theme.fonts.subheadline) + .font(theme.fonts.footnote) .textCase(.uppercase) .frame(maxWidth: .infinity, alignment: .leading) } From 8f6035066667f8d46a4876bfe68eed6f15a043fa Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 19 Oct 2021 15:18:15 +0100 Subject: [PATCH 5/8] Use footers for app and discovery information. Remove Invite Friends button from settings. Reorganise Advanced and Other settings. Rename Other to About. --- Riot/Assets/en.lproj/Vector.strings | 4 +- Riot/Generated/Strings.swift | 12 +- Riot/Managers/AppInfo/AppVersion.swift | 2 +- Riot/Managers/Settings/RiotSettings.swift | 3 - .../SettingsDiscoveryTableViewSection.swift | 42 ++- .../Modules/Settings/SettingsViewController.m | 274 +++++++----------- changelog.d/pr-5011.change | 1 + 7 files changed, 136 insertions(+), 202 deletions(-) create mode 100644 changelog.d/pr-5011.change diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 90551f97a..844626362 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -457,7 +457,6 @@ Tap the + to start adding people."; "settings_report_bug" = "Report bug"; "settings_clear_cache" = "Clear cache"; "settings_config_home_server" = "Homeserver is %@"; -"settings_config_identity_server" = "Identity server is %@"; "settings_config_user_id" = "Logged in as %@"; "settings_user_settings" = "USER SETTINGS"; @@ -473,7 +472,7 @@ Tap the + to start adding people."; "settings_contacts" = "DEVICE CONTACTS"; "settings_phone_contacts" = "PHONE CONTACTS"; "settings_advanced" = "ADVANCED"; -"settings_other" = "OTHER"; +"settings_about" = "ABOUT"; "settings_labs" = "LABS"; "settings_flair" = "Show flair where allowed"; "settings_devices" = "SESSIONS"; @@ -629,6 +628,7 @@ Tap the + to start adding people."; "settings_discovery_no_identity_server" = "You are not currently using an identity server. To be discoverable by existing contacts you known, add one."; "settings_discovery_terms_not_signed" = "Agree to the identity server (%@) Terms of Service to allow yourself to be discoverable by email address or phone number."; +"settings_discovery_accept_terms" = "Accept Identity Server Terms"; "settings_discovery_three_pids_management_information_part1" = "Manage which email addresses or phone numbers other users can use to discover you and use to invite you to rooms. Add or remove email addresses or phone numbers from this list in "; "settings_discovery_three_pids_management_information_part2" = "User Settings"; "settings_discovery_three_pids_management_information_part3" = "."; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 2801397ab..54ca11b35 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -4087,6 +4087,10 @@ public class VectorL10n: NSObject { public static var serviceTermsModalTitleMessage: String { return VectorL10n.tr("Vector", "service_terms_modal_title_message") } + /// ABOUT + public static var settingsAbout: String { + return VectorL10n.tr("Vector", "settings_about") + } /// Invalid credentials public static var settingsAdd3pidInvalidPasswordMessage: String { return VectorL10n.tr("Vector", "settings_add_3pid_invalid_password_message") @@ -4147,10 +4151,6 @@ public class VectorL10n: NSObject { public static func settingsConfigHomeServer(_ p1: String) -> String { return VectorL10n.tr("Vector", "settings_config_home_server", p1) } - /// Identity server is %@ - public static func settingsConfigIdentityServer(_ p1: String) -> String { - return VectorL10n.tr("Vector", "settings_config_identity_server", p1) - } /// No build info public static var settingsConfigNoBuildInfo: String { return VectorL10n.tr("Vector", "settings_config_no_build_info") @@ -4243,6 +4243,10 @@ public class VectorL10n: NSObject { public static var settingsDirectMessages: String { return VectorL10n.tr("Vector", "settings_direct_messages") } + /// Accept Identity Server Terms + public static var settingsDiscoveryAcceptTerms: String { + return VectorL10n.tr("Vector", "settings_discovery_accept_terms") + } /// An error occured. Please retry. public static var settingsDiscoveryErrorMessage: String { return VectorL10n.tr("Vector", "settings_discovery_error_message") diff --git a/Riot/Managers/AppInfo/AppVersion.swift b/Riot/Managers/AppInfo/AppVersion.swift index ff7e25080..dc75e5994 100644 --- a/Riot/Managers/AppInfo/AppVersion.swift +++ b/Riot/Managers/AppInfo/AppVersion.swift @@ -96,7 +96,7 @@ final class AppVersion: NSObject { } override var description: String { - return "\(bundleShortVersion)(\(bundleVersion))" + return "\(bundleShortVersion) (\(bundleVersion))" } // MARK: - Private diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 7f4adf16c..9e1ccd05b 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -233,9 +233,6 @@ final class RiotSettings: NSObject { @UserDefault(key: "settingsScreenShowChangePassword", defaultValue: BuildSettings.settingsScreenShowChangePassword, storage: defaults) var settingsScreenShowChangePassword - @UserDefault(key: "settingsScreenShowInviteFriends", defaultValue: BuildSettings.settingsScreenShowInviteFriends, storage: defaults) - var settingsScreenShowInviteFriends - @UserDefault(key: "settingsScreenShowEnableStunServerFallback", defaultValue: BuildSettings.settingsScreenShowEnableStunServerFallback, storage: defaults) var settingsScreenShowEnableStunServerFallback diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift index 5d2ca0a18..187f53c8c 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift @@ -23,7 +23,6 @@ import Foundation } private enum DiscoverySectionRows { - case info(text: String) case button(title: String, action: () -> Void) case threePid(threePid: MX3PID) } @@ -41,10 +40,7 @@ private enum DiscoverySectionRows { @objc weak var delegate: SettingsDiscoveryTableViewSectionDelegate? @objc var attributedFooterTitle: NSAttributedString? - - @objc var footerShouldScrollToUserSettings: Bool { - attributedFooterTitle != nil - } + @objc var footerShouldScrollToUserSettings = false // MARK: Private @@ -94,13 +90,6 @@ private enum DiscoverySectionRows { } switch discoveryRow { - case .info(let infoText): - if let infoCell: MXKTableViewCell = self.cellType(at: row) { - infoCell.textLabel?.numberOfLines = 0 - infoCell.textLabel?.text = infoText - infoCell.selectionStyle = .none - cell = infoCell - } case .button(title: let title, action: let action): if let buttonCell: MXKTableViewCellWithButton = self.cellType(at: row) { buttonCell.mxkButton.setTitle(title, for: .normal) @@ -172,7 +161,10 @@ private enum DiscoverySectionRows { private func updateRows() { - attributedFooterTitle = nil; + // reset the footer + attributedFooterTitle = nil + footerShouldScrollToUserSettings = false + let discoveryRows: [DiscoverySectionRows] switch self.viewState { @@ -181,19 +173,21 @@ private enum DiscoverySectionRows { case .loaded(let displayMode): switch displayMode { case .noIdentityServer: - discoveryRows = [ - .info(text: VectorL10n.settingsDiscoveryNoIdentityServer) - ] + discoveryRows = [] + attributedFooterTitle = NSAttributedString(string: VectorL10n.settingsDiscoveryNoIdentityServer) case .termsNotSigned(let host): discoveryRows = [ - .info(text: VectorL10n.settingsDiscoveryTermsNotSigned(host)), - .button(title: VectorL10n.accept, action: { [weak self] in + .button(title: VectorL10n.settingsDiscoveryAcceptTerms, action: { [weak self] in self?.viewModel.process(viewAction: .acceptTerms) }) ] + + attributedFooterTitle = NSAttributedString(string: VectorL10n.settingsDiscoveryTermsNotSigned(host)) case .noThreePidsAdded: discoveryRows = [] - attributedFooterTitle = self.threePidsManagementInfoAttributedString() + + attributedFooterTitle = threePidsManagementInfoAttributedString() + footerShouldScrollToUserSettings = true case .threePidsAdded(let emails, let phoneNumbers): let emailThreePids = emails.map { (email) -> DiscoverySectionRows in @@ -204,20 +198,18 @@ private enum DiscoverySectionRows { return .threePid(threePid: phoneNumber) } - var threePidsRows: [DiscoverySectionRows] = [] - threePidsRows.append(contentsOf: emailThreePids) - threePidsRows.append(contentsOf: phoneNumbersThreePids) - attributedFooterTitle = self.threePidsManagementInfoAttributedString() + discoveryRows = emailThreePids + phoneNumbersThreePids - discoveryRows = threePidsRows + attributedFooterTitle = threePidsManagementInfoAttributedString() + footerShouldScrollToUserSettings = true } case .error: discoveryRows = [ - .info(text: VectorL10n.settingsDiscoveryErrorMessage), .button(title: VectorL10n.retry, action: { [weak self] in self?.viewModel.process(viewAction: .load) }) ] + attributedFooterTitle = NSAttributedString(string: VectorL10n.settingsDiscoveryErrorMessage) } self.discoveryRows = discoveryRows diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 5372838f5..d51807d30 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -63,7 +63,7 @@ enum SECTION_TAG_INTEGRATIONS, SECTION_TAG_USER_INTERFACE, SECTION_TAG_ADVANCED, - SECTION_TAG_OTHER, + SECTION_TAG_ABOUT, SECTION_TAG_LABS, SECTION_TAG_FLAIR, SECTION_TAG_DEACTIVATE_ACCOUNT @@ -77,8 +77,7 @@ enum USER_SETTINGS_FIRST_NAME_INDEX, USER_SETTINGS_SURNAME_INDEX, USER_SETTINGS_ADD_EMAIL_INDEX, - USER_SETTINGS_ADD_PHONENUMBER_INDEX, - USER_SETTINGS_INVITE_FRIENDS_INDEX + USER_SETTINGS_ADD_PHONENUMBER_INDEX }; enum @@ -138,18 +137,20 @@ enum enum { - OTHER_VERSION_INDEX = 0, - OTHER_OLM_VERSION_INDEX, - OTHER_COPYRIGHT_INDEX, - OTHER_TERM_CONDITIONS_INDEX, - OTHER_PRIVACY_INDEX, - OTHER_THIRD_PARTY_INDEX, - OTHER_SHOW_NSFW_ROOMS_INDEX, - OTHER_CRASH_REPORT_INDEX, - OTHER_ENABLE_RAGESHAKE_INDEX, - OTHER_MARK_ALL_AS_READ_INDEX, - OTHER_CLEAR_CACHE_INDEX, - OTHER_REPORT_BUG_INDEX, + ADVANCED_SHOW_NSFW_ROOMS_INDEX = 0, + ADVANCED_CRASH_REPORT_INDEX, + ADVANCED_ENABLE_RAGESHAKE_INDEX, + ADVANCED_MARK_ALL_AS_READ_INDEX, + ADVANCED_CLEAR_CACHE_INDEX, + ADVANCED_REPORT_BUG_INDEX, +}; + +enum +{ + ABOUT_COPYRIGHT_INDEX = 0, + ABOUT_TERM_CONDITIONS_INDEX, + ABOUT_PRIVACY_INDEX, + ABOUT_THIRD_PARTY_INDEX, }; enum @@ -267,8 +268,6 @@ TableViewSectionsDelegate> @property (nonatomic, strong) TableViewSections *tableViewSections; -@property (nonatomic, strong) InviteFriendsPresenter *inviteFriendsPresenter; - @property (nonatomic, strong) CrossSigningSetupCoordinatorBridgePresenter *crossSigningSetupCoordinatorBridgePresenter; @property (nonatomic, strong) ReauthenticationCoordinatorBridgePresenter *reauthenticationCoordinatorBridgePresenter; @@ -360,10 +359,6 @@ TableViewSectionsDelegate> [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[VectorL10n settingsThreePidsManagementInformationPart3] attributes:@{}]]; sectionUserSettings.attributedFooterTitle = attributedString; } - if (RiotSettings.shared.settingsScreenShowInviteFriends) - { - [sectionUserSettings addRowWithTag:USER_SETTINGS_INVITE_FRIENDS_INDEX]; - } sectionUserSettings.headerTitle = [VectorL10n settingsUserSettings]; [tmpSections addObject:sectionUserSettings]; @@ -498,51 +493,57 @@ TableViewSectionsDelegate> sectionUserInterface.headerTitle = [VectorL10n settingsUserInterface]; [tmpSections addObject: sectionUserInterface]; - if (BuildSettings.settingsScreenShowAdvancedSettings) - { - Section *sectionAdvanced = [Section sectionWithTag:SECTION_TAG_ADVANCED]; - [sectionAdvanced addRowWithTag:0]; - sectionAdvanced.headerTitle = [VectorL10n settingsAdvanced]; - [tmpSections addObject:sectionAdvanced]; - } + Section *sectionAdvanced = [Section sectionWithTag:SECTION_TAG_ADVANCED]; + sectionAdvanced.headerTitle = [VectorL10n settingsAdvanced]; - Section *sectionOther = [Section sectionWithTag:SECTION_TAG_OTHER]; - [sectionOther addRowWithTag:OTHER_VERSION_INDEX]; - [sectionOther addRowWithTag:OTHER_OLM_VERSION_INDEX]; - if (BuildSettings.applicationCopyrightUrlString.length) - { - [sectionOther addRowWithTag:OTHER_COPYRIGHT_INDEX]; - } - if (BuildSettings.applicationTermsConditionsUrlString.length) - { - [sectionOther addRowWithTag:OTHER_TERM_CONDITIONS_INDEX]; - } - if (BuildSettings.applicationPrivacyPolicyUrlString.length) - { - [sectionOther addRowWithTag:OTHER_PRIVACY_INDEX]; - } - [sectionOther addRowWithTag:OTHER_THIRD_PARTY_INDEX]; if (RiotSettings.shared.settingsScreenShowNsfwRoomsOption) { - [sectionOther addRowWithTag:OTHER_SHOW_NSFW_ROOMS_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_SHOW_NSFW_ROOMS_INDEX]; } if (BuildSettings.settingsScreenAllowChangingCrashUsageDataSettings) { - [sectionOther addRowWithTag:OTHER_CRASH_REPORT_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_CRASH_REPORT_INDEX]; } if (BuildSettings.settingsScreenAllowChangingRageshakeSettings) { - [sectionOther addRowWithTag:OTHER_ENABLE_RAGESHAKE_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_ENABLE_RAGESHAKE_INDEX]; } - [sectionOther addRowWithTag:OTHER_MARK_ALL_AS_READ_INDEX]; - [sectionOther addRowWithTag:OTHER_CLEAR_CACHE_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_MARK_ALL_AS_READ_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_CLEAR_CACHE_INDEX]; if (BuildSettings.settingsScreenAllowBugReportingManually) { - [sectionOther addRowWithTag:OTHER_REPORT_BUG_INDEX]; + [sectionAdvanced addRowWithTag:ADVANCED_REPORT_BUG_INDEX]; } - sectionOther.headerTitle = [VectorL10n settingsOther]; - [tmpSections addObject:sectionOther]; + + [tmpSections addObject:sectionAdvanced]; + + Section *sectionAbout = [Section sectionWithTag:SECTION_TAG_ABOUT]; + if (BuildSettings.applicationCopyrightUrlString.length) + { + [sectionAbout addRowWithTag:ABOUT_COPYRIGHT_INDEX]; + } + if (BuildSettings.applicationTermsConditionsUrlString.length) + { + [sectionAbout addRowWithTag:ABOUT_TERM_CONDITIONS_INDEX]; + } + if (BuildSettings.applicationPrivacyPolicyUrlString.length) + { + [sectionAbout addRowWithTag:ABOUT_PRIVACY_INDEX]; + } + [sectionAbout addRowWithTag:ABOUT_THIRD_PARTY_INDEX]; + sectionAbout.headerTitle = VectorL10n.settingsAbout; + + if (BuildSettings.settingsScreenShowAdvancedSettings) + { + sectionAbout.footerTitle = [NSString stringWithFormat:@"Element %@ / Olm %@\n%@\n%@", + AppInfo.current.appVersion.description, + [OLMKit versionString], + [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId], + [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer]]; + } + + [tmpSections addObject:sectionAbout]; if (BuildSettings.settingsScreenShowLabSettings) { @@ -1857,18 +1858,6 @@ TableViewSectionsDelegate> cell = newPhoneCell; } } - else if (row == USER_SETTINGS_INVITE_FRIENDS_INDEX) - { - MXKTableViewCell *inviteFriendsCell = [self getDefaultTableViewCell:tableView]; - - inviteFriendsCell.textLabel.text = [VectorL10n inviteFriendsAction:BuildSettings.bundleDisplayName]; - - UIImage *shareActionImage = [[UIImage imageNamed:@"share_action_button"] vc_tintedImageUsingColor:ThemeService.shared.theme.tintColor]; - UIImageView *accessoryView = [[UIImageView alloc] initWithImage:shareActionImage]; - inviteFriendsCell.accessoryView = accessoryView; - - cell = inviteFriendsCell; - } else if (row == USER_SETTINGS_CHANGE_PASSWORD_INDEX) { MXKTableViewCellWithLabelAndTextField *passwordCell = [self getLabelAndTextFieldCell:tableView forIndexPath:indexPath]; @@ -2182,79 +2171,7 @@ TableViewSectionsDelegate> } else if (section == SECTION_TAG_ADVANCED) { - MXKTableViewCellWithTextView *configCell = [self textViewCellForTableView:tableView atIndexPath:indexPath]; - - configCell.mxkTextView.text = [NSString stringWithFormat:@"%@\n%@\n%@", [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId], [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer], [MatrixKitL10n settingsConfigIdentityServer:account.identityServerURL]]; - configCell.mxkTextView.accessibilityIdentifier=@"SettingsVCConfigStaticText"; - - cell = configCell; - } - else if (section == SECTION_TAG_OTHER) - { - if (row == OTHER_VERSION_INDEX) - { - MXKTableViewCell *versionCell = [self getDefaultTableViewCell:tableView]; - - NSString* appVersion = [AppDelegate theDelegate].appVersion; - NSString* build = [AppDelegate theDelegate].build; - - versionCell.textLabel.text = [VectorL10n settingsVersion:[NSString stringWithFormat:@"%@ %@", appVersion, build]]; - - versionCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = versionCell; - } - else if (row == OTHER_OLM_VERSION_INDEX) - { - MXKTableViewCell *versionCell = [self getDefaultTableViewCell:tableView]; - - versionCell.textLabel.text = [VectorL10n settingsOlmVersion:[OLMKit versionString]]; - - versionCell.selectionStyle = UITableViewCellSelectionStyleNone; - - cell = versionCell; - } - else if (row == OTHER_TERM_CONDITIONS_INDEX) - { - MXKTableViewCell *termAndConditionCell = [self getDefaultTableViewCell:tableView]; - - termAndConditionCell.textLabel.text = [VectorL10n settingsTermConditions]; - - [termAndConditionCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; - - cell = termAndConditionCell; - } - else if (row == OTHER_COPYRIGHT_INDEX) - { - MXKTableViewCell *copyrightCell = [self getDefaultTableViewCell:tableView]; - - copyrightCell.textLabel.text = [VectorL10n settingsCopyright]; - - [copyrightCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; - - cell = copyrightCell; - } - else if (row == OTHER_PRIVACY_INDEX) - { - MXKTableViewCell *privacyPolicyCell = [self getDefaultTableViewCell:tableView]; - - privacyPolicyCell.textLabel.text = [VectorL10n settingsPrivacyPolicy]; - - [privacyPolicyCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; - - cell = privacyPolicyCell; - } - else if (row == OTHER_THIRD_PARTY_INDEX) - { - MXKTableViewCell *thirdPartyCell = [self getDefaultTableViewCell:tableView]; - - thirdPartyCell.textLabel.text = [VectorL10n settingsThirdPartyNotices]; - - [thirdPartyCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; - - cell = thirdPartyCell; - } - else if (row == OTHER_SHOW_NSFW_ROOMS_INDEX) + if (row == ADVANCED_SHOW_NSFW_ROOMS_INDEX) { MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; @@ -2267,7 +2184,7 @@ TableViewSectionsDelegate> cell = labelAndSwitchCell; } - else if (row == OTHER_CRASH_REPORT_INDEX) + else if (row == ADVANCED_CRASH_REPORT_INDEX) { MXKTableViewCellWithLabelAndSwitch* sendCrashReportCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; @@ -2279,7 +2196,7 @@ TableViewSectionsDelegate> cell = sendCrashReportCell; } - else if (row == OTHER_ENABLE_RAGESHAKE_INDEX) + else if (row == ADVANCED_ENABLE_RAGESHAKE_INDEX) { MXKTableViewCellWithLabelAndSwitch* enableRageShakeCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; @@ -2291,7 +2208,7 @@ TableViewSectionsDelegate> cell = enableRageShakeCell; } - else if (row == OTHER_MARK_ALL_AS_READ_INDEX) + else if (row == ADVANCED_MARK_ALL_AS_READ_INDEX) { MXKTableViewCellWithButton *markAllBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; if (!markAllBtnCell) @@ -2316,7 +2233,7 @@ TableViewSectionsDelegate> cell = markAllBtnCell; } - else if (row == OTHER_CLEAR_CACHE_INDEX) + else if (row == ADVANCED_CLEAR_CACHE_INDEX) { MXKTableViewCellWithButton *clearCacheBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; if (!clearCacheBtnCell) @@ -2341,7 +2258,7 @@ TableViewSectionsDelegate> cell = clearCacheBtnCell; } - else if (row == OTHER_REPORT_BUG_INDEX) + else if (row == ADVANCED_REPORT_BUG_INDEX) { MXKTableViewCellWithButton *reportBugBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; if (!reportBugBtnCell) @@ -2367,6 +2284,49 @@ TableViewSectionsDelegate> cell = reportBugBtnCell; } } + else if (section == SECTION_TAG_ABOUT) + { + if (row == ABOUT_TERM_CONDITIONS_INDEX) + { + MXKTableViewCell *termAndConditionCell = [self getDefaultTableViewCell:tableView]; + + termAndConditionCell.textLabel.text = [VectorL10n settingsTermConditions]; + + [termAndConditionCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; + + cell = termAndConditionCell; + } + else if (row == ABOUT_COPYRIGHT_INDEX) + { + MXKTableViewCell *copyrightCell = [self getDefaultTableViewCell:tableView]; + + copyrightCell.textLabel.text = [VectorL10n settingsCopyright]; + + [copyrightCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; + + cell = copyrightCell; + } + else if (row == ABOUT_PRIVACY_INDEX) + { + MXKTableViewCell *privacyPolicyCell = [self getDefaultTableViewCell:tableView]; + + privacyPolicyCell.textLabel.text = [VectorL10n settingsPrivacyPolicy]; + + [privacyPolicyCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; + + cell = privacyPolicyCell; + } + else if (row == ABOUT_THIRD_PARTY_INDEX) + { + MXKTableViewCell *thirdPartyCell = [self getDefaultTableViewCell:tableView]; + + thirdPartyCell.textLabel.text = [VectorL10n settingsThirdPartyNotices]; + + [thirdPartyCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; + + cell = thirdPartyCell; + } + } else if (section == SECTION_TAG_LABS) { if (row == LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX) @@ -2595,11 +2555,6 @@ TableViewSectionsDelegate> [self showThemePicker]; } } - else if (section == SECTION_TAG_USER_SETTINGS && row == USER_SETTINGS_INVITE_FRIENDS_INDEX) - { - UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; - [self showInviteFriendsFromSourceView:selectedCell]; - } else if (section == SECTION_TAG_NOTIFICATIONS && row == NOTIFICATION_SETTINGS_SYSTEM_SETTINGS) { [self openSystemSettingsApp]; @@ -2678,9 +2633,9 @@ TableViewSectionsDelegate> [self presentViewController:currentAlert animated:YES completion:nil]; } } - else if (section == SECTION_TAG_OTHER) + else if (section == SECTION_TAG_ABOUT) { - if (row == OTHER_COPYRIGHT_INDEX) + if (row == ABOUT_COPYRIGHT_INDEX) { WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:BuildSettings.applicationCopyrightUrlString]; @@ -2688,7 +2643,7 @@ TableViewSectionsDelegate> [self pushViewController:webViewViewController]; } - else if (row == OTHER_TERM_CONDITIONS_INDEX) + else if (row == ABOUT_TERM_CONDITIONS_INDEX) { WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:BuildSettings.applicationTermsConditionsUrlString]; @@ -2696,7 +2651,7 @@ TableViewSectionsDelegate> [self pushViewController:webViewViewController]; } - else if (row == OTHER_PRIVACY_INDEX) + else if (row == ABOUT_PRIVACY_INDEX) { WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:BuildSettings.applicationPrivacyPolicyUrlString]; @@ -2704,7 +2659,7 @@ TableViewSectionsDelegate> [self pushViewController:webViewViewController]; } - else if (row == OTHER_THIRD_PARTY_INDEX) + else if (row == ABOUT_THIRD_PARTY_INDEX) { NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"third_party_licenses" ofType:@"html" inDirectory:nil]; @@ -3819,21 +3774,6 @@ TableViewSectionsDelegate> self.deactivateAccountViewController = deactivateAccountViewController; } -- (void)showInviteFriendsFromSourceView:(UIView*)sourceView -{ - if (!self.inviteFriendsPresenter) - { - self.inviteFriendsPresenter = [InviteFriendsPresenter new]; - } - - NSString *userId = self.mainSession.myUser.userId; - - [self.inviteFriendsPresenter presentFor:userId - from:self - sourceView:sourceView - animated:YES]; -} - - (void)toggleNSFWPublicRoomsFiltering:(UISwitch *)sender { RiotSettings.shared.showNSFWPublicRooms = sender.isOn; diff --git a/changelog.d/pr-5011.change b/changelog.d/pr-5011.change new file mode 100644 index 000000000..3dfc602c1 --- /dev/null +++ b/changelog.d/pr-5011.change @@ -0,0 +1 @@ +Settings: Refresh the appearance of headers and footers, with a few minor tweaks to the organisation. \ No newline at end of file From 86869d5fdc60a545832db3c530529e6ece5b5756 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 20 Oct 2021 09:58:30 +0100 Subject: [PATCH 6/8] Fix bug accepting identity server terms from the Setting Discovery section. --- .../SettingsDiscoveryViewModel.swift | 28 +---- .../SettingsDiscoveryViewModelType.swift | 1 + .../Modules/Settings/SettingsViewController.m | 104 +++++++++++------- 3 files changed, 68 insertions(+), 65 deletions(-) diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift index 8eba596c0..c0e3749a7 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModel.swift @@ -54,11 +54,11 @@ import Foundation func process(viewAction: SettingsDiscoveryViewAction) { switch viewAction { case .load: - self.checkTerms() + checkTerms() case .acceptTerms: - self.acceptTerms() + coordinatorDelegate?.settingsDiscoveryViewModelDidTapAcceptIdentityServerTerms(self) case .select(threePid: let threePid): - self.coordinatorDelegate?.settingsDiscoveryViewModel(self, didSelectThreePidWith: threePid.medium.identifier, and: threePid.address) + coordinatorDelegate?.settingsDiscoveryViewModel(self, didSelectThreePidWith: threePid.medium.identifier, and: threePid.address) } } @@ -114,28 +114,6 @@ import Foundation }) } - private func acceptTerms() { - guard let identityService = self.identityService else { - self.update(viewState: .loaded(displayMode: .noIdentityServer)) - return - } - - // Launch an identity server request to trigger terms modal apparition - identityService.account { (response) in - switch response { - case .success: - // Display three pids if presents - self.updateViewStateFromCurrentThreePids() - case .failure(let error): - if MXError(nsError: error)?.errcode == kMXErrCodeStringTermsNotSigned { - // Identity terms modal should appear - } else { - self.update(viewState: .error(error)) - } - } - } - } - private func canCheckTerms() -> Bool { guard let viewState = self.viewState else { return true diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift index 5acfdfad2..8dfbbec34 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryViewModelType.swift @@ -22,6 +22,7 @@ protocol SettingsDiscoveryViewModelViewDelegate: AnyObject { @objc protocol SettingsDiscoveryViewModelCoordinatorDelegate: AnyObject { func settingsDiscoveryViewModel(_ viewModel: SettingsDiscoveryViewModel, didSelectThreePidWith medium: String, and address: String) + func settingsDiscoveryViewModelDidTapAcceptIdentityServerTerms(_ viewModel: SettingsDiscoveryViewModel) } protocol SettingsDiscoveryViewModelType { diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index d51807d30..758b151b8 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -274,6 +274,11 @@ TableViewSectionsDelegate> @property (nonatomic, strong) UserInteractiveAuthenticationService *userInteractiveAuthenticationService; +/** + Whether or not to check for contacts access after the user accepts the service terms. The value of this property is + set automatically when calling `prepareIdentityServiceAndPresentTermsWithSession:checkingAccessForContactsOnAccept` +*/ +@property (nonatomic) BOOL serviceTermsModalShouldCheckAccessForContactsOnAccept; @property (nonatomic, strong) ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter; @end @@ -3017,37 +3022,7 @@ TableViewSectionsDelegate> } else { - MXWeakify(self); - - // The preparation can take some time so indicate this to the user - [self startActivityIndicator]; - - [session prepareIdentityServiceForTermsWithDefault:RiotSettings.shared.identityServerUrlString - success:^(MXSession *session, NSString *baseURL, NSString *accessToken) { - MXStrongifyAndReturnIfNil(self); - - [self stopActivityIndicator]; - - // Present the terms of the identity server. - [self presentIdentityServerTermsWithSession:session baseURL:baseURL andAccessToken:accessToken]; - } failure:^(NSError *error) { - MXStrongifyAndReturnIfNil(self); - - [self stopActivityIndicator]; - - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:VectorL10n.findYourContactsIdentityServiceError - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - - [alertController addAction:[UIAlertAction actionWithTitle:MatrixKitL10n.ok - style:UIAlertActionStyleDefault - handler:nil]]; - - [self presentViewController:alertController animated:YES completion:nil]; - - [MXKAppSettings standardAppSettings].syncLocalContacts = NO; - [self updateSections]; - }]; + [self prepareIdentityServiceAndPresentTermsWithSession:session checkingAccessForContactsOnAccept:YES]; } } else @@ -4372,6 +4347,15 @@ TableViewSectionsDelegate> self.discoveryThreePidDetailsPresenter = discoveryThreePidDetailsPresenter; } +- (void)settingsDiscoveryViewModelDidTapAcceptIdentityServerTerms:(SettingsDiscoveryViewModel *)viewModel +{ + MXSession *session = self.mainSession; + if (!session.identityService.areAllTermsAgreed) + { + [self prepareIdentityServiceAndPresentTermsWithSession:session checkingAccessForContactsOnAccept:NO]; + } +} + #pragma mark - Local Contacts Sync - (void)checkAccessForContacts @@ -4405,6 +4389,44 @@ TableViewSectionsDelegate> identityServerSettingsCoordinatorBridgePresenter.delegate = self; } +- (void)prepareIdentityServiceAndPresentTermsWithSession:(MXSession *)session + checkingAccessForContactsOnAccept:(BOOL)checkAccessForContacts +{ + self.serviceTermsModalShouldCheckAccessForContactsOnAccept = checkAccessForContacts; + + MXWeakify(self); + + // The preparation can take some time so indicate this to the user + [self startActivityIndicator]; + + [session prepareIdentityServiceForTermsWithDefault:RiotSettings.shared.identityServerUrlString + success:^(MXSession *session, NSString *baseURL, NSString *accessToken) { + MXStrongifyAndReturnIfNil(self); + + [self stopActivityIndicator]; + + // Present the terms of the identity server. + [self presentIdentityServerTermsWithSession:session baseURL:baseURL andAccessToken:accessToken]; + } failure:^(NSError *error) { + MXStrongifyAndReturnIfNil(self); + + [self stopActivityIndicator]; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:VectorL10n.findYourContactsIdentityServiceError + message:nil + preferredStyle:UIAlertControllerStyleAlert]; + + [alertController addAction:[UIAlertAction actionWithTitle:MatrixKitL10n.ok + style:UIAlertActionStyleDefault + handler:nil]]; + + [self presentViewController:alertController animated:YES completion:nil]; + + [MXKAppSettings standardAppSettings].syncLocalContacts = NO; + [self updateSections]; + }]; +} + - (void)presentIdentityServerTermsWithSession:(MXSession*)mxSession baseURL:(NSString*)baseURL andAccessToken:(NSString*)accessToken { if (!mxSession || !baseURL || !accessToken || self.serviceTermsModalCoordinatorBridgePresenter.isPresenting) @@ -4412,15 +4434,13 @@ TableViewSectionsDelegate> return; } - ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter = [[ServiceTermsModalCoordinatorBridgePresenter alloc] initWithSession:mxSession - baseUrl:baseURL - serviceType:MXServiceTypeIdentityService - accessToken:accessToken]; + self.serviceTermsModalCoordinatorBridgePresenter = [[ServiceTermsModalCoordinatorBridgePresenter alloc] initWithSession:mxSession + baseUrl:baseURL + serviceType:MXServiceTypeIdentityService + accessToken:accessToken]; - serviceTermsModalCoordinatorBridgePresenter.delegate = self; - - [serviceTermsModalCoordinatorBridgePresenter presentFrom:self animated:YES]; - self.serviceTermsModalCoordinatorBridgePresenter = serviceTermsModalCoordinatorBridgePresenter; + self.serviceTermsModalCoordinatorBridgePresenter.delegate = self; + [self.serviceTermsModalCoordinatorBridgePresenter presentFrom:self animated:YES]; } #pragma mark SettingsIdentityServerCoordinatorBridgePresenterDelegate @@ -4436,7 +4456,11 @@ TableViewSectionsDelegate> - (void)serviceTermsModalCoordinatorBridgePresenterDelegateDidAccept:(ServiceTermsModalCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter { [coordinatorBridgePresenter dismissWithAnimated:YES completion:^{ - [self checkAccessForContacts]; + [self.settingsDiscoveryTableViewSection reload]; + if (self.serviceTermsModalShouldCheckAccessForContactsOnAccept) + { + [self checkAccessForContacts]; + } }]; self.serviceTermsModalCoordinatorBridgePresenter = nil; } From 987c39b93c30b479f3657e747880a83ed56e0145 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 20 Oct 2021 13:11:10 +0100 Subject: [PATCH 7/8] Add SectionFooterView.xib to fix fonts on iOS 12-14. Update SecurityViewController too. --- .../SectionFooters/SectionFooterView.swift | 38 +++++++++++++++--- .../SectionFooters/SectionFooterView.xib | 40 +++++++++++++++++++ .../Security/SecurityViewController.m | 17 +------- .../Modules/Settings/SettingsViewController.m | 3 +- Riot/Modules/Spaces/BetaAnnounceCell.swift | 2 +- 5 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 Riot/Modules/Common/SectionFooters/SectionFooterView.xib diff --git a/Riot/Modules/Common/SectionFooters/SectionFooterView.swift b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift index 394207b74..21ac03c7a 100644 --- a/Riot/Modules/Common/SectionFooters/SectionFooterView.swift +++ b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift @@ -15,16 +15,44 @@ // import UIKit +import Reusable -/// A subclass of `UITableViewHeaderFooterView` that conforms `Themable` +/// A subclass of `UITableViewHeaderFooterView` that conforms to `Themable` /// to create a consistent looking custom footer inside of the app. If using gesture /// recognizers on the view, be aware that these will be automatically removed on reuse. @objcMembers -class SectionFooterView: UITableViewHeaderFooterView, Themable { +class SectionFooterView: UITableViewHeaderFooterView, NibLoadable, Themable { + + // MARK: - Properties + static var defaultReuseIdentifier: String { String(describing: Self.self) } + static var nib: UINib { + // Copy paste from NibReusable in order to expose to ObjC + UINib(nibName: String(describing: self), bundle: Bundle(for: self)) + } + + var leadingInset: CGFloat { + get { footerLabelLeadingConstraint.constant } + set { footerLabelLeadingConstraint.constant = newValue } + } + + // Expose `footerLabel` as the default label property. + override var textLabel: UILabel? { + footerLabel + } + + /// The text label added in the xib file. Using our own label was necessary due to the behaviour + /// on iOS 12-14 where any customisation to the text label would be wiped out after being set + /// in `tableView:viewForFooterInSection`. This behaviour is fixed in iOS 15. + @IBOutlet private weak var footerLabel: UILabel! + /// The label's leading constraint, relative to the safe area insets. + @IBOutlet private weak var footerLabelLeadingConstraint: NSLayoutConstraint! + + // MARK: - Public + override func prepareForReuse() { super.prepareForReuse() @@ -34,8 +62,8 @@ class SectionFooterView: UITableViewHeaderFooterView, Themable { } func update(theme: Theme) { - textLabel?.textColor = theme.colors.secondaryContent - textLabel?.font = theme.fonts.subheadline - textLabel?.numberOfLines = 0 + footerLabel.textColor = theme.colors.secondaryContent + footerLabel.font = theme.fonts.subheadline + footerLabel.numberOfLines = 0 } } diff --git a/Riot/Modules/Common/SectionFooters/SectionFooterView.xib b/Riot/Modules/Common/SectionFooters/SectionFooterView.xib new file mode 100644 index 000000000..1dbf29848 --- /dev/null +++ b/Riot/Modules/Common/SectionFooters/SectionFooterView.xib @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index 1f8adbf4c..5e479e534 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -159,7 +159,7 @@ TableViewSectionsDelegate> [self.tableView registerClass:MXKTableViewCellWithLabelAndSwitch.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithTextView.nib forCellReuseIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithButton.nib forCellReuseIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; - [self.tableView registerClass:SectionFooterView.class forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; + [self.tableView registerNib:SectionFooterView.nib forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; // Enable self sizing cells and footers self.tableView.rowHeight = UITableViewAutomaticDimension; @@ -1313,6 +1313,7 @@ TableViewSectionsDelegate> SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; [view updateWithTheme:ThemeService.shared.theme]; + view.leadingInset = tableView.vc_separatorInset.left; view.textLabel.text = footerTitle; return view; @@ -1346,20 +1347,6 @@ TableViewSectionsDelegate> } } -//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section -//{ -// if (section == SECTION_CRYPTO_SESSIONS) -// { -// return 44; -// } -// return 24; -//} -// -//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -//{ -// return 24; -//} - - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (self.tableView == tableView) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 758b151b8..458eb48da 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -602,7 +602,7 @@ TableViewSectionsDelegate> [self.tableView registerClass:TableViewCellWithPhoneNumberTextField.class forCellReuseIdentifier:[TableViewCellWithPhoneNumberTextField defaultReuseIdentifier]]; [self.tableView registerClass:GroupTableViewCellWithSwitch.class forCellReuseIdentifier:[GroupTableViewCellWithSwitch defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithTextView.nib forCellReuseIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; - [self.tableView registerClass:SectionFooterView.class forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; + [self.tableView registerNib:SectionFooterView.nib forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; // Enable self sizing cells and footers self.tableView.rowHeight = UITableViewAutomaticDimension; @@ -2442,6 +2442,7 @@ TableViewSectionsDelegate> SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; [view updateWithTheme:ThemeService.shared.theme]; + view.leadingInset = tableView.vc_separatorInset.left; view.textLabel.attributedText = attributedFooterTitle; if (section == SECTION_TAG_USER_SETTINGS) diff --git a/Riot/Modules/Spaces/BetaAnnounceCell.swift b/Riot/Modules/Spaces/BetaAnnounceCell.swift index 9897c9417..08485e91a 100644 --- a/Riot/Modules/Spaces/BetaAnnounceCell.swift +++ b/Riot/Modules/Spaces/BetaAnnounceCell.swift @@ -82,7 +82,7 @@ final class BetaAnnounceCell: UITableViewCell, Themable { } } -// Copy past from NibReusable in order to expose these methods to ObjC +// Copy paste from NibReusable in order to expose these methods to ObjC extension BetaAnnounceCell { @objc static var reuseIdentifier: String { return String(describing: self) From a2eea97690be77754d4bf968f87ca5f17726e1fb Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 20 Oct 2021 19:29:23 +0100 Subject: [PATCH 8/8] Address Steve's comments. --- Riot/Managers/AppInfo/AppVersion.swift | 2 +- Riot/Modules/Common/Models/Section.swift | 15 +++++++++++- .../SectionFooters/SectionFooterView.swift | 21 ++++++++++------ .../SettingsDiscoveryTableViewSection.swift | 6 ++--- .../Security/SecurityViewController.m | 2 +- .../Modules/Settings/SettingsViewController.m | 24 +++++++++++++++---- 6 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Riot/Managers/AppInfo/AppVersion.swift b/Riot/Managers/AppInfo/AppVersion.swift index dc75e5994..ff7e25080 100644 --- a/Riot/Managers/AppInfo/AppVersion.swift +++ b/Riot/Managers/AppInfo/AppVersion.swift @@ -96,7 +96,7 @@ final class AppVersion: NSObject { } override var description: String { - return "\(bundleShortVersion) (\(bundleVersion))" + return "\(bundleShortVersion)(\(bundleVersion))" } // MARK: - Private diff --git a/Riot/Modules/Common/Models/Section.swift b/Riot/Modules/Common/Models/Section.swift index c9cae8131..8b7131208 100644 --- a/Riot/Modules/Common/Models/Section.swift +++ b/Riot/Modules/Common/Models/Section.swift @@ -21,9 +21,22 @@ final class Section: NSObject { let tag: Int var rows: [Row] - var headerTitle: String? + var attributedHeaderTitle: NSAttributedString? var attributedFooterTitle: NSAttributedString? + var headerTitle: String? { + get { + attributedHeaderTitle?.string + } + set { + guard let newValue = newValue else { + attributedHeaderTitle = nil + return + } + + attributedHeaderTitle = NSAttributedString(string: newValue) + } + } var footerTitle: String? { get { attributedFooterTitle?.string diff --git a/Riot/Modules/Common/SectionFooters/SectionFooterView.swift b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift index 21ac03c7a..92c36e88c 100644 --- a/Riot/Modules/Common/SectionFooters/SectionFooterView.swift +++ b/Riot/Modules/Common/SectionFooters/SectionFooterView.swift @@ -34,19 +34,15 @@ class SectionFooterView: UITableViewHeaderFooterView, NibLoadable, Themable { UINib(nibName: String(describing: self), bundle: Bundle(for: self)) } + /// The amount to inset the footer label on its leading side, relative to the safe area insets. var leadingInset: CGFloat { get { footerLabelLeadingConstraint.constant } set { footerLabelLeadingConstraint.constant = newValue } } - // Expose `footerLabel` as the default label property. - override var textLabel: UILabel? { - footerLabel - } - /// The text label added in the xib file. Using our own label was necessary due to the behaviour - /// on iOS 12-14 where any customisation to the text label would be wiped out after being set - /// in `tableView:viewForFooterInSection`. This behaviour is fixed in iOS 15. + /// on iOS 12-14 where any customisation to the existing text label is wiped out after being + /// set in `tableView:viewForFooterInSection`. This behaviour is fixed in iOS 15. @IBOutlet private weak var footerLabel: UILabel! /// The label's leading constraint, relative to the safe area insets. @IBOutlet private weak var footerLabelLeadingConstraint: NSLayoutConstraint! @@ -66,4 +62,15 @@ class SectionFooterView: UITableViewHeaderFooterView, NibLoadable, Themable { footerLabel.font = theme.fonts.subheadline footerLabel.numberOfLines = 0 } + + /// Update the footer with new text. + func update(withText text: String) { + footerLabel.text = text + } + + /// Update the footer with attributed text. Be sure to call this after calling `update(theme:)` + /// otherwise any color or font attributes will be wiped out by the theme. + func update(withAttributedText attributedText: NSAttributedString) { + footerLabel.attributedText = attributedText + } } diff --git a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift index 187f53c8c..64e96878f 100644 --- a/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift +++ b/Riot/Modules/Settings/Discovery/SettingsDiscoveryTableViewSection.swift @@ -216,12 +216,10 @@ private enum DiscoverySectionRows { } private func threePidsManagementInfoAttributedString() -> NSAttributedString { - let attributedInfoString = NSMutableAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart1, - attributes: [:]) + let attributedInfoString = NSMutableAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart1) attributedInfoString.append(NSAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart2, attributes: [.foregroundColor: self.theme.tintColor])) - attributedInfoString.append(NSAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart3, - attributes: [:])) + attributedInfoString.append(NSAttributedString(string: VectorL10n.settingsDiscoveryThreePidsManagementInformationPart3)) return attributedInfoString } } diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index 5e479e534..fce6d5c9b 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -1314,7 +1314,7 @@ TableViewSectionsDelegate> SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; [view updateWithTheme:ThemeService.shared.theme]; view.leadingInset = tableView.vc_separatorInset.left; - view.textLabel.text = footerTitle; + [view updateWithText:footerTitle]; return view; } diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 458eb48da..0a5acf57c 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -279,6 +279,7 @@ TableViewSectionsDelegate> set automatically when calling `prepareIdentityServiceAndPresentTermsWithSession:checkingAccessForContactsOnAccept` */ @property (nonatomic) BOOL serviceTermsModalShouldCheckAccessForContactsOnAccept; +@property (nonatomic) BOOL isPreparingIdentityService; @property (nonatomic, strong) ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter; @end @@ -541,8 +542,9 @@ TableViewSectionsDelegate> if (BuildSettings.settingsScreenShowAdvancedSettings) { - sectionAbout.footerTitle = [NSString stringWithFormat:@"Element %@ / Olm %@\n%@\n%@", - AppInfo.current.appVersion.description, + sectionAbout.footerTitle = [NSString stringWithFormat:@"Element %@ (%@) / Olm %@\n%@\n%@", + AppInfo.current.appVersion.bundleShortVersion, + AppInfo.current.appVersion.bundleVersion, [OLMKit versionString], [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId], [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer]]; @@ -2443,7 +2445,7 @@ TableViewSectionsDelegate> SectionFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionFooterView.defaultReuseIdentifier]; [view updateWithTheme:ThemeService.shared.theme]; view.leadingInset = tableView.vc_separatorInset.left; - view.textLabel.attributedText = attributedFooterTitle; + [view updateWithAttributedText:attributedFooterTitle]; if (section == SECTION_TAG_USER_SETTINGS) { @@ -4393,6 +4395,12 @@ TableViewSectionsDelegate> - (void)prepareIdentityServiceAndPresentTermsWithSession:(MXSession *)session checkingAccessForContactsOnAccept:(BOOL)checkAccessForContacts { + if (self.isPreparingIdentityService) + { + return; + } + + self.isPreparingIdentityService = YES; self.serviceTermsModalShouldCheckAccessForContactsOnAccept = checkAccessForContacts; MXWeakify(self); @@ -4405,6 +4413,7 @@ TableViewSectionsDelegate> MXStrongifyAndReturnIfNil(self); [self stopActivityIndicator]; + self.isPreparingIdentityService = NO; // Present the terms of the identity server. [self presentIdentityServerTermsWithSession:session baseURL:baseURL andAccessToken:accessToken]; @@ -4412,6 +4421,7 @@ TableViewSectionsDelegate> MXStrongifyAndReturnIfNil(self); [self stopActivityIndicator]; + self.isPreparingIdentityService = NO; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:VectorL10n.findYourContactsIdentityServiceError message:nil @@ -4468,8 +4478,9 @@ TableViewSectionsDelegate> - (void)serviceTermsModalCoordinatorBridgePresenterDelegateDidDecline:(ServiceTermsModalCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter session:(MXSession *)session { - // Disable the contacts toggle as the terms weren't accepted. + // Terms weren't accepted: disable contacts toggle and refresh discovery [self updateSections]; + [self.settingsDiscoveryTableViewSection reload]; [coordinatorBridgePresenter dismissWithAnimated:YES completion:nil]; self.serviceTermsModalCoordinatorBridgePresenter = nil; @@ -4477,7 +4488,10 @@ TableViewSectionsDelegate> - (void)serviceTermsModalCoordinatorBridgePresenterDelegateDidClose:(ServiceTermsModalCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter { - [self updateSections]; // Disables the contacts toggle as the terms weren't accepted. + // Terms weren't accepted: disable contacts toggle and refresh discovery + [self updateSections]; + [self.settingsDiscoveryTableViewSection reload]; + self.serviceTermsModalCoordinatorBridgePresenter = nil; }