Added call back when bluetooth device is added or removed

This commit is contained in:
Christophe Deschamps 2022-12-02 16:50:23 +01:00
parent 82289f4523
commit e8c2e92fc9
2 changed files with 9 additions and 0 deletions

View file

@ -30,6 +30,7 @@ class ControlsViewModel {
let isMicrophoneMuted = MutableLiveData<Bool>()
let isMuteMicrophoneEnabled = MutableLiveData<Bool>()
let isBluetoothHeadsetSelected = MutableLiveData<Bool>()
let isBluetoothHeadsetAvailable = MutableLiveData<Bool>()
let nonEarpieceOutputAudioDevice = MutableLiveData<Bool>()
let audioRoutesSelected = MutableLiveData<Bool>()
let audioRoutesEnabled = MutableLiveData<Bool>()
@ -71,6 +72,9 @@ class ControlsViewModel {
self.nonEarpieceOutputAudioDevice.value = audioDevice.type != AudioDeviceType.Microphone // on iOS Earpiece = Microphone
self.updateSpeakerState()
self.updateBluetoothHeadsetState()
},
onAudioDevicesListUpdated : { (core: Core) -> Void in
self.isBluetoothHeadsetAvailable.value = !core.audioDevices.filter { [.Bluetooth,.BluetoothA2DP].contains($0.type)}.isEmpty
}
)
Core.get().addDelegate(delegate: coreDelegate!)

View file

@ -67,6 +67,11 @@ class ControlsView: UIStackView {
routes.isHidden = !speaker.isHidden
}
controlsViewModel.isBluetoothHeadsetAvailable.readCurrentAndObserve { available in
speaker.isHidden = available == true
routes.isHidden = !speaker.isHidden
}
// Video
if (showVideo) {
let video = CallControlButton(buttonTheme: VoipTheme.call_video, onClickAction: {