Code improvement
This commit is contained in:
parent
c5f40c8eed
commit
704e7d84fa
3 changed files with 14 additions and 26 deletions
|
@ -55,7 +55,7 @@ class ControlsFadingViewModel : ViewModel() {
|
||||||
) {
|
) {
|
||||||
if (state == Call.State.StreamsRunning || state == Call.State.Updating || state == Call.State.UpdatedByRemote) {
|
if (state == Call.State.StreamsRunning || state == Call.State.Updating || state == Call.State.UpdatedByRemote) {
|
||||||
val isVideoCall = coreContext.isVideoCallOrConferenceActive()
|
val isVideoCall = coreContext.isVideoCallOrConferenceActive()
|
||||||
Log.i("[Controls Fading] Call is in state $state, video is enabled? $videoEnabled")
|
Log.i("[Controls Fading] Call is in state $state, video is ${if (isVideoCall) "enabled" else "disabled"}")
|
||||||
if (isVideoCall) {
|
if (isVideoCall) {
|
||||||
videoEnabled.value = true
|
videoEnabled.value = true
|
||||||
startTimer()
|
startTimer()
|
||||||
|
|
|
@ -188,7 +188,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
override fun onAudioDevicesListUpdated(core: Core) {
|
override fun onAudioDevicesListUpdated(core: Core) {
|
||||||
if (core.callsNb == 0) return
|
if (core.callsNb == 0) return
|
||||||
updateAudioRoutesState()
|
updateAudioRoutesState()
|
||||||
routeAudioToBluetoothIfAvailable(core.currentCall ?: core.calls[0])
|
coreContext.routeAudioToBluetoothIfAvailable(core.currentCall ?: core.calls[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,18 +443,6 @@ class ControlsViewModel : ViewModel() {
|
||||||
isBluetoothHeadsetSelected.value = audioDevice?.type == AudioDevice.Type.Bluetooth
|
isBluetoothHeadsetSelected.value = audioDevice?.type == AudioDevice.Type.Bluetooth
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun routeAudioToBluetoothIfAvailable(call: Call) {
|
|
||||||
for (audioDevice in coreContext.core.audioDevices) {
|
|
||||||
if (audioDevice.type == AudioDevice.Type.Bluetooth &&
|
|
||||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
|
||||||
Log.i("[Call] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it")
|
|
||||||
call.outputAudioDevice = audioDevice
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.w("[Call] Didn't find any bluetooth audio device, keeping current audio route")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateVideoAvailable() {
|
private fun updateVideoAvailable() {
|
||||||
val core = coreContext.core
|
val core = coreContext.core
|
||||||
val currentCall = core.currentCall
|
val currentCall = core.currentCall
|
||||||
|
|
|
@ -549,6 +549,18 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun routeAudioToBluetoothIfAvailable(call: Call) {
|
||||||
|
for (audioDevice in core.audioDevices) {
|
||||||
|
if (audioDevice.type == AudioDevice.Type.Bluetooth &&
|
||||||
|
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
||||||
|
Log.i("[Context] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it")
|
||||||
|
call.outputAudioDevice = audioDevice
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.w("[Context] Didn't find any bluetooth audio device, keeping default audio route")
|
||||||
|
}
|
||||||
|
|
||||||
/* Start call related activities */
|
/* Start call related activities */
|
||||||
|
|
||||||
private fun onIncomingReceived() {
|
private fun onIncomingReceived() {
|
||||||
|
@ -589,16 +601,4 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun routeAudioToBluetoothIfAvailable(call: Call) {
|
|
||||||
for (audioDevice in core.audioDevices) {
|
|
||||||
if (audioDevice.type == AudioDevice.Type.Bluetooth &&
|
|
||||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
|
||||||
Log.i("[Context] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it")
|
|
||||||
call.outputAudioDevice = audioDevice
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.w("[Context] Didn't find any bluetooth audio device, keeping default audio route")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue