Sketch out the backup restore view.

pull/1/head
Matthew Chen 7 years ago
parent 56fe3663e6
commit 4ee0958384

@ -142,6 +142,11 @@ static NSTimeInterval launchStartedAt;
return Environment.shared.windowManager; return Environment.shared.windowManager;
} }
- (OWSBackup *)backup
{
return AppEnvironment.shared.backup;
}
#pragma mark - #pragma mark -
- (void)applicationDidEnterBackground:(UIApplication *)application { - (void)applicationDidEnterBackground:(UIApplication *)application {
@ -547,6 +552,10 @@ static NSTimeInterval launchStartedAt;
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
return NO; return NO;
} }
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring URL; pending restore decision.");
return NO;
}
if (!AppReadiness.isAppReady) { if (!AppReadiness.isAppReady) {
OWSLogWarn(@"Ignoring openURL: app not ready."); OWSLogWarn(@"Ignoring openURL: app not ready.");
@ -744,6 +753,12 @@ static NSTimeInterval launchStartedAt;
if (self.didAppLaunchFail) { if (self.didAppLaunchFail) {
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
completionHandler(NO);
return;
}
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring shortcut action; pending restore decision.");
completionHandler(NO);
return; return;
} }
@ -795,6 +810,10 @@ static NSTimeInterval launchStartedAt;
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
return NO; return NO;
} }
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring user activity; pending restore decision.");
return NO;
}
if ([userActivity.activityType isEqualToString:@"INStartVideoCallIntent"]) { if ([userActivity.activityType isEqualToString:@"INStartVideoCallIntent"]) {
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0)) { if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0)) {
@ -950,6 +969,10 @@ static NSTimeInterval launchStartedAt;
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
return; return;
} }
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring remote notification; pending restore decision.");
return;
}
// It is safe to continue even if the app isn't ready. // It is safe to continue even if the app isn't ready.
[[PushManager sharedManager] application:application didReceiveRemoteNotification:userInfo]; [[PushManager sharedManager] application:application didReceiveRemoteNotification:userInfo];
@ -964,6 +987,10 @@ static NSTimeInterval launchStartedAt;
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
return; return;
} }
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring remote notification; pending restore decision.");
return;
}
// It is safe to continue even if the app isn't ready. // It is safe to continue even if the app isn't ready.
[[PushManager sharedManager] application:application [[PushManager sharedManager] application:application
@ -978,6 +1005,10 @@ static NSTimeInterval launchStartedAt;
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
return; return;
} }
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring local notification; pending restore decision.");
return;
}
OWSLogInfo(@"%@", notification); OWSLogInfo(@"%@", notification);
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
@ -994,6 +1025,12 @@ static NSTimeInterval launchStartedAt;
if (self.didAppLaunchFail) { if (self.didAppLaunchFail) {
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
completionHandler();
return;
}
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring action; pending restore decision.");
completionHandler();
return; return;
} }
@ -1023,6 +1060,12 @@ static NSTimeInterval launchStartedAt;
if (self.didAppLaunchFail) { if (self.didAppLaunchFail) {
OWSFailDebug(@"app launch failed"); OWSFailDebug(@"app launch failed");
completionHandler();
return;
}
if (self.backup.hasPendingRestoreDecision) {
OWSLogInfo(@"Ignoring action; pending restore decision.");
completionHandler();
return; return;
} }
@ -1220,18 +1263,21 @@ static NSTimeInterval launchStartedAt;
NSTimeInterval startupDuration = CACurrentMediaTime() - launchStartedAt; NSTimeInterval startupDuration = CACurrentMediaTime() - launchStartedAt;
OWSLogInfo(@"Presenting app %.2f seconds after launch started.", startupDuration); OWSLogInfo(@"Presenting app %.2f seconds after launch started.", startupDuration);
UIViewController *rootViewController;
if ([self.tsAccountManager isRegistered]) { if ([self.tsAccountManager isRegistered]) {
HomeViewController *homeView = [HomeViewController new]; if (self.backup.hasPendingRestoreDecision) {
SignalsNavigationController *navigationController = rootViewController = [BackupRestoreViewController new];
[[SignalsNavigationController alloc] initWithRootViewController:homeView]; } else {
self.window.rootViewController = navigationController; rootViewController = [HomeViewController new];
}
} else { } else {
RegistrationViewController *viewController = [RegistrationViewController new]; rootViewController = [RegistrationViewController new];
OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:viewController];
navigationController.navigationBarHidden = YES;
self.window.rootViewController = navigationController;
} }
OWSAssertDebug(rootViewController);
OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:rootViewController];
navigationController.navigationBarHidden = YES;
self.window.rootViewController = navigationController;
[AppUpdateNag.sharedInstance showAppUpgradeNagIfNecessary]; [AppUpdateNag.sharedInstance showAppUpgradeNagIfNecessary];
} }

