add flag for enable/disable call function

pull/560/head
Ryan Zhao 3 years ago
parent 6ac075fa5a
commit 71e6ccd94b

@ -5,6 +5,9 @@ import PromiseKit
import CallKit import CallKit
public final class SessionCall: NSObject, WebRTCSessionDelegate { public final class SessionCall: NSObject, WebRTCSessionDelegate {
@objc static let isEnabled = true
// MARK: Metadata Properties // MARK: Metadata Properties
let uuid: String let uuid: String
let callID: UUID // This is for CallKit let callID: UUID // This is for CallKit

@ -28,6 +28,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
// MARK: Call // MARK: Call
@objc func startCall(_ sender: Any?) { @objc func startCall(_ sender: Any?) {
guard SessionCall.isEnabled else { return }
let userDefaults = UserDefaults.standard let userDefaults = UserDefaults.standard
if !SSKPreferences.areCallsEnabled && !userDefaults[.hasSeenCallIPExposureWarning] { if !SSKPreferences.areCallsEnabled && !userDefaults[.hasSeenCallIPExposureWarning] {
userDefaults[.hasSeenCallIPExposureWarning] = true userDefaults[.hasSeenCallIPExposureWarning] = true

@ -309,7 +309,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
settingsButton.accessibilityLabel = "Settings button" settingsButton.accessibilityLabel = "Settings button"
settingsButton.isAccessibilityElement = true settingsButton.isAccessibilityElement = true
rightBarButtonItems.append(settingsButton) rightBarButtonItems.append(settingsButton)
let shouldShowCallButton = !thread.isNoteToSelf() && (SSKPreferences.areCallsEnabled || !UserDefaults.standard[.hasSeenCallIPExposureWarning]) let shouldShowCallButton = SessionCall.isEnabled && !thread.isNoteToSelf() && (SSKPreferences.areCallsEnabled || !UserDefaults.standard[.hasSeenCallIPExposureWarning])
if shouldShowCallButton { if shouldShowCallButton {
let callButton = UIBarButtonItem(image: UIImage(named: "Phone")!, style: .plain, target: self, action: #selector(startCall)) let callButton = UIBarButtonItem(image: UIImage(named: "Phone")!, style: .plain, target: self, action: #selector(startCall))
rightBarButtonItems.append(callButton) rightBarButtonItems.append(callButton)

@ -44,7 +44,7 @@ final class ConversationTitleView : UIView {
stackView.axis = .vertical stackView.axis = .vertical
stackView.alignment = .center stackView.alignment = .center
stackView.isLayoutMarginsRelativeArrangement = true stackView.isLayoutMarginsRelativeArrangement = true
let shouldShowCallButton = !thread.isNoteToSelf() && !thread.isGroupThread() && (SSKPreferences.areCallsEnabled || !UserDefaults.standard[.hasSeenCallIPExposureWarning]) let shouldShowCallButton = SessionCall.isEnabled && !thread.isNoteToSelf() && !thread.isGroupThread() && (SSKPreferences.areCallsEnabled || !UserDefaults.standard[.hasSeenCallIPExposureWarning])
let leftMargin: CGFloat = shouldShowCallButton ? 54 : 8 // Contact threads also have the call button to compensate for let leftMargin: CGFloat = shouldShowCallButton ? 54 : 8 // Contact threads also have the call button to compensate for
stackView.layoutMargins = UIEdgeInsets(top: 0, left: leftMargin, bottom: 0, right: 0) stackView.layoutMargins = UIEdgeInsets(top: 0, left: leftMargin, bottom: 0, right: 0)
addSubview(stackView) addSubview(stackView)

Loading…
Cancel
Save