diff --git a/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt b/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt index 2573e38df..640631ee6 100644 --- a/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt +++ b/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt @@ -240,6 +240,7 @@ class ConferenceViewModel : ViewModel() { init { coreContext.core.addListener(listener) + conferenceExists.value = false conferenceParticipants.value = arrayListOf() conferenceParticipantDevices.value = arrayListOf() @@ -360,8 +361,11 @@ class ConferenceViewModel : ViewModel() { fun switchLayoutFromAudioOnlyToActiveSpeaker() { if (conferenceDisplayMode.value == ConferenceDisplayMode.AUDIO_ONLY) { + Log.i("[Conference] Trying to switch from AUDIO_ONLY to ACTIVE_SPEAKER and toggle video ON") changeLayout(ConferenceDisplayMode.ACTIVE_SPEAKER, true) waitForNextStreamsRunningToUpdateLayout = true + } else { + Log.w("[Conference] Can't switch from AUDIO_ONLY to ACTIVE_SPEAKER as current display mode isn't AUDIO_ONLY but ${conferenceDisplayMode.value}") } } diff --git a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt index 59dfcced8..4af7a906b 100644 --- a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt +++ b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt @@ -286,6 +286,7 @@ class ControlsViewModel : ViewModel() { fun toggleVideo() { if (!PermissionHelper.get().hasCameraPermission()) { + Log.w("[Call Controls] Camera permission isn't granted, asking it before toggling video") askPermissionEvent.value = Event(Manifest.permission.CAMERA) return } @@ -294,8 +295,10 @@ class ControlsViewModel : ViewModel() { val currentCall = core.currentCall if (currentCall != null) { val state = currentCall.state - if (state == Call.State.End || state == Call.State.Released || state == Call.State.Error) + if (state == Call.State.End || state == Call.State.Released || state == Call.State.Error) { + Log.e("[Call Controls] Current call state is $state, aborting video toggle") return + } isVideoUpdateInProgress.value = true val params = core.createCallParams(currentCall) @@ -311,9 +314,12 @@ class ControlsViewModel : ViewModel() { } } } else { - params?.isVideoEnabled = !currentCall.currentParams.isVideoEnabled + params?.isVideoEnabled = params?.isVideoEnabled == false + Log.i("[Call Controls] Updating call with video enabled set to ${params?.isVideoEnabled}") } currentCall.update(params) + } else { + Log.e("[Call Controls] Can't toggle video, no current call found!") } } diff --git a/app/src/main/res/layout/voip_buttons.xml b/app/src/main/res/layout/voip_buttons.xml index 3c2047e5e..0ca230176 100644 --- a/app/src/main/res/layout/voip_buttons.xml +++ b/app/src/main/res/layout/voip_buttons.xml @@ -97,7 +97,7 @@ android:background="@drawable/button_background_reverse" android:contentDescription="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo ? @string/content_description_disable_video : @string/content_description_enable_video}" android:enabled="@{controlsViewModel.isVideoAvailable && !controlsViewModel.isVideoUpdateInProgress}" - android:onClick="@{() -> conferenceViewModel.conferenceDisplayMode != ConferenceDisplayMode.AUDIO_ONLY ? controlsViewModel.toggleVideo() : conferenceViewModel.switchLayoutFromAudioOnlyToActiveSpeaker()}" + android:onClick="@{() -> (!conferenceViewModel.conferenceExists || conferenceViewModel.conferenceDisplayMode != ConferenceDisplayMode.AUDIO_ONLY) ? controlsViewModel.toggleVideo() : conferenceViewModel.switchLayoutFromAudioOnlyToActiveSpeaker()}" android:padding="5dp" android:selected="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo}" android:src="@drawable/icon_toggle_camera" diff --git a/app/src/main/res/layout/voip_single_call_fragment.xml b/app/src/main/res/layout/voip_single_call_fragment.xml index e2e9aed64..1c79db141 100644 --- a/app/src/main/res/layout/voip_single_call_fragment.xml +++ b/app/src/main/res/layout/voip_single_call_fragment.xml @@ -278,6 +278,7 @@ android:visibility="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? View.GONE : View.VISIBLE}" app:callsViewModel="@{callsViewModel}" app:controlsViewModel="@{controlsViewModel}" + app:conferenceViewModel="@{conferenceViewModel}" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"