Revert "Remove usage of ! in call view."

This reverts commit 699bf0a829.
pull/1/head
Matthew Chen 7 years ago
parent 594ddfaec3
commit 943b3f031c

@ -30,7 +30,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
// MARK: Views // MARK: Views
var hasConstraints = false var hasConstraints = false
let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark)) var blurView: UIVisualEffectView?
var dateFormatter: DateFormatter? var dateFormatter: DateFormatter?
// MARK: Contact Views // MARK: Contact Views
@ -43,7 +43,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
// MARK: Ongoing Call Controls // MARK: Ongoing Call Controls
let ongoingCallView = UIView() var ongoingCallView: UIView?
var hangUpButton: UIButton? var hangUpButton: UIButton?
var audioSourceButton: UIButton? var audioSourceButton: UIButton?
@ -58,7 +58,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
// MARK: Incoming Call Controls // MARK: Incoming Call Controls
let incomingCallView = UIView() var incomingCallView: UIView?
var acceptIncomingButton: UIButton? var acceptIncomingButton: UIButton?
var declineIncomingButton: UIButton? var declineIncomingButton: UIButton?
@ -218,6 +218,9 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
action: #selector(didTouchRootView))) action: #selector(didTouchRootView)))
// Dark blurred background. // Dark blurred background.
let blurEffect = UIBlurEffect(style: .dark)
let blurView = UIVisualEffectView(effect: blurEffect)
self.blurView = blurView
blurView.isUserInteractionEnabled = false blurView.isUserInteractionEnabled = false
self.view.addSubview(blurView) self.view.addSubview(blurView)
@ -384,8 +387,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
setButtonSelectedImage(button: audioModeVideoButton, imageName: "audio-call-video-active") setButtonSelectedImage(button: audioModeVideoButton, imageName: "audio-call-video-active")
setButtonSelectedImage(button: videoModeVideoButton, imageName: "video-video-selected") setButtonSelectedImage(button: videoModeVideoButton, imageName: "video-video-selected")
createContainerForCallControls(containerView: ongoingCallView, ongoingCallView = createContainerForCallControls(controlGroups: [
controlGroups: [
[audioModeMuteButton, audioSourceButton, audioModeVideoButton ], [audioModeMuteButton, audioSourceButton, audioModeVideoButton ],
[videoModeMuteButton, hangUpButton, videoModeVideoButton ] [videoModeMuteButton, hangUpButton, videoModeVideoButton ]
]) ])
@ -441,14 +443,13 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
comment: "Accessibility label for declining incoming calls")) comment: "Accessibility label for declining incoming calls"))
self.declineIncomingButton = declineIncomingButton self.declineIncomingButton = declineIncomingButton
createContainerForCallControls(containerView: incomingCallView, incomingCallView = createContainerForCallControls(controlGroups: [
controlGroups: [
[acceptIncomingButton, declineIncomingButton ] [acceptIncomingButton, declineIncomingButton ]
]) ])
} }
func createContainerForCallControls(containerView: UIView, func createContainerForCallControls(controlGroups: [[UIView]]) -> UIView {
controlGroups: [[UIView]]) { let containerView = UIView()
self.view.addSubview(containerView) self.view.addSubview(containerView)
var rows: [UIView] = [] var rows: [UIView] = []
for controlGroup in controlGroups { for controlGroup in controlGroups {
@ -468,6 +469,7 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
containerView.setContentHuggingVerticalHigh() containerView.setContentHuggingVerticalHigh()
rows.first?.autoPinEdge(toSuperviewEdge: .top) rows.first?.autoPinEdge(toSuperviewEdge: .top)
rows.last?.autoPinEdge(toSuperviewEdge: .bottom) rows.last?.autoPinEdge(toSuperviewEdge: .bottom)
return containerView
} }
func createButton(imageName: String, action: Selector, accessibilityLabel: String) -> UIButton { func createButton(imageName: String, action: Selector, accessibilityLabel: String) -> UIButton {
@ -536,6 +538,10 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
// MARK: - Layout // MARK: - Layout
override func updateViewConstraints() { override func updateViewConstraints() {
guard let blurView = blurView else {
owsFail("\(TAG) missing blurView.")
return
}
guard let localVideoView = localVideoView else { guard let localVideoView = localVideoView else {
owsFail("\(TAG) missing localVideoView.") owsFail("\(TAG) missing localVideoView.")
return return
@ -544,6 +550,14 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
owsFail("\(TAG) missing remoteVideoView.") owsFail("\(TAG) missing remoteVideoView.")
return return
} }
guard let ongoingCallView = ongoingCallView else {
owsFail("\(TAG) missing ongoingCallView.")
return
}
guard let incomingCallView = incomingCallView else {
owsFail("\(TAG) missing incomingCallView.")
return
}
if !hasConstraints { if !hasConstraints {
// We only want to create our constraints once. // We only want to create our constraints once.
@ -748,7 +762,7 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
if isShowingSettingsNag { if isShowingSettingsNag {
settingsNagView.isHidden = false settingsNagView.isHidden = false
contactAvatarView.isHidden = true contactAvatarView.isHidden = true
ongoingCallView.isHidden = true ongoingCallView?.isHidden = true
return return
} }
@ -762,10 +776,10 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
// Show Incoming vs. Ongoing call controls // Show Incoming vs. Ongoing call controls
let isRinging = callState == .localRinging let isRinging = callState == .localRinging
incomingCallView.isHidden = !isRinging incomingCallView?.isHidden = !isRinging
incomingCallView.isUserInteractionEnabled = isRinging incomingCallView?.isUserInteractionEnabled = isRinging
ongoingCallView.isHidden = isRinging ongoingCallView?.isHidden = isRinging
ongoingCallView.isUserInteractionEnabled = !isRinging ongoingCallView?.isUserInteractionEnabled = !isRinging
// Rework control state if remote video is available. // Rework control state if remote video is available.
let hasRemoteVideo = !remoteVideoView.isHidden let hasRemoteVideo = !remoteVideoView.isHidden
@ -785,7 +799,7 @@ accessibilityLabel: NSLocalizedString("CALL_VIEW_DECLINE_INCOMING_CALL_LABEL",
if shouldRemoteVideoControlsBeHidden && !remoteVideoView.isHidden { if shouldRemoteVideoControlsBeHidden && !remoteVideoView.isHidden {
contactNameLabel.isHidden = true contactNameLabel.isHidden = true
callStatusLabel.isHidden = true callStatusLabel.isHidden = true
ongoingCallView.isHidden = true ongoingCallView?.isHidden = true
} else { } else {
contactNameLabel.isHidden = false contactNameLabel.isHidden = false
callStatusLabel.isHidden = false callStatusLabel.isHidden = false

Loading…
Cancel
Save