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

Loading…
Cancel
Save