Present calls using window manager.

pull/1/head
Matthew Chen 7 years ago
parent 7345ab2e4e
commit 6a8796ad04

@ -1687,11 +1687,9 @@ protocol CallServiceObserver: class {
return return
} }
let frontmostViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts if !OWSWindowManager.shared().hasCall() {
guard nil != frontmostViewController as? CallViewController else {
OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file: #file, function: #function, line: #line) 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")) self.handleFailedCall(failedCall: call, error: CallError.assertionError(description: "Call view didn't present after \(kMaxViewPresentationDelay) seconds"))
return return
} }

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

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

Loading…
Cancel
Save