Merge branch 'charlesmchen/mainWindow' into hotfix/2.23.4

pull/1/head
Matthew Chen 7 years ago
commit 7d7981e823

@ -168,12 +168,12 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
return YES; return YES;
} }
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIWindow *mainWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = mainWindow;
CurrentAppContext().mainWindow = mainWindow;
// Show the launch screen until the async database view registrations are complete. // Show the launch screen until the async database view registrations are complete.
self.window.rootViewController = [self loadingRootViewController]; mainWindow.rootViewController = [self loadingRootViewController];
[mainWindow makeKeyAndVisible];
[self.window makeKeyAndVisible];
// performUpdateCheck must be invoked after Environment has been initialized because // performUpdateCheck must be invoked after Environment has been initialized because
// upgrade process may depend on Environment. // upgrade process may depend on Environment.

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -7,16 +7,19 @@ import Foundation
extension UIApplication { extension UIApplication {
var frontmostViewControllerIgnoringAlerts: UIViewController? { var frontmostViewControllerIgnoringAlerts: UIViewController? {
return findFrontmostViewController(ignoringAlerts:true) return findFrontmostViewController(ignoringAlerts: true)
} }
var frontmostViewController: UIViewController? { var frontmostViewController: UIViewController? {
return findFrontmostViewController(ignoringAlerts:false) return findFrontmostViewController(ignoringAlerts: false)
} }
internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? { internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? {
let window = UIApplication.shared.keyWindow guard let window = CurrentAppContext().mainWindow else {
guard let viewController = window!.rootViewController else { return nil
}
Logger.error("findFrontmostViewController: \(window)")
guard let viewController = window.rootViewController else {
owsFail("\(self.logTag) in \(#function) Missing root view controller.") owsFail("\(self.logTag) in \(#function) Missing root view controller.")
return nil return nil
} }

@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
@implementation MainAppContext @implementation MainAppContext
@synthesize mainWindow = _mainWindow;
- (instancetype)init - (instancetype)init
{ {
self = [super init]; self = [super init];
@ -174,11 +176,6 @@ NS_ASSUME_NONNULL_BEGIN
return UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts; return UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
} }
- (nullable UIView *)rootReferenceView
{
return UIApplication.sharedApplication.keyWindow;
}
- (nullable UIAlertAction *)openSystemSettingsAction - (nullable UIAlertAction *)openSystemSettingsAction
{ {
return [UIAlertAction actionWithTitle:CommonStrings.openSettingsButton return [UIAlertAction actionWithTitle:CommonStrings.openSettingsButton

@ -29,8 +29,7 @@ typedef void (^BackgroundTaskExpirationHandler)(void);
@property (nonatomic, readonly) BOOL isRunningTests; @property (nonatomic, readonly) BOOL isRunningTests;
// Useful for translating coordinates to the "entire screen" @property (atomic, nullable) UIWindow *mainWindow;
@property (nonatomic, readonly, nullable) UIView *rootReferenceView;
// Should only be called if isMainApp is YES. // Should only be called if isMainApp is YES.
// //

@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
@implementation ShareAppExtensionContext @implementation ShareAppExtensionContext
@synthesize mainWindow = _mainWindow;
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController - (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{ {
self = [super init]; self = [super init];
@ -172,11 +174,6 @@ NS_ASSUME_NONNULL_BEGIN
return [self.rootViewController findFrontmostViewController:YES]; return [self.rootViewController findFrontmostViewController:YES];
} }
- (nullable UIView *)rootReferenceView
{
return self.rootViewController.view;
}
- (nullable UIAlertAction *)openSystemSettingsAction - (nullable UIAlertAction *)openSystemSettingsAction
{ {
return nil; return nil;

Loading…
Cancel
Save