WIP: fix call from contacts when signal hasn't been launched yet

pull/1/head
Michael Kirk 8 years ago
parent 59d3e9ed51
commit ff93732ed7

@ -22,6 +22,7 @@
#import "PropertyListPreferences.h" #import "PropertyListPreferences.h"
#import "PushManager.h" #import "PushManager.h"
#import "SettingsTableViewController.h" #import "SettingsTableViewController.h"
#import "SignalsViewController.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIUtil.h" #import "UIUtil.h"

@ -95,7 +95,6 @@
<outlet property="hideMissingContactsPermissionViewConstraint" destination="b7U-Ma-c6S" id="bcT-sh-weS"/> <outlet property="hideMissingContactsPermissionViewConstraint" destination="b7U-Ma-c6S" id="bcT-sh-weS"/>
<outlet property="missingContactsPermissionView" destination="7iZ-hQ-Iik" id="aWf-NH-kn6"/> <outlet property="missingContactsPermissionView" destination="7iZ-hQ-Iik" id="aWf-NH-kn6"/>
<outlet property="tableView" destination="PaA-ol-uQT" id="nQU-tR-wbL"/> <outlet property="tableView" destination="PaA-ol-uQT" id="nQU-tR-wbL"/>
<segue destination="Tyf-mN-gzf" kind="modal" identifier="ShowIncomingCallSegue" id="G2B-Fr-Ezs"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dE8-zB-mtF" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dE8-zB-mtF" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -150,23 +149,6 @@
</objects> </objects>
<point key="canvasLocation" x="-2287" y="-1516"/> <point key="canvasLocation" x="-2287" y="-1516"/>
</scene> </scene>
<!--New Call-->
<scene sceneID="Xck-Ph-UlV">
<objects>
<viewController storyboardIdentifier="OWSCallViewController" title="New Call" definesPresentationContext="YES" modalTransitionStyle="crossDissolve" modalPresentationStyle="currentContext" id="Tyf-mN-gzf" customClass="OWSCallViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="0w2-kv-AfM"/>
<viewControllerLayoutGuide type="bottom" id="d8M-LU-Hfa"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="fjB-Ns-OQs">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5mi-rT-gg5" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1790" y="-2348"/>
</scene>
<!--Signals Navigation Controller--> <!--Signals Navigation Controller-->
<scene sceneID="miN-Ma-3eR"> <scene sceneID="miN-Ma-3eR">
<objects> <objects>

@ -8,7 +8,6 @@ import PromiseKit
// TODO: Add category so that button handlers can be defined where button is created. // TODO: Add category so that button handlers can be defined where button is created.
// TODO: Ensure buttons enabled & disabled as necessary. // TODO: Ensure buttons enabled & disabled as necessary.
@objc(OWSCallViewController)
class CallViewController: UIViewController, CallObserver, CallServiceObserver, RTCEAGLVideoViewDelegate { class CallViewController: UIViewController, CallObserver, CallServiceObserver, RTCEAGLVideoViewDelegate {
let TAG = "[CallViewController]" let TAG = "[CallViewController]"

@ -31,7 +31,7 @@
#define CELL_HEIGHT 72.0f #define CELL_HEIGHT 72.0f
#define HEADER_HEIGHT 44.0f #define HEADER_HEIGHT 44.0f
NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallSegue"; // NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallSegue";
@interface SignalsViewController () @interface SignalsViewController ()
@ -195,12 +195,12 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
(self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) { (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {
[self registerForPreviewingWithDelegate:self sourceView:self.tableView]; [self registerForPreviewingWithDelegate:self sourceView:self.tableView];
} }
[[NSNotificationCenter defaultCenter] addObserver:self // [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleActiveCallNotification:) // selector:@selector(handleActiveCallNotification:)
name:[CallService callServiceActiveCallNotificationName] // name:[CallService callServiceActiveCallNotificationName]
object:nil]; // object:nil];
//
[self updateBarButtonItems]; [self updateBarButtonItems];
} }
@ -260,29 +260,30 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
} }
} }
- (void)handleActiveCallNotification:(NSNotification *)notification //- (void)handleActiveCallNotification:(NSNotification *)notification
{ //{
AssertIsOnMainThread(); // // TODO insteead at the callsite lets present as topmost VC
// AssertIsOnMainThread();
if (![notification.object isKindOfClass:[SignalCall class]]) { //
DDLogError(@"%@ expected presentCall observer to be notified with a SignalCall, but found %@", // if (![notification.object isKindOfClass:[SignalCall class]]) {
self.tag, // DDLogError(@"%@ expected presentCall observer to be notified with a SignalCall, but found %@",
notification.object); // self.tag,
return; // notification.object);
} // return;
// }
SignalCall *call = (SignalCall *)notification.object; //
// SignalCall *call = (SignalCall *)notification.object;
// Dismiss any other modals so we can present call modal. //
if (self.presentedViewController) { // // Dismiss any other modals so we can present call modal.
[self dismissViewControllerAnimated:YES // if (self.presentedViewController) {
completion:^{ // [self dismissViewControllerAnimated:YES
[self performSegueWithIdentifier:SignalsViewControllerSegueShowIncomingCall sender:call]; // completion:^{
}]; // [self performSegueWithIdentifier:SignalsViewControllerSegueShowIncomingCall sender:call];
} else { // }];
[self performSegueWithIdentifier:SignalsViewControllerSegueShowIncomingCall sender:call]; // } else {
} // [self performSegueWithIdentifier:SignalsViewControllerSegueShowIncomingCall sender:call];
} // }
//}
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
commitViewController:(UIViewController *)viewControllerToCommit { commitViewController:(UIViewController *)viewControllerToCommit {
@ -727,25 +728,25 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
#pragma mark - Navigation #pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { //- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:SignalsViewControllerSegueShowIncomingCall]) { // if ([segue.identifier isEqualToString:SignalsViewControllerSegueShowIncomingCall]) {
DDLogDebug(@"%@ preparing for incoming call segue", self.tag); // DDLogDebug(@"%@ preparing for incoming call segue", self.tag);
if (![segue.destinationViewController isKindOfClass:[OWSCallViewController class]]) { // if (![segue.destinationViewController isKindOfClass:[OWSCallViewController class]]) {
DDLogError(@"%@ Received unexpected destination view controller: %@", self.tag, segue.destinationViewController); // DDLogError(@"%@ Received unexpected destination view controller: %@", self.tag,
return; // segue.destinationViewController); return;
} // }
OWSCallViewController *callViewController = (OWSCallViewController *)segue.destinationViewController; // OWSCallViewController *callViewController = (OWSCallViewController *)segue.destinationViewController;
//
if (![sender isKindOfClass:[SignalCall class]]) { // if (![sender isKindOfClass:[SignalCall class]]) {
DDLogError(@"%@ expecting call segueu to be sent by a SignalCall, but found: %@", self.tag, sender); // DDLogError(@"%@ expecting call segueu to be sent by a SignalCall, but found: %@", self.tag, sender);
return; // return;
} // }
SignalCall *call = (SignalCall *)sender; // SignalCall *call = (SignalCall *)sender;
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber]; // TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
callViewController.thread = thread; // callViewController.thread = thread;
callViewController.call = call; // callViewController.call = call;
} // }
} //}
#pragma mark - IBAction #pragma mark - IBAction

