From 5739f074ae85d7cb99d1e4e1bc49453ee6bca27e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 12:27:04 -0500 Subject: [PATCH] Show migration screen at first launch. sort sounds alphabetically (other than Default/None) // FREEBIE --- ...ExperienceUpgradesPageViewController.swift | 4 +-- .../src/ViewControllers/HomeViewController.m | 29 ++++++++++--------- SignalMessaging/environment/OWSSounds.m | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index 8d8b2bc634..e84bd77337 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -44,8 +44,8 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: let button = addButton(title: buttonTitle) { _ in // dismiss the modally presented view controller, then proceed. self.experienceUpgradesPageViewController.dismiss(animated: true) { - guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else { - owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))") + guard let fromViewController = UIApplication.shared.frontmostViewController else { + owsFail("frontmostViewController was unexectedly nil") return } diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index fd6148776f..a760a5b71e 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -287,6 +287,22 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; [self updateBarButtonItems]; } +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + // Keep in mind viewDidAppear is called while the app is in the background if the app was + // launched by a voip notification. This is fine - it will remain visible to the user + // when they eventually launch the app, but we shouldn't make any changes assuming + // the user has *seen* the upgrade experience at this point. + if (!self.hasShownAnyUnseenUpgradeExperiences) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self displayAnyUnseenUpgradeExperience]; + self.hasShownAnyUnseenUpgradeExperiences = YES; + }); + } +} + - (void)updateBarButtonItems { const CGFloat kBarButtonSize = 44; @@ -510,19 +526,6 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; }); }]; } - - // We want to show the user the upgrade experience as soon as the app is visible to them. - // It cannot go in viewDidAppear, which is called while the app is in the background if - // we were launched from a voip notification. - if (!self.hasShownAnyUnseenUpgradeExperiences) { - dispatch_async(dispatch_get_main_queue(), ^{ - if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) { - return; - } - [self displayAnyUnseenUpgradeExperience]; - self.hasShownAnyUnseenUpgradeExperiences = YES; - }); - } } #pragma mark - startup diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 60acb38718..a29b16c775 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -74,8 +74,8 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @(OWSSound_Keys), @(OWSSound_Popcorn), @(OWSSound_Pulse), - @(OWSSound_Synth), @(OWSSound_ClassicNotification), + @(OWSSound_Synth), ]; }