diff --git a/CHANGES.rst b/CHANGES.rst index 8e8e5fd4c..c82f41c33 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,7 @@ Improvements: Bugfix: * Fix biometry name null case (#3551). * Avoid email validation link to redirect to web app (#3513). + * Wait for first sync complete before stopping loading screen (#3336). * Gracefully cancel verification on iOS 13 drag gesture (#3556). API Change: diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index 4ee3246f3..da794c940 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -841,13 +841,14 @@ EC85D754247C0F5B002C44C9 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D753247C0F5B002C44C9 /* Constants.swift */; }; EC85D755247C0F84002C44C9 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D753247C0F5B002C44C9 /* Constants.swift */; }; EC85D757247E700F002C44C9 /* NSEMemoryStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC85D756247E700F002C44C9 /* NSEMemoryStore.swift */; }; - EC9A3EC524E1616900A8CFAE /* PushNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC9A3EC424E1616900A8CFAE /* PushNotificationManager.swift */; }; - EC9A3EC624E1632C00A8CFAE /* PushNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC9A3EC424E1616900A8CFAE /* PushNotificationManager.swift */; }; + EC9A3EC524E1616900A8CFAE /* PushNotificationStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC9A3EC424E1616900A8CFAE /* PushNotificationStore.swift */; }; + EC9A3EC624E1632C00A8CFAE /* PushNotificationStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC9A3EC424E1616900A8CFAE /* PushNotificationStore.swift */; }; EC9A3EC724E1634100A8CFAE /* KeyValueStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA87124C823E700DE9EBF /* KeyValueStore.swift */; }; EC9A3EC824E1634800A8CFAE /* KeychainStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA87424C8259700DE9EBF /* KeychainStore.swift */; }; ECAE7AE524EC0E01002FA813 /* TableViewSections.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECAE7AE424EC0E01002FA813 /* TableViewSections.swift */; }; ECAE7AE724EC15F7002FA813 /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECAE7AE624EC15F7002FA813 /* Section.swift */; }; ECAE7AE924EC1888002FA813 /* Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECAE7AE824EC1888002FA813 /* Row.swift */; }; + ECAE7AEE24EFDD1F002FA813 /* MXSessionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECAE7AED24EFDD1F002FA813 /* MXSessionState.swift */; }; ECB101302477CFDB00CF8C11 /* UITableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECB1012C2477CFDB00CF8C11 /* UITableView.swift */; }; ECB101312477CFDB00CF8C11 /* UILabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECB1012D2477CFDB00CF8C11 /* UILabel.swift */; }; ECB101322477CFDB00CF8C11 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECB1012E2477CFDB00CF8C11 /* UIDevice.swift */; }; @@ -1972,10 +1973,11 @@ EC85D750247C0E8F002C44C9 /* UNUserNotificationCenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UNUserNotificationCenter.swift; sourceTree = ""; }; EC85D753247C0F5B002C44C9 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; EC85D756247E700F002C44C9 /* NSEMemoryStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSEMemoryStore.swift; sourceTree = ""; }; - EC9A3EC424E1616900A8CFAE /* PushNotificationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotificationManager.swift; sourceTree = ""; }; + EC9A3EC424E1616900A8CFAE /* PushNotificationStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotificationStore.swift; sourceTree = ""; }; ECAE7AE424EC0E01002FA813 /* TableViewSections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewSections.swift; sourceTree = ""; }; ECAE7AE624EC15F7002FA813 /* Section.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Section.swift; sourceTree = ""; }; ECAE7AE824EC1888002FA813 /* Row.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Row.swift; sourceTree = ""; }; + ECAE7AED24EFDD1F002FA813 /* MXSessionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXSessionState.swift; sourceTree = ""; }; ECB1012C2477CFDB00CF8C11 /* UITableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UITableView.swift; sourceTree = ""; }; ECB1012D2477CFDB00CF8C11 /* UILabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UILabel.swift; sourceTree = ""; }; ECB1012E2477CFDB00CF8C11 /* UIDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = ""; }; @@ -4827,7 +4829,7 @@ children = ( EC85D73C2477DDD0002C44C9 /* PushNotificationService.h */, EC85D73D2477DDD0002C44C9 /* PushNotificationService.m */, - EC9A3EC424E1616900A8CFAE /* PushNotificationManager.swift */, + EC9A3EC424E1616900A8CFAE /* PushNotificationStore.swift */, ); path = PushNotification; sourceTree = ""; @@ -4964,6 +4966,7 @@ B1DCC63322E72C1B00625807 /* UISearchBar.swift */, B11291EB238D704C0077B478 /* FloatingPoint.swift */, 32FD757524D2C9BA00BA7B37 /* Bundle.swift */, + ECAE7AED24EFDD1F002FA813 /* MXSessionState.swift */, ); path = Categories; sourceTree = ""; @@ -5705,7 +5708,7 @@ EC2B4EF224A1EF34005EB739 /* DataProtectionHelper.swift in Sources */, EC85D7462477E5F7002C44C9 /* NotificationService.swift in Sources */, 32FD755424D074C700BA7B37 /* CommonConfiguration.swift in Sources */, - EC9A3EC624E1632C00A8CFAE /* PushNotificationManager.swift in Sources */, + EC9A3EC624E1632C00A8CFAE /* PushNotificationStore.swift in Sources */, 32FD757424D2BEF700BA7B37 /* InfoPlist.swift in Sources */, EC85D752247C0F52002C44C9 /* UNUserNotificationCenter.swift in Sources */, EC9A3EC724E1634100A8CFAE /* KeyValueStore.swift in Sources */, @@ -5897,6 +5900,7 @@ F05927C91FDED836009F2A68 /* MXGroup+Riot.m in Sources */, B1B5594520EF7BD000210D55 /* TableViewCellWithCollectionView.m in Sources */, B1A6C109238828A6002882FD /* SlidingModalPresentationDelegate.swift in Sources */, + ECAE7AEE24EFDD1F002FA813 /* MXSessionState.swift in Sources */, 32DB557722FDADE50016329E /* ServiceTermsModalCoordinator.swift in Sources */, B185145B24B8C98200EE19EA /* MajorUpdateViewController.swift in Sources */, 32DB557922FDADE50016329E /* ServiceTermsModalScreenViewModel.swift in Sources */, @@ -6168,7 +6172,7 @@ EC711BA924A63B58008F830C /* SecureBackupSetupCoordinatorBridgePresenter.swift in Sources */, B1B558C720EF768F00210D55 /* RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.m in Sources */, B1B336C5242B933700F95EC4 /* KeyVerificationSelfVerifyStartViewModel.swift in Sources */, - EC9A3EC524E1616900A8CFAE /* PushNotificationManager.swift in Sources */, + EC9A3EC524E1616900A8CFAE /* PushNotificationStore.swift in Sources */, B1B558F020EF768F00210D55 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m in Sources */, 926FA53F1F4C132000F826C2 /* MXSession+Riot.m in Sources */, EC711B8324A63B37008F830C /* SecretsSetupRecoveryPassphraseCoordinator.swift in Sources */, diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index a8e1bfef7..98fbc2734 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -237,6 +237,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni Related push notification service instance. Will be created when launch finished. */ @property (nonatomic, strong) PushNotificationService *pushNotificationService; +@property (nonatomic, strong) PushNotificationStore *pushNotificationStore; @property (nonatomic, strong) LocalAuthenticationService *localAuthenticationService; @property (nonatomic, strong) MajorUpdateManager *majorUpdateManager; @@ -510,7 +511,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni self.localAuthenticationService = [[LocalAuthenticationService alloc] initWithPinCodePreferences:[PinCodePreferences shared]]; - self.pushNotificationService = [[PushNotificationService alloc] initWithPushNotificationManager:PushNotificationManager.shared]; + self.pushNotificationStore = [PushNotificationStore new]; + self.pushNotificationService = [[PushNotificationService alloc] initWithPushNotificationStore:self.pushNotificationStore]; self.pushNotificationService.delegate = self; // Add matrix observers, and initialize matrix sessions if the app is not launched in background. @@ -2250,8 +2252,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Reset user pin code [PinCodePreferences.shared reset]; - // Reset push notification manager - [PushNotificationManager.shared reset]; + // Reset push notification store + [self.pushNotificationStore reset]; #ifdef MX_CALL_STACK_ENDPOINT // Erase all created certificates and private keys by MXEndpointCallStack diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 07aba72e5..463b8c003 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1121,6 +1121,7 @@ "device_verification_self_verify_wait_recover_secrets_without_passphrase" = "Use Recovery Key"; "device_verification_self_verify_wait_recover_secrets_with_passphrase" = "Use Recovery Passphrase or Key"; "device_verification_self_verify_wait_recover_secrets_additional_information" = "If you can't accessing an existing session"; +"device_verification_self_verify_wait_recover_secrets_checking_availability" = "Checking for other verification capabilities ..."; // MARK: Verify diff --git a/Riot/Categories/MXSessionState.swift b/Riot/Categories/MXSessionState.swift new file mode 100644 index 000000000..9f43992a8 --- /dev/null +++ b/Riot/Categories/MXSessionState.swift @@ -0,0 +1,25 @@ +// +// Copyright 2020 Vector Creations 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 + +extension MXSessionState: Comparable { + + public static func < (lhs: MXSessionState, rhs: MXSessionState) -> Bool { + return lhs.rawValue < rhs.rawValue + } + +} diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index ffdd4d08c..34a325d63 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -926,6 +926,10 @@ internal enum VectorL10n { internal static var deviceVerificationSelfVerifyWaitRecoverSecretsAdditionalInformation: String { return VectorL10n.tr("Vector", "device_verification_self_verify_wait_recover_secrets_additional_information") } + /// Checking for other verification capabilities ... + internal static var deviceVerificationSelfVerifyWaitRecoverSecretsCheckingAvailability: String { + return VectorL10n.tr("Vector", "device_verification_self_verify_wait_recover_secrets_checking_availability") + } /// Use Recovery Passphrase or Key internal static var deviceVerificationSelfVerifyWaitRecoverSecretsWithPassphrase: String { return VectorL10n.tr("Vector", "device_verification_self_verify_wait_recover_secrets_with_passphrase") diff --git a/Riot/Managers/PushNotification/PushNotificationService.h b/Riot/Managers/PushNotification/PushNotificationService.h index fc45a328a..24729adca 100644 --- a/Riot/Managers/PushNotification/PushNotificationService.h +++ b/Riot/Managers/PushNotification/PushNotificationService.h @@ -34,8 +34,8 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)new NS_UNAVAILABLE; /// Designated initializer -/// @param pushNotificationManager Push Notification Manager instance -- (instancetype)initWithPushNotificationManager:(PushNotificationManager *)pushNotificationManager; +/// @param pushNotificationStore Push Notification Store instance +- (instancetype)initWithPushNotificationStore:(PushNotificationStore *)pushNotificationStore; /** Is push really registered. diff --git a/Riot/Managers/PushNotification/PushNotificationService.m b/Riot/Managers/PushNotification/PushNotificationService.m index 87e1f4cc2..57611bdcc 100644 --- a/Riot/Managers/PushNotification/PushNotificationService.m +++ b/Riot/Managers/PushNotification/PushNotificationService.m @@ -22,16 +22,14 @@ #import @interface PushNotificationService() -{ - /** - Matrix session observer used to detect new opened sessions. - */ - id matrixSessionStateObserver; -} +/** +Matrix session observer used to detect new opened sessions. +*/ +@property (nonatomic, weak) id matrixSessionStateObserver; @property (nonatomic, nullable, copy) void (^registrationForRemoteNotificationsCompletion)(NSError *); @property (nonatomic, strong) PKPushRegistry *pushRegistry; -@property (nonatomic, strong) PushNotificationManager *pushNotificationManager; +@property (nonatomic, strong) PushNotificationStore *pushNotificationStore; /// Should PushNotificationService receive VoIP pushes @property (nonatomic, assign) BOOL shouldReceiveVoIPPushes; @@ -40,11 +38,11 @@ @implementation PushNotificationService -- (instancetype)initWithPushNotificationManager:(PushNotificationManager *)pushNotificationManager +- (instancetype)initWithPushNotificationStore:(PushNotificationStore *)pushNotificationStore { if (self = [super init]) { - self.pushNotificationManager = pushNotificationManager; + self.pushNotificationStore = pushNotificationStore; _pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; self.shouldReceiveVoIPPushes = YES; } @@ -117,7 +115,7 @@ _isPushRegistered = YES; - if (!_pushNotificationManager.pushKitToken) + if (!_pushNotificationStore.pushKitToken) { [self configurePushKit]; } @@ -162,7 +160,7 @@ - (void)applicationDidEnterBackground { - if (_pushNotificationManager.pushKitToken) + if (_pushNotificationStore.pushKitToken) { self.shouldReceiveVoIPPushes = YES; } @@ -172,7 +170,7 @@ { [[UNUserNotificationCenter currentNotificationCenter] removeUnwantedNotifications]; [[UNUserNotificationCenter currentNotificationCenter] removeCallNotificationsFor:nil]; - if (_pushNotificationManager.pushKitToken) + if (_pushNotificationStore.pushKitToken) { self.shouldReceiveVoIPPushes = NO; } @@ -184,7 +182,7 @@ { _shouldReceiveVoIPPushes = shouldReceiveVoIPPushes; - if (_shouldReceiveVoIPPushes && _pushNotificationManager.pushKitToken) + if (_shouldReceiveVoIPPushes && _pushNotificationStore.pushKitToken) { MXSession *session = [AppDelegate theDelegate].mxSessions.firstObject; if (session.state >= MXSessionStateStoreDataReady) @@ -194,7 +192,11 @@ else { // add an observer for session state - matrixSessionStateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + MXWeakify(self); + + NSNotificationCenter * __weak notificationCenter = [NSNotificationCenter defaultCenter]; + self.matrixSessionStateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + MXStrongifyAndReturnIfNil(self); MXSession *mxSession = (MXSession*)notif.object; if ([[AppDelegate theDelegate].mxSessions containsObject:mxSession] @@ -202,8 +204,7 @@ && self->_shouldReceiveVoIPPushes) { [self configurePushKit]; - [[NSNotificationCenter defaultCenter] removeObserver:self->matrixSessionStateObserver]; - self->matrixSessionStateObserver = nil; + [notificationCenter removeObserver:self.matrixSessionStateObserver]; } }]; } @@ -230,15 +231,12 @@ if (account.mxSession.state == MXSessionStatePaused) { NSLog(@"[PushNotificationService] launchBackgroundSync"); - __weak typeof(self) weakSelf = self; + MXWeakify(self); [account backgroundSync:20000 success:^{ // Sanity check - if (!weakSelf) - { - return; - } + MXStrongifyAndReturnIfNil(self); [[UNUserNotificationCenter currentNotificationCenter] removeUnwantedNotifications]; [[UNUserNotificationCenter currentNotificationCenter] removeCallNotificationsFor:nil]; @@ -450,7 +448,7 @@ - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)pushCredentials forType:(PKPushType)type { NSLog(@"[PushNotificationService] did update PushKit credentials"); - _pushNotificationManager.pushKitToken = pushCredentials.token; + _pushNotificationStore.pushKitToken = pushCredentials.token; if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { self.shouldReceiveVoIPPushes = NO; @@ -474,9 +472,9 @@ if (@available(iOS 13.0, *)) { // for iOS 13, we'll just report the incoming call in the same runloop. It means we cannot call an async API here. - MXEvent *lastCallInvite = _pushNotificationManager.lastCallInvite; + MXEvent *lastCallInvite = _pushNotificationStore.lastCallInvite; // remove event - _pushNotificationManager.lastCallInvite = nil; + _pushNotificationStore.lastCallInvite = nil; MXSession *session = [AppDelegate theDelegate].mxSessions.firstObject; // when we have a VoIP push while the application is killed, session.callManager will not be ready yet. Configure it. [[AppDelegate theDelegate] configureCallManagerIfRequiredForSession:session]; diff --git a/Riot/Managers/PushNotification/PushNotificationManager.swift b/Riot/Managers/PushNotification/PushNotificationStore.swift similarity index 96% rename from Riot/Managers/PushNotification/PushNotificationManager.swift rename to Riot/Managers/PushNotification/PushNotificationStore.swift index fb5bd1633..694df3309 100644 --- a/Riot/Managers/PushNotification/PushNotificationManager.swift +++ b/Riot/Managers/PushNotification/PushNotificationStore.swift @@ -19,7 +19,7 @@ import KeychainAccess import MatrixSDK @objcMembers -final class PushNotificationManager: NSObject { +final class PushNotificationStore: NSObject { // MARK: - Constants @@ -32,8 +32,6 @@ final class PushNotificationManager: NSObject { static let lastCallInvite: String = "lastCallInvite" } - static let shared = PushNotificationManager() - /// Store. Defaults to `KeychainStore` private let store: KeyValueStore diff --git a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard index a854f8878..d3db75f1f 100644 --- a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard +++ b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewController.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -19,16 +17,16 @@ - + - + - + - + @@ -85,19 +83,43 @@ Riot X for Android - + + + + + + + + + + + + + + + + + + + + - +