Merge branch 'mkirk/fix-cold-call-from-contacts'

pull/1/head
Michael Kirk 7 years ago
commit 7a2ad91940

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

@ -95,7 +95,6 @@
<outlet property="hideMissingContactsPermissionViewConstraint" destination="b7U-Ma-c6S" id="bcT-sh-weS"/>
<outlet property="missingContactsPermissionView" destination="7iZ-hQ-Iik" id="aWf-NH-kn6"/>
<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>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dE8-zB-mtF" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -150,23 +149,6 @@
</objects>
<point key="canvasLocation" x="-2287" y="-1516"/>
</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-->
<scene sceneID="miN-Ma-3eR">
<objects>

@ -8,7 +8,6 @@ import PromiseKit
// TODO: Add category so that button handlers can be defined where button is created.
// TODO: Ensure buttons enabled & disabled as necessary.
@objc(OWSCallViewController)
class CallViewController: UIViewController, CallObserver, CallServiceObserver, RTCEAGLVideoViewDelegate {
let TAG = "[CallViewController]"
@ -147,7 +146,11 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
createViews()
contactNameLabel.text = contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier())
contactAvatarView.image = OWSAvatarBuilder.buildImage(for: thread, contactsManager: contactsManager, diameter:400)
updateAvatarImage()
NotificationCenter.default.addObserver(forName: .OWSContactsManagerSignalAccountsDidChange, object: nil, queue: nil) { _ in
Logger.info("\(self.TAG) updating avatar image")
self.updateAvatarImage()
}
assert(call != nil)
// Subscribe for future call updates
@ -315,6 +318,10 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
button.setImage(image, for:.selected)
}
func updateAvatarImage() {
contactAvatarView.image = OWSAvatarBuilder.buildImage(for: thread, contactsManager: contactsManager, diameter:400)
}
func createIncomingCallControls() {
acceptIncomingButton = createButton(imageName:"call-active-wide",

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

@ -248,15 +248,6 @@ protocol CallServiceObserver: class {
self.callUIAdapter = CallUIAdapter(callService: self, contactsManager: self.contactsManager, notificationsAdapter: self.notificationsAdapter)
}
// MARK: - Class Methods
// MARK: Notifications
// Wrapping these class constants in a method to make it accessible to objc
class func callServiceActiveCallNotificationName() -> String {
return "CallServiceActiveCallNotification"
}
// MARK: - Service Actions
/**

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

@ -34,8 +34,22 @@ extension CallUIAdaptee {
internal func showCall(_ call: SignalCall) {
AssertIsOnMainThread()
let callNotificationName = CallService.callServiceActiveCallNotificationName()
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
guard let presentingViewController = Environment.getCurrent().signalsViewController else {
Logger.error("in \(#function) view controller unexpectedly nil")
assertionFailure("in \(#function) 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) {

Loading…
Cancel
Save