parent
c43063e1d6
commit
734dec12e9
|
@ -251,15 +251,15 @@ protocol CallServiceObserver: class {
|
|||
}
|
||||
|
||||
class func presentCallInterstitialNotificationName() -> String {
|
||||
return "PresentCallInterstitialNotification"
|
||||
return "CallServicePresentCallInterstitialNotification"
|
||||
}
|
||||
|
||||
class func dismissCallInterstitialNotificationName() -> String {
|
||||
return "DismissCallInterstitialNotification"
|
||||
return "CallServiceDismissCallInterstitialNotification"
|
||||
}
|
||||
|
||||
class func callWasCancelledByInterstitialNotificationName() -> String {
|
||||
return "CallWasCancelledByInterstitialNotification"
|
||||
return "CallServiceCallWasCancelledByInterstitialNotification"
|
||||
}
|
||||
|
||||
// MARK: - Service Actions
|
||||
|
|
|
@ -38,10 +38,10 @@ import Foundation
|
|||
AssertIsOnMainThread()
|
||||
|
||||
let callToken = notification.object as! String
|
||||
cancelCallToken(callToken)
|
||||
cancelCallToken(callToken:callToken)
|
||||
}
|
||||
|
||||
func cancelCallToken(_ callToken: String) {
|
||||
func cancelCallToken(callToken: String) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
cancelledCallTokens.append(callToken)
|
||||
|
@ -72,7 +72,7 @@ import Foundation
|
|||
|
||||
// A temporary unique id used to identify this call during the
|
||||
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
|
||||
// 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,
|
||||
success: { recipient in
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,8 @@ import Foundation
|
|||
failure: { error in
|
||||
Logger.warn("\(self.TAG) looking up recipientId: \(recipientId) failed with error \(error)")
|
||||
|
||||
self.cancelCallToken(callToken)
|
||||
self.dismissCallInterstitial(callToken)
|
||||
self.cancelCallToken(callToken:callToken)
|
||||
self.dismissCallInterstitial(callToken:callToken)
|
||||
|
||||
let alertTitle = NSLocalizedString("UNABLE_TO_PLACE_CALL", comment:"Alert Title")
|
||||
let alertController = UIAlertController(title: alertTitle, message: error.localizedDescription, preferredStyle: .alert)
|
||||
|
@ -150,14 +150,14 @@ import Foundation
|
|||
return true
|
||||
}
|
||||
|
||||
private func presentCallInterstitial(_ callToken: String) {
|
||||
private func presentCallInterstitial(callToken: String) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
let notificationName = CallService.presentCallInterstitialNotificationName()
|
||||
NotificationCenter.default.post(name: NSNotification.Name(rawValue: notificationName), object: callToken)
|
||||
}
|
||||
|
||||
private func dismissCallInterstitial(_ callToken: String) {
|
||||
private func dismissCallInterstitial(callToken: String) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
let notificationName = CallService.dismissCallInterstitialNotificationName()
|
||||
|
|
|
@ -10,7 +10,7 @@ class CallInterstitialViewController: UIViewController {
|
|||
let TAG = "[CallInterstitialViewController]"
|
||||
|
||||
var wasCallCancelled = false
|
||||
var callToken: String?
|
||||
let callToken: String!
|
||||
|
||||
// MARK: Views
|
||||
|
||||
|
@ -20,12 +20,15 @@ class CallInterstitialViewController: UIViewController {
|
|||
|
||||
// MARK: Initializers
|
||||
|
||||
@available(*, unavailable, message:"init is unavailable, use initWithCallToken")
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
assert(false)
|
||||
self.callToken = ""
|
||||
super.init(coder: aDecoder)
|
||||
}
|
||||
|
||||
required init() {
|
||||
required init(callToken: String) {
|
||||
self.callToken = callToken
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
observeNotifications()
|
||||
}
|
||||
|
@ -102,7 +105,7 @@ class CallInterstitialViewController: UIViewController {
|
|||
contentView.addSubview(dialingLabel)
|
||||
|
||||
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)
|
||||
cancelCallButton.setTitleColor(UIColor.white, for:.normal)
|
||||
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))
|
||||
}
|
||||
|
||||
func cancelCallButtonPressed(sender button: UIButton) {
|
||||
cancelCall()
|
||||
}
|
||||
|
||||
// MARK: - Layout
|
||||
|
||||
override func updateViewConstraints() {
|
||||
|
@ -163,4 +162,10 @@ class CallInterstitialViewController: UIViewController {
|
|||
|
||||
self.dismiss(animated: false)
|
||||
}
|
||||
|
||||
// MARK: - Events
|
||||
|
||||
func cancelCallButtonPressed(sender button: UIButton) {
|
||||
cancelCall()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,8 +165,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
|
|||
NSString *callToken = notification.object;
|
||||
OWSAssert(callToken != nil);
|
||||
|
||||
OWSCallInterstitialViewController *viewController = [OWSCallInterstitialViewController new];
|
||||
viewController.callToken = callToken;
|
||||
OWSCallInterstitialViewController *viewController = [[OWSCallInterstitialViewController alloc] initWithCallToken:callToken];
|
||||
|
||||
void(^presentInterstitial)() = ^{
|
||||
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
|
@ -177,9 +176,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
|
|||
|
||||
// Dismiss any other modals so we can present call modal.
|
||||
if (self.presentedViewController) {
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
presentInterstitial();
|
||||
}];
|
||||
[self dismissViewControllerAnimated:YES completion:presentInterstitial];
|
||||
} else {
|
||||
presentInterstitial();
|
||||
}
|
||||
|
|
|
@ -73,9 +73,6 @@
|
|||
/* Title for call interstitial view */
|
||||
"CALL_INTERSTITIAL_CALLING_LABEL" = "Calling...";
|
||||
|
||||
/* Label for cancel button on call interstitial view */
|
||||
"CALL_INTERSTITIAL_CANCEL_BUTTON" = "Cancel";
|
||||
|
||||
/* Accessibilty label for placing call button */
|
||||
"CALL_LABEL" = "Call";
|
||||
|
||||
|
|
Loading…
Reference in New Issue