@ -426,9 +426,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
{ {
OWSLogVerbose(@""); OWSLogVerbose(@"");
[self checkCanImportBackup];
return;
// Dismiss this view. // Dismiss this view.
switch (self.profileViewMode) { switch (self.profileViewMode) {
case ProfileViewMode_AppSettings: case ProfileViewMode_AppSettings:

@ -115,18 +115,27 @@ public class BackupRestoreViewController: OWSTableViewController {
backup.setHasPendingRestoreDecision(false) backup.setHasPendingRestoreDecision(false)
self.dismiss(animated: true) dismiss(animated: true)
} }
@objc @objc
private func startImport() { private func startImport() {
Logger.info("") Logger.info("")
hasBegunImport = true
backup.tryToImport() backup.tryToImport()
} }
private func showHomeView() { private func showHomeView() {
SignalApp.shared().showHomeView() let isModal = navigationController?.presentingViewController != nil
if isModal {
dismiss(animated: true, completion: {
SignalApp.shared().showHomeView()
})
} else {
SignalApp.shared().showHomeView()
}
} }
// MARK: - Notifications // MARK: - Notifications
@ -134,7 +143,12 @@ public class BackupRestoreViewController: OWSTableViewController {
@objc func backupStateDidChange() { @objc func backupStateDidChange() {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.verbose("backup.backupImportState: \(NSStringForBackupImportState(backup.backupImportState))")
Logger.flush()
if backup.backupImportState == .succeeded { if backup.backupImportState == .succeeded {
backup.setHasPendingRestoreDecision(false)
showHomeView() showHomeView()
} else { } else {
updateTableContents() updateTableContents()

@ -259,6 +259,11 @@ NSString *NSStringForBackupImportState(OWSBackupState state)
if (!self.isBackupEnabled) { if (!self.isBackupEnabled) {
return NO; return NO;
} }
if (self.hasPendingRestoreDecision) {
// Don't backup while awaiting user decision about
// whether to import previous backup.
return NO;
}
if (UIApplication.sharedApplication.applicationState != UIApplicationStateActive) { if (UIApplication.sharedApplication.applicationState != UIApplicationStateActive) {
// Don't start backups when app is in the background. // Don't start backups when app is in the background.
return NO; return NO;

@ -234,13 +234,13 @@
"BACKUP_RESTORE_DECISION_TITLE" = "Backup Available"; "BACKUP_RESTORE_DECISION_TITLE" = "Backup Available";
/* Label for the backup restore description. */ /* Label for the backup restore description. */
"BACKUP_RESTORE_DESCRIPTION" = "BACKUP_RESTORE_DESCRIPTION"; "BACKUP_RESTORE_DESCRIPTION" = "Restoring Backup";
/* Label for the backup restore progress. */ /* Label for the backup restore progress. */
"BACKUP_RESTORE_PROGRESS" = "BACKUP_RESTORE_PROGRESS"; "BACKUP_RESTORE_PROGRESS" = "Progress";
/* Label for the backup restore status. */ /* Label for the backup restore status. */
"BACKUP_RESTORE_STATUS" = "BACKUP_RESTORE_STATUS"; "BACKUP_RESTORE_STATUS" = "Status";
/* An explanation of the consequences of blocking a group. */ /* An explanation of the consequences of blocking a group. */
"BLOCK_GROUP_BEHAVIOR_EXPLANATION" = "You will no longer receive messages or updates from this group."; "BLOCK_GROUP_BEHAVIOR_EXPLANATION" = "You will no longer receive messages or updates from this group.";

Loading…
Cancel
Save