Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent c43063e1d6
commit 734dec12e9

@ -251,15 +251,15 @@ protocol CallServiceObserver: class {
} }
class func presentCallInterstitialNotificationName() -> String { class func presentCallInterstitialNotificationName() -> String {
return "PresentCallInterstitialNotification" return "CallServicePresentCallInterstitialNotification"
} }
class func dismissCallInterstitialNotificationName() -> String { class func dismissCallInterstitialNotificationName() -> String {
return "DismissCallInterstitialNotification" return "CallServiceDismissCallInterstitialNotification"
} }
class func callWasCancelledByInterstitialNotificationName() -> String { class func callWasCancelledByInterstitialNotificationName() -> String {
return "CallWasCancelledByInterstitialNotification" return "CallServiceCallWasCancelledByInterstitialNotification"
} }
// MARK: - Service Actions // MARK: - Service Actions

@ -38,10 +38,10 @@ import Foundation
AssertIsOnMainThread() AssertIsOnMainThread()
let callToken = notification.object as! String let callToken = notification.object as! String
cancelCallToken(callToken) cancelCallToken(callToken:callToken)
} }
func cancelCallToken(_ callToken: String) { func cancelCallToken(callToken: String) {
AssertIsOnMainThread() AssertIsOnMainThread()
cancelledCallTokens.append(callToken) cancelledCallTokens.append(callToken)
@ -72,7 +72,7 @@ import Foundation
// A temporary unique id used to identify this call during the // A temporary unique id used to identify this call during the
let callToken = NSUUID().uuidString let callToken = NSUUID().uuidString
presentCallInterstitial(callToken) presentCallInterstitial(callToken:callToken)
// Since users can toggle this setting, which is only communicated during contact sync, it's easy to imagine the // Since users can toggle this setting, which is only communicated during contact sync, it's easy to imagine the
// preference getting stale. Especially as users are toggling the feature to test calls. So here, we opt for a // preference getting stale. Especially as users are toggling the feature to test calls. So here, we opt for a
@ -83,7 +83,7 @@ import Foundation
self.contactsUpdater.lookupIdentifier(recipientId, self.contactsUpdater.lookupIdentifier(recipientId,
success: { recipient in success: { recipient in
guard !self.cancelledCallTokens.contains(callToken) else { guard !self.cancelledCallTokens.contains(callToken) else {
Logger.error("\(self.TAG) OutboundCallInitiator aborting due to cancelled call.") Logger.info("\(self.TAG) OutboundCallInitiator aborting due to cancelled call.")
return return
} }
@ -108,8 +108,8 @@ import Foundation
failure: { error in failure: { error in
Logger.warn("\(self.TAG) looking up recipientId: \(recipientId) failed with error \(error)") Logger.warn("\(self.TAG) looking up recipientId: \(recipientId) failed with error \(error)")
self.cancelCallToken(callToken) self.cancelCallToken(callToken:callToken)
self.dismissCallInterstitial(callToken) self.dismissCallInterstitial(callToken:callToken)
let alertTitle = NSLocalizedString("UNABLE_TO_PLACE_CALL", comment:"Alert Title") let alertTitle = NSLocalizedString("UNABLE_TO_PLACE_CALL", comment:"Alert Title")
let alertController = UIAlertController(title: alertTitle, message: error.localizedDescription, preferredStyle: .alert) let alertController = UIAlertController(title: alertTitle, message: error.localizedDescription, preferredStyle: .alert)
@ -150,14 +150,14 @@ import Foundation
return true return true
} }
private func presentCallInterstitial(_ callToken: String) { private func presentCallInterstitial(callToken: String) {
AssertIsOnMainThread() AssertIsOnMainThread()
let notificationName = CallService.presentCallInterstitialNotificationName() let notificationName = CallService.presentCallInterstitialNotificationName()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: notificationName), object: callToken) NotificationCenter.default.post(name: NSNotification.Name(rawValue: notificationName), object: callToken)
} }
private func dismissCallInterstitial(_ callToken: String) { private func dismissCallInterstitial(callToken: String) {
AssertIsOnMainThread() AssertIsOnMainThread()
let notificationName = CallService.dismissCallInterstitialNotificationName() let notificationName = CallService.dismissCallInterstitialNotificationName()

@ -10,7 +10,7 @@ class CallInterstitialViewController: UIViewController {
let TAG = "[CallInterstitialViewController]" let TAG = "[CallInterstitialViewController]"
var wasCallCancelled = false var wasCallCancelled = false
var callToken: String? let callToken: String!
// MARK: Views // MARK: Views
@ -20,12 +20,15 @@ class CallInterstitialViewController: UIViewController {
// MARK: Initializers // MARK: Initializers
@available(*, unavailable, message:"init is unavailable, use initWithCallToken")
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
assert(false) assert(false)
self.callToken = ""
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
required init() { required init(callToken: String) {
self.callToken = callToken
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
observeNotifications() observeNotifications()
} }
@ -102,7 +105,7 @@ class CallInterstitialViewController: UIViewController {
contentView.addSubview(dialingLabel) contentView.addSubview(dialingLabel)
let cancelCallButton = UIButton() let cancelCallButton = UIButton()
cancelCallButton.setTitle(NSLocalizedString("CALL_INTERSTITIAL_CANCEL_BUTTON", comment: "Label for cancel button on call interstitial view"), cancelCallButton.setTitle(NSLocalizedString("TXT_CANCEL_TITLE", comment: "nil"),
for:.normal) for:.normal)
cancelCallButton.setTitleColor(UIColor.white, for:.normal) cancelCallButton.setTitleColor(UIColor.white, for:.normal)
cancelCallButton.titleLabel?.font = UIFont.ows_lightFont(withSize:ScaleFromIPhone5To7Plus(26, 32)) cancelCallButton.titleLabel?.font = UIFont.ows_lightFont(withSize:ScaleFromIPhone5To7Plus(26, 32))
@ -122,10 +125,6 @@ class CallInterstitialViewController: UIViewController {
cancelCallButton.autoPinEdge(toSuperviewEdge:.bottom, withInset:ScaleFromIPhone5To7Plus(23, 41)) cancelCallButton.autoPinEdge(toSuperviewEdge:.bottom, withInset:ScaleFromIPhone5To7Plus(23, 41))
} }
func cancelCallButtonPressed(sender button: UIButton) {
cancelCall()
}
// MARK: - Layout // MARK: - Layout
override func updateViewConstraints() { override func updateViewConstraints() {
@ -163,4 +162,10 @@ class CallInterstitialViewController: UIViewController {
self.dismiss(animated: false) self.dismiss(animated: false)
} }
// MARK: - Events
func cancelCallButtonPressed(sender button: UIButton) {
cancelCall()
}
} }

@ -165,8 +165,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
NSString *callToken = notification.object; NSString *callToken = notification.object;
OWSAssert(callToken != nil); OWSAssert(callToken != nil);
OWSCallInterstitialViewController *viewController = [OWSCallInterstitialViewController new]; OWSCallInterstitialViewController *viewController = [[OWSCallInterstitialViewController alloc] initWithCallToken:callToken];
viewController.callToken = callToken;
void(^presentInterstitial)() = ^{ void(^presentInterstitial)() = ^{
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen; viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
@ -177,9 +176,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
// Dismiss any other modals so we can present call modal. // Dismiss any other modals so we can present call modal.
if (self.presentedViewController) { if (self.presentedViewController) {
[self dismissViewControllerAnimated:YES completion:^{ [self dismissViewControllerAnimated:YES completion:presentInterstitial];
presentInterstitial();
}];
} else { } else {
presentInterstitial(); presentInterstitial();
} }

@ -73,9 +73,6 @@
/* Title for call interstitial view */ /* Title for call interstitial view */
"CALL_INTERSTITIAL_CALLING_LABEL" = "Calling..."; "CALL_INTERSTITIAL_CALLING_LABEL" = "Calling...";
/* Label for cancel button on call interstitial view */
"CALL_INTERSTITIAL_CANCEL_BUTTON" = "Cancel";
/* Accessibilty label for placing call button */ /* Accessibilty label for placing call button */
"CALL_LABEL" = "Call"; "CALL_LABEL" = "Call";

Loading…
Cancel
Save