restore calling banner

The `statusBarDidChange` is called when entering but not leaving landscape mode
we we've got to update manually before showing the call banner.
This commit is contained in:
Michael Kirk 2018-10-25 11:46:48 -06:00
parent 19f2d0db48
commit 85a4fc7b66
2 changed files with 29 additions and 8 deletions

View File

@ -48,7 +48,7 @@ public class OWSNavigationBar: UINavigationBar {
applyTheme()
NotificationCenter.default.addObserver(self, selector: #selector(callDidChange), name: .OWSWindowManagerCallDidChange, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatusBarFrame), name: .UIApplicationDidChangeStatusBarFrame, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatusBarFrame), name: .UIApplicationDidChangeStatusBarFrame, object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(themeDidChange),
name: .ThemeDidChange,

View File

@ -19,7 +19,6 @@ const CGFloat OWSWindowManagerCallBannerHeight(void)
return CurrentAppContext().statusBarHeight + 20;
}
if (![UIDevice currentDevice].hasIPhoneXNotch) {
return CurrentAppContext().statusBarHeight + 20;
}
@ -100,6 +99,21 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
@end
@interface OWSWindowRootNavigationViewController : UINavigationController
@end
@implementation OWSWindowRootNavigationViewController : UINavigationController
#pragma mark - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
#pragma mark -
@interface OWSWindowManager () <ReturnToCallViewControllerDelegate>
@ -185,11 +199,18 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
}
- (void)didChangeStatusBarFrame:(NSNotification *)notification
{
// Apple bug? Upon returning from landscape, this method *is* fired, but both the notification and [UIApplication
// sharedApplication].statusBarFrame still show a height of 0. So to work around we also call
// `ensureReturnToCallWindowFrame` before showing the call banner.
[self ensureReturnToCallWindowFrame];
}
- (void)ensureReturnToCallWindowFrame
{
CGRect newFrame = self.returnToCallWindow.frame;
newFrame.size.height = OWSWindowManagerCallBannerHeight();
OWSLogDebug(@"StatusBar changed frames - updating returnToCallWindowFrame: %@", NSStringFromCGRect(newFrame));
OWSLogDebug(@"returnToCallWindowFrame: %@", NSStringFromCGRect(newFrame));
self.returnToCallWindow.frame = newFrame;
}
@ -260,14 +281,13 @@ const UIWindowLevel UIWindowLevel_MessageActions(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.
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:viewController];
OWSWindowRootNavigationViewController *navigationController =
[[OWSWindowRootNavigationViewController alloc] initWithRootViewController:viewController];
navigationController.navigationBarHidden = YES;
OWSAssertDebug(!self.callNavigationController);
self.callNavigationController = navigationController;
// MJK DO NOT COMMIT.
window.rootViewController = viewController;
window.rootViewController = navigationController;
return window;
}
@ -478,6 +498,7 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
return;
}
[self ensureReturnToCallWindowFrame];
OWSLogInfo(@"showing 'return to call' window.");
self.returnToCallWindow.hidden = NO;
[self.returnToCallViewController startAnimating];