From 0429836ff9d987969c4d9c60e64a26c0ba76f652 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 7 Dec 2017 10:39:15 -0500 Subject: [PATCH] CR: rename keyWindow -> keyReferenceView, split long line // FREEBIE --- Signal/src/util/MainAppContext.m | 2 +- SignalMessaging/attachments/FullImageViewController.m | 2 +- SignalMessaging/attachments/MediaMessageView.swift | 2 +- SignalServiceKit/src/Util/AppContext.h | 2 +- SignalShareExtension/ShareViewController.swift | 3 ++- SignalShareExtension/utils/ShareAppExtensionContext.m | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Signal/src/util/MainAppContext.m b/Signal/src/util/MainAppContext.m index 7bc5b7bbd..15c1273b2 100644 --- a/Signal/src/util/MainAppContext.m +++ b/Signal/src/util/MainAppContext.m @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN return UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts; } -- (UIView *)keyWindow +- (nullable UIView *)rootReferenceView { return UIApplication.sharedApplication.keyWindow; } diff --git a/SignalMessaging/attachments/FullImageViewController.m b/SignalMessaging/attachments/FullImageViewController.m index fac409e6a..1dbad385c 100644 --- a/SignalMessaging/attachments/FullImageViewController.m +++ b/SignalMessaging/attachments/FullImageViewController.m @@ -383,7 +383,7 @@ NS_ASSUME_NONNULL_BEGIN presentViewController:self animated:NO completion:^{ - UIView *window = CurrentAppContext().keyWindow; + UIView *window = CurrentAppContext().rootReferenceView; // During the presentation animation, we want to seamlessly animate the image // from its location in the conversation view. To do so, we need a // consistent coordinate system, so we pass the `originRect` in the diff --git a/SignalMessaging/attachments/MediaMessageView.swift b/SignalMessaging/attachments/MediaMessageView.swift index 7399497dc..d8e60e33b 100644 --- a/SignalMessaging/attachments/MediaMessageView.swift +++ b/SignalMessaging/attachments/MediaMessageView.swift @@ -426,7 +426,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { return } - let window = CurrentAppContext().keyWindow + let window = CurrentAppContext().rootReferenceView let convertedRect = fromView.convert(fromView.bounds, to:window) let viewController = FullImageViewController(attachment:attachment, from:convertedRect) viewController.present(from:fromViewController) diff --git a/SignalServiceKit/src/Util/AppContext.h b/SignalServiceKit/src/Util/AppContext.h index bf3e92061..8e5c99953 100755 --- a/SignalServiceKit/src/Util/AppContext.h +++ b/SignalServiceKit/src/Util/AppContext.h @@ -19,7 +19,7 @@ typedef void (^BackgroundTaskExpirationHandler)(void); @property (nonatomic, readonly) BOOL isRunningTests; // Useful for translating coordinates to the "entire screen" -@property (nonatomic, readonly) UIView *keyWindow; +@property (nonatomic, readonly, nullable) UIView *rootReferenceView; // Should only be called if isMainApp is YES. // diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index 47a235fa6..23d4e7630 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -355,7 +355,8 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S self.setViewControllers([conversationPicker], animated: true) Logger.info("showing picker with attachment: \(attachment)") }.catch { error in - OWSAlerts.showAlert(withTitle: NSLocalizedString("SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details."), + let alertTitle = NSLocalizedString("SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details.") + OWSAlerts.showAlert(withTitle: alertTitle, message: error.localizedDescription, buttonTitle: CommonStrings.cancelButton) { _ in self.shareExtensionWasCancelled() diff --git a/SignalShareExtension/utils/ShareAppExtensionContext.m b/SignalShareExtension/utils/ShareAppExtensionContext.m index d6ca2d524..a28a8491f 100644 --- a/SignalShareExtension/utils/ShareAppExtensionContext.m +++ b/SignalShareExtension/utils/ShareAppExtensionContext.m @@ -92,7 +92,7 @@ NS_ASSUME_NONNULL_BEGIN return [self.rootViewController findFrontmostViewController:YES]; } -- (UIView *)keyWindow +- (nullable UIView *)rootReferenceView { return self.rootViewController.view; }