diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index bf1b697465..62f0797dcb 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1977,6 +1977,7 @@ Tap the + to start adding people."; // MARK: - Launch loading +"launch_loading_migrating_data" = "Migrating data\n%@ %%"; "launch_loading_server_syncing" = "Syncing with the server"; "launch_loading_server_syncing_nth_attempt" = "Syncing with the server\n(%@ attempt)"; "launch_loading_processing_response" = "Processing data\n%@ %%"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 3de9542c2e..bb8e85211b 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -3179,6 +3179,10 @@ public class VectorL10n: NSObject { public static var later: String { return VectorL10n.tr("Vector", "later") } + /// Migrating data\n%@ %% + public static func launchLoadingMigratingData(_ p1: String) -> String { + return VectorL10n.tr("Vector", "launch_loading_migrating_data", p1) + } /// Processing data\n%@ %% public static func launchLoadingProcessingResponse(_ p1: String) -> String { return VectorL10n.tr("Vector", "launch_loading_processing_response", p1) diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 15cdb8be1c..6ede5be425 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -2395,14 +2395,14 @@ - (void)showLaunchAnimation MXLogDebug(@"[AppDelegate] showLaunchAnimation"); LaunchLoadingView *launchLoadingView; - if (MXSDKOptions.sharedInstance.enableSyncProgress) + if (MXSDKOptions.sharedInstance.enableStartupProgress) { MXSession *mainSession = self.mxSessions.firstObject; - launchLoadingView = [LaunchLoadingView instantiateWithSyncProgress:mainSession.syncProgress]; + launchLoadingView = [LaunchLoadingView instantiateWithStartupProgress:mainSession.startupProgress]; } else { - launchLoadingView = [LaunchLoadingView instantiateWithSyncProgress:nil]; + launchLoadingView = [LaunchLoadingView instantiateWithStartupProgress:nil]; } launchLoadingView.frame = window.bounds; diff --git a/Riot/Modules/Authentication/AuthenticationCoordinator.swift b/Riot/Modules/Authentication/AuthenticationCoordinator.swift index 8b98989929..9f2e7083b6 100644 --- a/Riot/Modules/Authentication/AuthenticationCoordinator.swift +++ b/Riot/Modules/Authentication/AuthenticationCoordinator.swift @@ -613,8 +613,8 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc /// Replace the contents of the navigation router with a loading animation. private func showLoadingAnimation() { - let syncProgress: MXSessionSyncProgress? = MXSDKOptions.sharedInstance().enableSyncProgress ? session?.syncProgress : nil - let loadingViewController = LaunchLoadingViewController(syncProgress: syncProgress) + let startupProgress: MXSessionStartupProgress? = MXSDKOptions.sharedInstance().enableStartupProgress ? session?.startupProgress : nil + let loadingViewController = LaunchLoadingViewController(startupProgress: startupProgress) loadingViewController.modalPresentationStyle = .fullScreen // Replace the navigation stack with the loading animation diff --git a/Riot/Modules/Authentication/Legacy/LegacyAuthenticationCoordinator.swift b/Riot/Modules/Authentication/Legacy/LegacyAuthenticationCoordinator.swift index 583419075f..d6270edae1 100644 --- a/Riot/Modules/Authentication/Legacy/LegacyAuthenticationCoordinator.swift +++ b/Riot/Modules/Authentication/Legacy/LegacyAuthenticationCoordinator.swift @@ -106,8 +106,8 @@ final class LegacyAuthenticationCoordinator: NSObject, AuthenticationCoordinator // MARK: - Private private func showLoadingAnimation() { - let syncProgress: MXSessionSyncProgress? = MXSDKOptions.sharedInstance().enableSyncProgress ? session?.syncProgress : nil - let loadingViewController = LaunchLoadingViewController(syncProgress: syncProgress) + let startupProgress: MXSessionStartupProgress? = MXSDKOptions.sharedInstance().enableStartupProgress ? session?.startupProgress : nil + let loadingViewController = LaunchLoadingViewController(startupProgress: startupProgress) loadingViewController.modalPresentationStyle = .fullScreen // Replace the navigation stack with the loading animation diff --git a/Riot/Modules/LaunchLoading/LaunchLoadingView.swift b/Riot/Modules/LaunchLoading/LaunchLoadingView.swift index 55f3aff054..18d6add9d4 100644 --- a/Riot/Modules/LaunchLoading/LaunchLoadingView.swift +++ b/Riot/Modules/LaunchLoading/LaunchLoadingView.swift @@ -41,9 +41,9 @@ final class LaunchLoadingView: UIView, NibLoadable, Themable { // MARK: - Setup - static func instantiate(syncProgress: MXSessionSyncProgress?) -> LaunchLoadingView { + static func instantiate(startupProgress: MXSessionStartupProgress?) -> LaunchLoadingView { let view = LaunchLoadingView.loadFromNib() - syncProgress?.delegate = view + startupProgress?.delegate = view return view } @@ -54,7 +54,7 @@ final class LaunchLoadingView: UIView, NibLoadable, Themable { animationTimeline.play() self.animationTimeline = animationTimeline - self.statusLabel.isHidden = !MXSDKOptions.sharedInstance().enableSyncProgress + self.statusLabel.isHidden = !MXSDKOptions.sharedInstance().enableStartupProgress } // MARK: - Public @@ -65,21 +65,35 @@ final class LaunchLoadingView: UIView, NibLoadable, Themable { } } -extension LaunchLoadingView: MXSessionSyncProgressDelegate { - func sessionDidUpdateSyncState(_ state: MXSessionSyncState) { - guard MXSDKOptions.sharedInstance().enableSyncProgress else { +extension LaunchLoadingView: MXSessionStartupProgressDelegate { + func sessionDidUpdateStartupStage(_ stage: MXSessionStartupStage) { + guard MXSDKOptions.sharedInstance().enableStartupProgress else { + return + } + updateStatusText(for: stage) + + } + + private func updateStatusText(for stage: MXSessionStartupStage) { + guard Thread.isMainThread else { + DispatchQueue.main.async { [weak self] in + self?.updateStatusText(for: stage) + } return } // Sync may be doing a lot of heavy work on the main thread and the status text // does not update reliably enough without explicitly refreshing CATransaction.begin() - statusLabel.text = statusText(for: state) + statusLabel.text = statusText(for: stage) CATransaction.commit() } - private func statusText(for state: MXSessionSyncState) -> String { - switch state { + private func statusText(for stage: MXSessionStartupStage) -> String { + switch stage { + case .migratingData(let progress): + let percent = Int(floor(progress * 100)) + return VectorL10n.launchLoadingMigratingData("\(percent)") case .serverSyncing(let attempts): if attempts > 1, let nth = numberFormatter.string(from: NSNumber(value: attempts)) { return VectorL10n.launchLoadingServerSyncingNthAttempt(nth) diff --git a/Riot/Modules/LaunchLoading/LaunchLoadingViewController.swift b/Riot/Modules/LaunchLoading/LaunchLoadingViewController.swift index 1da229b79a..ef9630dda9 100644 --- a/Riot/Modules/LaunchLoading/LaunchLoadingViewController.swift +++ b/Riot/Modules/LaunchLoading/LaunchLoadingViewController.swift @@ -21,10 +21,10 @@ class LaunchLoadingViewController: UIViewController, Reusable { required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - init(syncProgress: MXSessionSyncProgress?) { + init(startupProgress: MXSessionStartupProgress?) { super.init(nibName: "LaunchLoadingViewController", bundle: nil) - let launchLoadingView = LaunchLoadingView.instantiate(syncProgress: syncProgress) + let launchLoadingView = LaunchLoadingView.instantiate(startupProgress: startupProgress) launchLoadingView.update(theme: ThemeService.shared().theme) view.vc_addSubViewMatchingParent(launchLoadingView) diff --git a/changelog.d/pr-7286.change b/changelog.d/pr-7286.change new file mode 100644 index 0000000000..ff8cbb8204 --- /dev/null +++ b/changelog.d/pr-7286.change @@ -0,0 +1 @@ +CryptoV2: Display migration progress during startup