@ -253,9 +253,9 @@ protocol CallServiceObserver: class {
// MARK: Notifications // MARK: Notifications
// Wrapping these class constants in a method to make it accessible to objc // Wrapping these class constants in a method to make it accessible to objc
class func callServiceActiveCallNotificationName() -> String { // class func callServiceActiveCallNotificationName() -> String {
return "CallServiceActiveCallNotification" // return "CallServiceActiveCallNotification"
} // }
// MARK: - Service Actions // MARK: - Service Actions

@ -42,8 +42,9 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
Logger.debug("\(TAG) \(#function)") Logger.debug("\(TAG) \(#function)")
// present Call View controller // present Call View controller
let callNotificationName = CallService.callServiceActiveCallNotificationName() // let callNotificationName = CallService.callServiceActiveCallNotificationName()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: callNotificationName), object: call) // NotificationCenter.default.post(name: NSNotification.Name(rawValue: callNotificationName), object: call)
self.showCall(call)
// present lock screen notification // present lock screen notification
if UIApplication.shared.applicationState == .active { if UIApplication.shared.applicationState == .active {

@ -34,8 +34,30 @@ extension CallUIAdaptee {
internal func showCall(_ call: SignalCall) { internal func showCall(_ call: SignalCall) {
AssertIsOnMainThread() AssertIsOnMainThread()
let callNotificationName = CallService.callServiceActiveCallNotificationName() // let callNotificationName = CallService.callServiceActiveCallNotificationName()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: callNotificationName), object: call) // NotificationCenter.default.post(name: NSNotification.Name(rawValue: callNotificationName), object: call)
let callViewController = CallViewController()
let thread = TSContactThread.getOrCreateThread(contactId: call.remotePhoneNumber)
callViewController.call = call
callViewController.thread = thread
callViewController.modalTransitionStyle = .crossDissolve
//Environment.getCurrent().signalsViewController
// TODO dismiss any modal, can/should we present from frontmost?
// let presentingViewController = UIApplication.shared.frontmostViewController
// presentingViewController?.present(callViewController, animated: true)
guard let presentingViewController = Environment.getCurrent().signalsViewController else {
Logger.error("in \(#function) signals view controller unexpectedly nil")
assertionFailure("in \(#function) signals view controller unexpectedly nil")
return
}
if let presentedViewController = presentingViewController.presentedViewController {
presentedViewController.dismiss(animated: false)
}
presentingViewController.present(callViewController, animated: true)
} }
internal func reportMissedCall(_ call: SignalCall, callerName: String) { internal func reportMissedCall(_ call: SignalCall, callerName: String) {

Loading…
Cancel
Save