Merge remote-tracking branch 'origin/hotfix/2.23.4'

pull/1/head
Matthew Chen 6 years ago
commit eb51ea42e3

@ -168,12 +168,12 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
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.
self.window.rootViewController = [self loadingRootViewController];
[self.window makeKeyAndVisible];
mainWindow.rootViewController = [self loadingRootViewController];
[mainWindow makeKeyAndVisible];
// performUpdateCheck must be invoked after Environment has been initialized because
// 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
@ -7,16 +7,19 @@ import Foundation
extension UIApplication {
var frontmostViewControllerIgnoringAlerts: UIViewController? {
return findFrontmostViewController(ignoringAlerts:true)
return findFrontmostViewController(ignoringAlerts: true)
}
var frontmostViewController: UIViewController? {
return findFrontmostViewController(ignoringAlerts:false)
return findFrontmostViewController(ignoringAlerts: false)
}
internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? {
let window = UIApplication.shared.keyWindow
guard let viewController = window!.rootViewController else {
guard let window = CurrentAppContext().mainWindow else {
return nil
}
Logger.error("findFrontmostViewController: \(window)")
guard let viewController = window.rootViewController else {
owsFail("\(self.logTag) in \(#function) Missing root view controller.")
return nil
}

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

@ -393,7 +393,8 @@ const UIWindowLevel UIWindowLevel_Background = -1.f;
buttonAction:^(UIAlertAction *action) {
// After the alert, re-show the unlock UI.
[self ensureUI];
}];
}
fromViewController:self.screenBlockingViewController];
}
// 'Screen Blocking' window obscures the app screen:

@ -34,11 +34,20 @@ import Foundation
@objc
public class func showAlert(title: String?, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil) {
guard let fromViewController = CurrentAppContext().frontmostViewController() else {
return
}
showAlert(title: title, message: message, buttonTitle: buttonTitle, buttonAction: buttonAction,
fromViewController: fromViewController)
}
@objc
public class func showAlert(title: String?, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil, fromViewController: UIViewController?) {
let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "")
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: buttonAction))
CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil)
fromViewController?.present(alert, animated: true, completion: nil)
}
@objc

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

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

Loading…
Cancel
Save