show modal of ip exposure for calls

pull/560/head
ryanzhao 4 years ago
parent 7dfb999239
commit bcf0ecfb69

@ -320,14 +320,29 @@ final class CallVC : UIViewController, WebRTCSessionDelegate, VideoPreviewDelega
} }
} }
internal func showCallModal() {
let callModal = CallModal() { [weak self] in
self?.answerCall()
}
callModal.modalPresentationStyle = .overFullScreen
callModal.modalTransitionStyle = .crossDissolve
present(callModal, animated: true, completion: nil)
}
@objc private func answerCall() { @objc private func answerCall() {
if case let .answer(sdp) = mode { let userDefaults = UserDefaults.standard
callInfoLabel.text = "Connecting..." if userDefaults[.hasSeenCallIPExposureWarning] {
webRTCSession.handleRemoteSDP(sdp, from: sessionID) // This sends an answer message internally if case let .answer(sdp) = mode {
self.answerButton.alpha = 0 callInfoLabel.text = "Connecting..."
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseIn, animations: { webRTCSession.handleRemoteSDP(sdp, from: sessionID) // This sends an answer message internally
self.answerButton.isHidden = true self.answerButton.alpha = 0
}, completion: nil) UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
self.answerButton.isHidden = true
}, completion: nil)
}
} else {
userDefaults[.hasSeenCallIPExposureWarning] = true
showCallModal()
} }
} }

@ -140,7 +140,22 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
} }
@objc private func answerCall() { @objc private func answerCall() {
showCallVC(answer: true) let userDefaults = UserDefaults.standard
if userDefaults[.hasSeenCallIPExposureWarning] {
showCallVC(answer: true)
} else {
showCallModal()
}
}
internal func showCallModal() {
let callModal = CallModal() { [weak self] in
self?.showCallVC(answer: true)
}
callModal.modalPresentationStyle = .overFullScreen
callModal.modalTransitionStyle = .crossDissolve
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully
presentingVC.present(callModal, animated: true, completion: nil)
} }
@objc private func endCall() { @objc private func endCall() {

@ -28,14 +28,20 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
// MARK: Call // MARK: Call
@objc func startCall(_ sender: Any?) { @objc func startCall(_ sender: Any?) {
guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return } let userDefaults = UserDefaults.standard
let callVC = CallVC(for: contactSessionID, uuid: UUID().uuidString, mode: .offer) if userDefaults[.hasSeenCallIPExposureWarning] {
callVC.conversationVC = self guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return }
callVC.modalPresentationStyle = .overFullScreen let callVC = CallVC(for: contactSessionID, uuid: UUID().uuidString, mode: .offer)
callVC.modalTransitionStyle = .crossDissolve callVC.conversationVC = self
self.inputAccessoryView?.isHidden = true callVC.modalPresentationStyle = .overFullScreen
self.inputAccessoryView?.alpha = 0 callVC.modalTransitionStyle = .crossDissolve
present(callVC, animated: true, completion: nil) self.inputAccessoryView?.isHidden = true
self.inputAccessoryView?.alpha = 0
present(callVC, animated: true, completion: nil)
} else {
userDefaults[.hasSeenCallIPExposureWarning] = true
showCallModal()
}
} }
internal func showCallModal() { internal func showCallModal() {

@ -6,6 +6,7 @@ public enum SNUserDefaults {
case hasSyncedInitialConfiguration = "hasSyncedConfiguration" case hasSyncedInitialConfiguration = "hasSyncedConfiguration"
case hasViewedSeed case hasViewedSeed
case hasSeenLinkPreviewSuggestion case hasSeenLinkPreviewSuggestion
case hasSeenCallIPExposureWarning
case isUsingFullAPNs case isUsingFullAPNs
} }

Loading…
Cancel
Save