diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index 3c6cba965..1502232c2 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -135,7 +135,7 @@ 92726A4B1F58737A004AD26F /* SiriIntents.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 92726A431F58737A004AD26F /* SiriIntents.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 92726A511F587410004AD26F /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92726A501F587410004AD26F /* Intents.framework */; }; 933A7148CE5984940344006C /* Pods_RiotPods_RiotShareExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97151D7F0F892081250D50A3 /* Pods_RiotPods_RiotShareExtension.framework */; }; - B104C2942203773C00D9F496 /* KeyBackupBannerPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = B104C2932203773B00D9F496 /* KeyBackupBannerPreferences.swift */; }; + B104C2942203773C00D9F496 /* SecureBackupBannerPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = B104C2932203773B00D9F496 /* SecureBackupBannerPreferences.swift */; }; B1057789221304EC00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1057788221304EB00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.swift */; }; B105778B221304FA00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B105778A221304FA00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.storyboard */; }; B105778D2213051E00334B1E /* KeyBackupSetupSuccessFromRecoveryKeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B105778C2213051E00334B1E /* KeyBackupSetupSuccessFromRecoveryKeyViewController.swift */; }; @@ -167,8 +167,8 @@ B1098C1021ED07E4000DDA48 /* Presentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1098C0B21ED07E4000DDA48 /* Presentable.swift */; }; B1098C1121ED07E4000DDA48 /* NavigationRouterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1098C0C21ED07E4000DDA48 /* NavigationRouterType.swift */; }; B109D6F1222D8C400061B6D9 /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = B109D6F0222D8C400061B6D9 /* UIApplication.swift */; }; - B10B3B5B2201DD740072C76B /* KeyBackupBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10B3B592201DD740072C76B /* KeyBackupBannerCell.swift */; }; - B10B3B5C2201DD740072C76B /* KeyBackupBannerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B10B3B5A2201DD740072C76B /* KeyBackupBannerCell.xib */; }; + B10B3B5B2201DD740072C76B /* SecureBackupBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10B3B592201DD740072C76B /* SecureBackupBannerCell.swift */; }; + B10B3B5C2201DD740072C76B /* SecureBackupBannerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B10B3B5A2201DD740072C76B /* SecureBackupBannerCell.xib */; }; B10CFBC32268D99D00A5842E /* JitsiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10CFBC22268D99D00A5842E /* JitsiService.swift */; }; B1107EC82200B0720038014B /* KeyBackupRecoverSuccessViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1107EC72200B0720038014B /* KeyBackupRecoverSuccessViewController.swift */; }; B1107ECA2200B09F0038014B /* KeyBackupRecoverSuccessViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B1107EC92200B09F0038014B /* KeyBackupRecoverSuccessViewController.storyboard */; }; @@ -985,7 +985,7 @@ 97151D7F0F892081250D50A3 /* Pods_RiotPods_RiotShareExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RiotPods_RiotShareExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9C3242E3FE95BCDA9562C75D /* Pods-RiotPods-RiotShareExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotPods-RiotShareExtension.debug.xcconfig"; path = "Target Support Files/Pods-RiotPods-RiotShareExtension/Pods-RiotPods-RiotShareExtension.debug.xcconfig"; sourceTree = ""; }; AC34BF67FD21A9D01C16AE5D /* Pods-RiotTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotTests.release.xcconfig"; path = "Target Support Files/Pods-RiotTests/Pods-RiotTests.release.xcconfig"; sourceTree = ""; }; - B104C2932203773B00D9F496 /* KeyBackupBannerPreferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyBackupBannerPreferences.swift; sourceTree = ""; }; + B104C2932203773B00D9F496 /* SecureBackupBannerPreferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecureBackupBannerPreferences.swift; sourceTree = ""; }; B1057788221304EB00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupSetupSuccessFromPassphraseViewController.swift; sourceTree = ""; }; B105778A221304FA00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = KeyBackupSetupSuccessFromPassphraseViewController.storyboard; sourceTree = ""; }; B105778C2213051E00334B1E /* KeyBackupSetupSuccessFromRecoveryKeyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupSetupSuccessFromRecoveryKeyViewController.swift; sourceTree = ""; }; @@ -1017,8 +1017,8 @@ B1098C0B21ED07E4000DDA48 /* Presentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Presentable.swift; sourceTree = ""; }; B1098C0C21ED07E4000DDA48 /* NavigationRouterType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationRouterType.swift; sourceTree = ""; }; B109D6F0222D8C400061B6D9 /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = ""; }; - B10B3B592201DD740072C76B /* KeyBackupBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupBannerCell.swift; sourceTree = ""; }; - B10B3B5A2201DD740072C76B /* KeyBackupBannerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KeyBackupBannerCell.xib; sourceTree = ""; }; + B10B3B592201DD740072C76B /* SecureBackupBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupBannerCell.swift; sourceTree = ""; }; + B10B3B5A2201DD740072C76B /* SecureBackupBannerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecureBackupBannerCell.xib; sourceTree = ""; }; B10CFBC22268D99D00A5842E /* JitsiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JitsiService.swift; sourceTree = ""; }; B1107EC72200B0720038014B /* KeyBackupRecoverSuccessViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupRecoverSuccessViewController.swift; sourceTree = ""; }; B1107EC92200B09F0038014B /* KeyBackupRecoverSuccessViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = KeyBackupRecoverSuccessViewController.storyboard; sourceTree = ""; }; @@ -2299,10 +2299,8 @@ B1098BE921ECFE64000DDA48 /* KeyBackup */ = { isa = PBXGroup; children = ( - B1DE85E3249A51F7006454AF /* SecureSetup */, B1098C0221ECFEAF000DDA48 /* Setup */, B1FDF56421F726AD00BA3834 /* Recover */, - B1107ECB2201BE800038014B /* Banners */, B1CE9F042216FB09000FAE6A /* ManualExport */, ); path = KeyBackup; @@ -2369,9 +2367,9 @@ B1107ECB2201BE800038014B /* Banners */ = { isa = PBXGroup; children = ( - B104C2932203773B00D9F496 /* KeyBackupBannerPreferences.swift */, - B10B3B592201DD740072C76B /* KeyBackupBannerCell.swift */, - B10B3B5A2201DD740072C76B /* KeyBackupBannerCell.xib */, + B104C2932203773B00D9F496 /* SecureBackupBannerPreferences.swift */, + B10B3B592201DD740072C76B /* SecureBackupBannerCell.swift */, + B10B3B5A2201DD740072C76B /* SecureBackupBannerCell.xib */, ); path = Banners; sourceTree = ""; @@ -2463,6 +2461,15 @@ path = RecoveryKey; sourceTree = ""; }; + B1520C6C24A60ACD006F102F /* SecureBackup */ = { + isa = PBXGroup; + children = ( + B1DE85E3249A51F7006454AF /* Setup */, + B1107ECB2201BE800038014B /* Banners */, + ); + path = SecureBackup; + sourceTree = ""; + }; B152C72922DCEA670041315A /* EmojiPicker */ = { isa = PBXGroup; children = ( @@ -3037,6 +3044,7 @@ B1B5596B20EFA85C00210D55 /* EncryptionInfo */, B1B556FD20EE6C4C00210D55 /* RoomKeyRequest */, B1B556B020EE6C4C00210D55 /* BugReport */, + B1520C6C24A60ACD006F102F /* SecureBackup */, B1098BE921ECFE64000DDA48 /* KeyBackup */, B1550FCF242148FA00CE097B /* KeyVerification */, B19C4E6A248E98B9009A423F /* Secrets */, @@ -4387,7 +4395,7 @@ path = RecoveryKey; sourceTree = ""; }; - B1DE85E3249A51F7006454AF /* SecureSetup */ = { + B1DE85E3249A51F7006454AF /* Setup */ = { isa = PBXGroup; children = ( B1DE85E6249A5732006454AF /* SecureKeyBackupSetupCoordinatorBridgePresenter.swift */, @@ -4395,7 +4403,7 @@ B1DE85E5249A5732006454AF /* SecureKeyBackupSetupCoordinator.swift */, B1DE85EA249A5737006454AF /* Intro */, ); - path = SecureSetup; + path = Setup; sourceTree = ""; }; B1DE85EA249A5737006454AF /* Intro */ = { @@ -4995,7 +5003,7 @@ 3284A35120A07C210044F922 /* postMessageAPI.js in Resources */, B1B557A220EF58AD00210D55 /* ContactTableViewCell.xib in Resources */, B1B558EB20EF768F00210D55 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib in Resources */, - B10B3B5C2201DD740072C76B /* KeyBackupBannerCell.xib in Resources */, + B10B3B5C2201DD740072C76B /* SecureBackupBannerCell.xib in Resources */, B1C543A6239E999700DCA1FA /* KeyVerificationCellInnerContentView.xib in Resources */, 32891D76226728EF00C82226 /* KeyVerificationDataLoadingViewController.storyboard in Resources */, B1B5581820EF625800210D55 /* PreviewRoomTitleView.xib in Resources */, @@ -5544,7 +5552,7 @@ B1B5577120EE702800210D55 /* StickerPickerViewController.m in Sources */, 32FDC1CD2386CD390084717A /* RiotSettingIntegrationProvisioning.swift in Sources */, B1BEE73523DF44A60003A4CB /* UserVerificationSessionsStatusViewModel.swift in Sources */, - B104C2942203773C00D9F496 /* KeyBackupBannerPreferences.swift in Sources */, + B104C2942203773C00D9F496 /* SecureBackupBannerPreferences.swift in Sources */, B1B5572020EE6C4D00210D55 /* ContactsTableViewController.m in Sources */, B1B5581920EF625800210D55 /* RoomTitleView.m in Sources */, B1098BE321ECE09F000DDA48 /* RiotDefaults.swift in Sources */, @@ -5563,7 +5571,7 @@ B1A6C10723881EF2002882FD /* SlidingModalPresenter.swift in Sources */, B1B5573520EE6C4D00210D55 /* GroupDetailsViewController.m in Sources */, B12D7A0223E2462200FACEDC /* UserVerificationStartViewAction.swift in Sources */, - B10B3B5B2201DD740072C76B /* KeyBackupBannerCell.swift in Sources */, + B10B3B5B2201DD740072C76B /* SecureBackupBannerCell.swift in Sources */, B1DCC61A22E5E17100625807 /* EmojiPickerViewController.swift in Sources */, B1963B32228F1C6B00CBA17F /* BubbleReactionsViewModelType.swift in Sources */, 32A6001722C661100042C1D9 /* EditHistoryViewController.swift in Sources */, diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 1d020f38c..c4844a55c 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -2291,7 +2291,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [MXMediaManager clearCache]; // Reset key backup banner preferences - [KeyBackupBannerPreferences.shared reset]; + [SecureBackupBannerPreferences.shared reset]; #ifdef MX_CALL_STACK_ENDPOINT // Erase all created certificates and private keys by MXEndpointCallStack diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.h b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.h index 364cc4f5d..5304c62b3 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.h +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.h @@ -38,8 +38,7 @@ typedef enum : NSUInteger typedef NS_ENUM(NSInteger, SecureBackupBannerDisplay) { SecureBackupBannerDisplayNone, - SecureBackupBannerDisplaySetup, - SecureBackupBannerDisplayRecover + SecureBackupBannerDisplaySetup }; /** diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index 4d16d7cb5..6105687a5 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -43,7 +43,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSourceTapOnDirectoryServerChange"; -@interface RecentsDataSource() +@interface RecentsDataSource() { NSMutableArray* invitesCellDataArray; NSMutableArray* favoriteCellDataArray; @@ -130,7 +130,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou [self unregisterKeyBackupStateDidChangeNotification]; } - [self updateSecureKeyBackupBanner]; + [self updateSecureBackupBanner]; [self forceRefresh]; } @@ -169,55 +169,46 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)keyBackupStateDidChangeNotification:(NSNotification*)notification { - if ([self updateSecureKeyBackupBanner]) + if ([self updateSecureBackupBanner]) { [self forceRefresh]; } } -- (BOOL)updateSecureKeyBackupBanner +- (BOOL)updateSecureBackupBanner { - SecureBackupBannerDisplay keyBackupBanner = SecureBackupBannerDisplayNone; + SecureBackupBannerDisplay secureBackupBanner = SecureBackupBannerDisplayNone; if (self.recentsDataSourceMode == RecentsDataSourceModeHome) { - KeyBackupBannerPreferences *keyBackupBannersPreferences = KeyBackupBannerPreferences.shared; + SecureBackupBannerPreferences *secureBackupBannersPreferences = SecureBackupBannerPreferences.shared; - if (!keyBackupBannersPreferences.hideSetupBanner && [self.mxSession vc_canSetupSecureKeyBackup]) + if (!secureBackupBannersPreferences.hideSetupBanner && [self.mxSession vc_canSetupSecureKeyBackup]) { - keyBackupBanner = SecureBackupBannerDisplaySetup; + secureBackupBanner = SecureBackupBannerDisplaySetup; } } - BOOL updated = (self.secureBackupBannerDisplay != keyBackupBanner); + BOOL updated = (self.secureBackupBannerDisplay != secureBackupBanner); - self.secureBackupBannerDisplay = keyBackupBanner; + self.secureBackupBannerDisplay = secureBackupBanner; return updated; } - (void)hideKeyBackupBannerWithDisplay:(SecureBackupBannerDisplay)secureKeyBackupBannerDisplay { - KeyBackupBannerPreferences *keyBackupBannersPreferences = KeyBackupBannerPreferences.shared; + SecureBackupBannerPreferences *keyBackupBannersPreferences = SecureBackupBannerPreferences.shared; switch (secureKeyBackupBannerDisplay) { case SecureBackupBannerDisplaySetup: keyBackupBannersPreferences.hideSetupBanner = YES; break; - case SecureBackupBannerDisplayRecover: - { - NSString *keyBackupVersion = self.mxSession.crypto.backup.keyBackupVersion.version; - if (keyBackupVersion) - { - [keyBackupBannersPreferences hideRecoverBannerFor:keyBackupVersion]; - } - } - break; default: break; } - [self updateSecureKeyBackupBanner]; + [self updateSecureBackupBanner]; [self forceRefresh]; } @@ -757,7 +748,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou if (indexPath.section == self.secureBackupBannerSection) { - KeyBackupBannerCell* keyBackupBannerCell = [tableView dequeueReusableCellWithIdentifier:KeyBackupBannerCell.defaultReuseIdentifier forIndexPath:indexPath]; + SecureBackupBannerCell* keyBackupBannerCell = [tableView dequeueReusableCellWithIdentifier:SecureBackupBannerCell.defaultReuseIdentifier forIndexPath:indexPath]; [keyBackupBannerCell configureFor:self.secureBackupBannerDisplay]; keyBackupBannerCell.delegate = self; return keyBackupBannerCell; @@ -1551,9 +1542,9 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou } } -#pragma mark - KeyBackupSetupBannerCellDelegate +#pragma mark - secureBackupSetupBannerCellDelegate -- (void)keyBackupBannerCellDidTapCloseAction:(KeyBackupBannerCell * _Nonnull)cell +- (void)secureBackupBannerCellDidTapCloseAction:(SecureBackupBannerCell * _Nonnull)cell { [self hideKeyBackupBannerWithDisplay:self.secureBackupBannerDisplay]; } diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index fc26c5350..d5515985a 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -41,8 +41,8 @@ CGFloat selectedCollectionViewContentOffset; } -@property (nonatomic, strong) SecureKeyBackupSetupCoordinatorBridgePresenter *keyBackupSetupCoordinatorBridgePresenter; -@property (nonatomic, strong) KeyBackupBannerCell *keyBackupBannerPrototypeCell; +@property (nonatomic, strong) SecureKeyBackupSetupCoordinatorBridgePresenter *secureBackupSetupCoordinatorBridgePresenter; +@property (nonatomic, strong) SecureBackupBannerCell *keyBackupBannerPrototypeCell; @end @@ -77,7 +77,7 @@ [self.recentsTableView registerClass:TableViewCellWithCollectionView.class forCellReuseIdentifier:TableViewCellWithCollectionView.defaultReuseIdentifier]; // Register key backup banner cells - [self.recentsTableView registerNib:KeyBackupBannerCell.nib forCellReuseIdentifier:KeyBackupBannerCell.defaultReuseIdentifier]; + [self.recentsTableView registerNib:SecureBackupBannerCell.nib forCellReuseIdentifier:SecureBackupBannerCell.defaultReuseIdentifier]; // Change the table data source. It must be the home view controller itself. self.recentsTableView.dataSource = self; @@ -144,11 +144,11 @@ } } -- (KeyBackupBannerCell *)keyBackupBannerPrototypeCell +- (SecureBackupBannerCell *)keyBackupBannerPrototypeCell { if (!_keyBackupBannerPrototypeCell) { - _keyBackupBannerPrototypeCell = [self.recentsTableView dequeueReusableCellWithIdentifier:KeyBackupBannerCell.defaultReuseIdentifier]; + _keyBackupBannerPrototypeCell = [self.recentsTableView dequeueReusableCellWithIdentifier:SecureBackupBannerCell.defaultReuseIdentifier]; } return _keyBackupBannerPrototypeCell; } @@ -160,12 +160,7 @@ [keyBackupSetupCoordinatorBridgePresenter presentFrom:self animated:YES]; - self.keyBackupSetupCoordinatorBridgePresenter = keyBackupSetupCoordinatorBridgePresenter; -} - -- (void)presentSecureBackupRecover -{ - // TODO: Handle secure backup recover + self.secureBackupSetupCoordinatorBridgePresenter = keyBackupSetupCoordinatorBridgePresenter; } #pragma mark - Override RecentsViewController @@ -373,7 +368,7 @@ else if (indexPath.section == recentsDataSource.secureBackupBannerSection) { CGFloat height = 0.0; - KeyBackupBannerCell *sizingCell = self.keyBackupBannerPrototypeCell; + SecureBackupBannerCell *sizingCell = self.keyBackupBannerPrototypeCell; [sizingCell configureFor:recentsDataSource.secureBackupBannerDisplay]; @@ -431,9 +426,6 @@ case SecureBackupBannerDisplaySetup: [self presentSecureBackupSetup]; break; - case SecureBackupBannerDisplayRecover: - [self presentSecureBackupRecover]; - break; default: break; } @@ -689,14 +681,14 @@ - (void)secureKeyBackupSetupCoordinatorBridgePresenterDelegateDidComplete:(SecureKeyBackupSetupCoordinatorBridgePresenter *)coordinatorBridgePresenter { - [self.keyBackupSetupCoordinatorBridgePresenter dismissWithAnimated:YES completion:nil]; - self.keyBackupSetupCoordinatorBridgePresenter = nil; + [self.secureBackupSetupCoordinatorBridgePresenter dismissWithAnimated:YES completion:nil]; + self.secureBackupSetupCoordinatorBridgePresenter = nil; } - (void)secureKeyBackupSetupCoordinatorBridgePresenterDelegateDidCancel:(SecureKeyBackupSetupCoordinatorBridgePresenter *)coordinatorBridgePresenter { - [self.keyBackupSetupCoordinatorBridgePresenter dismissWithAnimated:YES completion:nil]; - self.keyBackupSetupCoordinatorBridgePresenter = nil; + [self.secureBackupSetupCoordinatorBridgePresenter dismissWithAnimated:YES completion:nil]; + self.secureBackupSetupCoordinatorBridgePresenter = nil; } @end diff --git a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerPreferences.swift b/Riot/Modules/KeyBackup/Banners/KeyBackupBannerPreferences.swift deleted file mode 100644 index eb4a2b06b..000000000 --- a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerPreferences.swift +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright 2018 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 Foundation - -/// Key backup banner user preferences. -@objcMembers -final class KeyBackupBannerPreferences: NSObject { - - // MARK: - Constants - - private enum UserDefaultsKeys { - static let hideSetupBanner = "KeyBackupBannerPreferencesHideSetupBanner" - static let hiddenRecoverBannerKeyBackupVersions = "KeyBackupBannerPreferencesHiddenRecoverBannerKeyBackupVersions" - } - - static let shared = KeyBackupBannerPreferences() - - // MARK: - Properties - private var hiddenRecoverBannerKeyBackupVersions: [String] { - get { - return UserDefaults.standard.stringArray(forKey: UserDefaultsKeys.hiddenRecoverBannerKeyBackupVersions) ?? [] - } - set { - UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.hiddenRecoverBannerKeyBackupVersions) - } - } - - // MARK: - Public - - /// Remember to hide key backup setup banner. - var hideSetupBanner: Bool { - get { - return UserDefaults.standard.bool(forKey: UserDefaultsKeys.hideSetupBanner) - } - set { - UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.hideSetupBanner) - } - } - - /// Remember to hide key backup recover banner for specific key backup version. - /// - /// - Parameter keyBackupVersion: Key backup version recover banner to hide. - func hideRecoverBanner(for keyBackupVersion: String) { - guard self.hiddenRecoverBannerKeyBackupVersions.contains(keyBackupVersion) == false else { - return - } - self.hiddenRecoverBannerKeyBackupVersions.append(keyBackupVersion) - } - - /// Check if key backup recover banner should be hidden for key backup version. - /// - /// - Parameter keyBackupVersion: Key backup version to check. - /// - Returns: true if recover banner should be hidden. - func isRecoverBannerHidden(for keyBackupVersion: String) -> Bool { - return self.hiddenRecoverBannerKeyBackupVersions.contains(keyBackupVersion) - } - - /// Reset key backup banner preferences to default values - func reset() { - self.hideSetupBanner = false - self.hiddenRecoverBannerKeyBackupVersions = [] - } -} diff --git a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.swift b/Riot/Modules/SecureBackup/Banners/KeyBackupBannerCell.swift similarity index 95% rename from Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.swift rename to Riot/Modules/SecureBackup/Banners/KeyBackupBannerCell.swift index 45e93f823..9fcbef20d 100644 --- a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.swift +++ b/Riot/Modules/SecureBackup/Banners/KeyBackupBannerCell.swift @@ -17,11 +17,11 @@ import UIKit @objc protocol KeyBackupBannerCellDelegate: class { - func keyBackupBannerCellDidTapCloseAction(_ cell: KeyBackupBannerCell) + func keyBackupBannerCellDidTapCloseAction(_ cell: SecureBackupBannerCell) } @objcMembers -final class KeyBackupBannerCell: MXKTableViewCell { +final class SecureBackupBannerCell: MXKTableViewCell { // MARK: - Properties diff --git a/Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.swift b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.swift new file mode 100644 index 000000000..a1ff99449 --- /dev/null +++ b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.swift @@ -0,0 +1,101 @@ +/* + Copyright 2019 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 + +@objc protocol SecureBackupBannerCellDelegate: class { + func secureBackupBannerCellDidTapCloseAction(_ cell: SecureBackupBannerCell) +} + +@objcMembers +final class SecureBackupBannerCell: MXKTableViewCell, Themable { + + // MARK: - Properties + + // MARK: Outlets + + @IBOutlet private weak var shieldImageView: UIImageView! + @IBOutlet private weak var titleLabel: UILabel! + @IBOutlet private weak var subtitleLabel: UILabel! + @IBOutlet private weak var closeButton: UIButton! + + // MARK: Public + + weak var delegate: SecureBackupBannerCellDelegate? + + // MARK: - Overrides + + override class func defaultReuseIdentifier() -> String { + return String(describing: self) + } + + override class func nib() -> UINib { + return UINib(nibName: String(describing: self), bundle: nil) + } + + override func customizeRendering() { + super.customizeRendering() + + let theme = ThemeService.shared().theme + self.update(theme: theme) + } + + // MARK: - Life cycle + + override func awakeFromNib() { + super.awakeFromNib() + + let shieldImage = Asset.Images.secretsSetupKey.image.withRenderingMode(.alwaysTemplate) + self.shieldImageView.image = shieldImage + + let closeImage = Asset.Images.closeBanner.image.withRenderingMode(.alwaysTemplate) + self.closeButton.setImage(closeImage, for: .normal) + } + + // MARK: - Public + + func configure(for bannerDisplay: SecureBackupBannerDisplay) { + + let title: String? + let subtitle: String? + + switch bannerDisplay { + case .setup: + title = VectorL10n.secureBackupSetupBannerTitle + subtitle = VectorL10n.secureBackupSetupBannerSubtitle + default: + title = nil + subtitle = nil + } + + self.titleLabel.text = title + self.subtitleLabel.text = subtitle + } + + func update(theme: Theme) { + self.shieldImageView.tintColor = theme.textPrimaryColor + self.closeButton.tintColor = theme.textPrimaryColor + + self.titleLabel.textColor = theme.textPrimaryColor + self.subtitleLabel.textColor = theme.textPrimaryColor + } + + // MARK: - Actions + + @IBAction private func closeButtonAction(_ sender: Any) { + self.delegate?.secureBackupBannerCellDidTapCloseAction(self) + } +} diff --git a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.xib b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.xib similarity index 98% rename from Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.xib rename to Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.xib index 8ca8e35df..b93414ceb 100644 --- a/Riot/Modules/KeyBackup/Banners/KeyBackupBannerCell.xib +++ b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerCell.xib @@ -11,7 +11,7 @@ - + diff --git a/Riot/Modules/SecureBackup/Banners/SecureBackupBannerPreferences.swift b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerPreferences.swift new file mode 100644 index 000000000..03997d7f9 --- /dev/null +++ b/Riot/Modules/SecureBackup/Banners/SecureBackupBannerPreferences.swift @@ -0,0 +1,49 @@ +/* + Copyright 2018 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 Foundation + +/// Secure backup banner user preferences. +@objcMembers +final class SecureBackupBannerPreferences: NSObject { + + // MARK: - Constants + + private enum UserDefaultsKeys { + static let hideSetupBanner = "SecureBackupBannerPreferencesHideSetupBanner" + } + + static let shared = SecureBackupBannerPreferences() + + // MARK: - Properties + + // MARK: - Public + + /// Remember to hide key backup setup banner. + var hideSetupBanner: Bool { + get { + return UserDefaults.standard.bool(forKey: UserDefaultsKeys.hideSetupBanner) + } + set { + UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.hideSetupBanner) + } + } + + /// Reset key backup banner preferences to default values + func reset() { + self.hideSetupBanner = false + } +} diff --git a/Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroCell.swift b/Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroCell.swift similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroCell.swift rename to Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroCell.swift diff --git a/Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroCell.xib b/Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroCell.xib similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroCell.xib rename to Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroCell.xib diff --git a/Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroViewController.storyboard b/Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroViewController.storyboard similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroViewController.storyboard rename to Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroViewController.storyboard diff --git a/Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroViewController.swift b/Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroViewController.swift similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/Intro/SecureKeyBackupSetupIntroViewController.swift rename to Riot/Modules/SecureBackup/Setup/Intro/SecureKeyBackupSetupIntroViewController.swift diff --git a/Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinator.swift b/Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinator.swift similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinator.swift rename to Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinator.swift diff --git a/Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinatorBridgePresenter.swift b/Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinatorBridgePresenter.swift similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinatorBridgePresenter.swift rename to Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinatorBridgePresenter.swift diff --git a/Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinatorType.swift b/Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinatorType.swift similarity index 100% rename from Riot/Modules/KeyBackup/SecureSetup/SecureKeyBackupSetupCoordinatorType.swift rename to Riot/Modules/SecureBackup/Setup/SecureKeyBackupSetupCoordinatorType.swift