From 734dec12e9e6454699469256b845789111725130 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 7 Feb 2017 17:33:13 -0500 Subject: [PATCH] Respond to CR. // FREEBIE --- Signal/src/call/CallService.swift | 6 +++--- Signal/src/call/OutboundCallInitiator.swift | 16 ++++++++-------- .../CallInterstitialViewController.swift | 19 ++++++++++++------- .../view controllers/SignalsViewController.m | 7 ++----- .../translations/en.lproj/Localizable.strings | 3 --- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index dccb9d164..6eff5c5be 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -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 diff --git a/Signal/src/call/OutboundCallInitiator.swift b/Signal/src/call/OutboundCallInitiator.swift index 0ccfff931..bd741f0e8 100644 --- a/Signal/src/call/OutboundCallInitiator.swift +++ b/Signal/src/call/OutboundCallInitiator.swift @@ -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() diff --git a/Signal/src/view controllers/CallInterstitialViewController.swift b/Signal/src/view controllers/CallInterstitialViewController.swift index 550cb40c8..3b07dab79 100644 --- a/Signal/src/view controllers/CallInterstitialViewController.swift +++ b/Signal/src/view controllers/CallInterstitialViewController.swift @@ -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() + } } diff --git a/Signal/src/view controllers/SignalsViewController.m b/Signal/src/view controllers/SignalsViewController.m index 672df503a..cb0c33f32 100644 --- a/Signal/src/view controllers/SignalsViewController.m +++ b/Signal/src/view controllers/SignalsViewController.m @@ -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(); } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 10d62d124..d6b150d95 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -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";