From 3be41e8c25a6f794a91b61bcfc1c81d8b117efea Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 26 Feb 2019 19:21:29 -0700 Subject: [PATCH] Unless you're on a call, all windows respect the orientation mask of the primary app visible VC. Fixes: - Avoid flicker when forgrounding onboarding while in landscape - Fix status bar in landscape while fingerprint is portrait, same with device linker --- Signal/src/AppDelegate.m | 13 +++++++++++-- .../ViewControllers/OWSNavigationController.m | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 31d0cf177..da68d29ec 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -967,13 +967,22 @@ static NSTimeInterval launchStartedAt; - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window { - if (self.windowManager.hasCall) { + if (self.hasCall) { OWSLogInfo(@"has call"); // The call-banner window is only suitable for portrait display return UIInterfaceOrientationMaskPortrait; } - return UIInterfaceOrientationMaskAllButUpsideDown; + UIViewController *_Nullable rootViewController = self.window.rootViewController; + if (!rootViewController) { + return UIInterfaceOrientationMaskAllButUpsideDown; + } + return rootViewController.supportedInterfaceOrientations; +} + +- (BOOL)hasCall +{ + return self.windowManager.hasCall; } #pragma mark Push Notifications Delegate Methods diff --git a/SignalMessaging/ViewControllers/OWSNavigationController.m b/SignalMessaging/ViewControllers/OWSNavigationController.m index 901cb1517..64fa3604b 100644 --- a/SignalMessaging/ViewControllers/OWSNavigationController.m +++ b/SignalMessaging/ViewControllers/OWSNavigationController.m @@ -199,8 +199,8 @@ NS_ASSUME_NONNULL_BEGIN - (UIInterfaceOrientationMask)supportedInterfaceOrientations { - if (self.topViewController) { - return self.topViewController.supportedInterfaceOrientations; + if (self.visibleViewController) { + return self.visibleViewController.supportedInterfaceOrientations; } else { return UIInterfaceOrientationMaskAllButUpsideDown; }