Present calls using window manager.

This commit is contained in:
Matthew Chen 2018-04-18 12:09:42 -04:00
parent 7345ab2e4e
commit 6a8796ad04
3 changed files with 18 additions and 11 deletions

View File

@ -1687,11 +1687,9 @@ protocol CallServiceObserver: class {
return
}
let frontmostViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts
guard nil != frontmostViewController as? CallViewController else {
if !OWSWindowManager.shared().hasCall() {
OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file: #file, function: #function, line: #line)
owsFail("\(self.logTag) in \(#function) Call terminated due to call view presentation delay: \(frontmostViewController.debugDescription).")
owsFail("\(self.logTag) in \(#function) Call terminated due to missing call view.")
self.handleFailedCall(failedCall: call, error: CallError.assertionError(description: "Call view didn't present after \(kMaxViewPresentationDelay) seconds"))
return
}

View File

@ -30,6 +30,7 @@ extern const UIWindowLevel UIWindowLevel_Background;
- (void)endCall:(UIViewController *)callViewController;
- (void)leaveCallView;
- (void)returnToCallView;
- (BOOL)hasCall;
@end

View File

@ -160,13 +160,10 @@ const int kReturnToCallWindowHeight = 40.f;
window.hidden = YES;
window.windowLevel = UIWindowLevel_CallView();
window.opaque = YES;
// TODO:
window.backgroundColor = UIColor.ows_materialBlueColor;
window.backgroundColor = [UIColor yellowColor];
window.backgroundColor = [UIColor ows_materialBlueColor];
UIViewController *viewController = [OWSWindowRootViewController new];
viewController.view.backgroundColor = UIColor.ows_materialBlueColor;
viewController.view.backgroundColor = [UIColor yellowColor];
viewController.view.backgroundColor = [UIColor ows_materialBlueColor];
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:viewController];
@ -196,7 +193,9 @@ const int kReturnToCallWindowHeight = 40.f;
self.callViewController = callViewController;
// Attach callViewController from window.
[self.callViewWindow.rootViewController.navigationController pushViewController:callViewController animated:NO];
OWSAssert([self.callViewWindow.rootViewController isKindOfClass:[UINavigationController class]]);
UINavigationController *navigationController = (UINavigationController *)self.callViewWindow.rootViewController;
[navigationController pushViewController:callViewController animated:NO];
self.isCallViewActive = YES;
[self ensureWindowState];
@ -214,7 +213,9 @@ const int kReturnToCallWindowHeight = 40.f;
}
// Dettach callViewController from window.
[self.callViewWindow.rootViewController.navigationController popToRootViewControllerAnimated:NO];
OWSAssert([self.callViewWindow.rootViewController isKindOfClass:[UINavigationController class]]);
UINavigationController *navigationController = (UINavigationController *)self.callViewWindow.rootViewController;
[navigationController popToRootViewControllerAnimated:NO];
self.callViewController = nil;
self.isCallViewActive = NO;
@ -243,6 +244,13 @@ const int kReturnToCallWindowHeight = 40.f;
[self ensureWindowState];
}
- (BOOL)hasCall
{
OWSAssertIsOnMainThread();
return self.callViewController != nil;
}
#pragma mark - Window State
- (void)ensureWindowState