Use supportedInterfaceOrientations to force calls to portrait
Previously this used UIDevice.ows_setOrientation, an undocumented hack to basically lie to the device about which way is up. This sounds sketchy, but it's the result of a lot of testing various solutions for something that could reliably force the app into portrait orientation. However, every UIWindow has its own "supported orientations", provided by the root view controller. And calls are implemented in their own UIWindow (so that they don't disrupt whatever you were doing). So for *calls specifically*, we can use supportedInterfaceOrientations to force the app into portrait mode. All other callers of UIDevice.ows_setOrientation work in the shared main window, so they'll be left alone. This only changes things for the call window.
This commit is contained in:
parent
37fad63c7a
commit
856ced4062
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSWindowManager.h"
|
||||
@ -53,19 +53,19 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSWindowRootNavigationViewController : UINavigationController
|
||||
@interface OWSCallWindowRootNavigationViewController : UINavigationController
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSWindowRootNavigationViewController : UINavigationController
|
||||
@implementation OWSCallWindowRootNavigationViewController : UINavigationController
|
||||
|
||||
#pragma mark - Orientation
|
||||
|
||||
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||
{
|
||||
return UIDevice.currentDevice.defaultSupportedOrientations;
|
||||
return UIDevice.currentDevice.isIPad ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskPortrait;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -167,8 +167,8 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
||||
// It adjusts the size of the navigation bar to reflect the
|
||||
// call window. We don't want those adjustments made within
|
||||
// the call window itself.
|
||||
OWSWindowRootNavigationViewController *navigationController =
|
||||
[[OWSWindowRootNavigationViewController alloc] initWithRootViewController:viewController];
|
||||
OWSCallWindowRootNavigationViewController *navigationController =
|
||||
[[OWSCallWindowRootNavigationViewController alloc] initWithRootViewController:viewController];
|
||||
navigationController.navigationBarHidden = YES;
|
||||
OWSAssertDebug(!self.callNavigationController);
|
||||
self.callNavigationController = navigationController;
|
||||
@ -238,11 +238,7 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
||||
[self.callNavigationController popToRootViewControllerAnimated:NO];
|
||||
[self.callNavigationController pushViewController:callViewController animated:NO];
|
||||
self.shouldShowCallView = YES;
|
||||
// CallViewController only supports portrait for iPhones, but if we're _already_ landscape it won't
|
||||
// automatically switch.
|
||||
if (!UIDevice.currentDevice.isIPad) {
|
||||
[UIDevice.currentDevice ows_setOrientation:UIDeviceOrientationPortrait];
|
||||
}
|
||||
|
||||
[self ensureWindowState];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user