mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-25 13:58:32 +00:00
Fixed video toggle button in single call
This commit is contained in:
parent
f3178a0854
commit
8e893b60a1
4 changed files with 14 additions and 3 deletions
|
|
@ -240,6 +240,7 @@ class ConferenceViewModel : ViewModel() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
coreContext.core.addListener(listener)
|
coreContext.core.addListener(listener)
|
||||||
|
conferenceExists.value = false
|
||||||
|
|
||||||
conferenceParticipants.value = arrayListOf()
|
conferenceParticipants.value = arrayListOf()
|
||||||
conferenceParticipantDevices.value = arrayListOf()
|
conferenceParticipantDevices.value = arrayListOf()
|
||||||
|
|
@ -360,8 +361,11 @@ class ConferenceViewModel : ViewModel() {
|
||||||
|
|
||||||
fun switchLayoutFromAudioOnlyToActiveSpeaker() {
|
fun switchLayoutFromAudioOnlyToActiveSpeaker() {
|
||||||
if (conferenceDisplayMode.value == ConferenceDisplayMode.AUDIO_ONLY) {
|
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)
|
changeLayout(ConferenceDisplayMode.ACTIVE_SPEAKER, true)
|
||||||
waitForNextStreamsRunningToUpdateLayout = 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}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
|
|
||||||
fun toggleVideo() {
|
fun toggleVideo() {
|
||||||
if (!PermissionHelper.get().hasCameraPermission()) {
|
if (!PermissionHelper.get().hasCameraPermission()) {
|
||||||
|
Log.w("[Call Controls] Camera permission isn't granted, asking it before toggling video")
|
||||||
askPermissionEvent.value = Event(Manifest.permission.CAMERA)
|
askPermissionEvent.value = Event(Manifest.permission.CAMERA)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -294,8 +295,10 @@ class ControlsViewModel : ViewModel() {
|
||||||
val currentCall = core.currentCall
|
val currentCall = core.currentCall
|
||||||
if (currentCall != null) {
|
if (currentCall != null) {
|
||||||
val state = currentCall.state
|
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
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isVideoUpdateInProgress.value = true
|
isVideoUpdateInProgress.value = true
|
||||||
val params = core.createCallParams(currentCall)
|
val params = core.createCallParams(currentCall)
|
||||||
|
|
@ -311,9 +314,12 @@ class ControlsViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
currentCall.update(params)
|
||||||
|
} else {
|
||||||
|
Log.e("[Call Controls] Can't toggle video, no current call found!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
android:background="@drawable/button_background_reverse"
|
android:background="@drawable/button_background_reverse"
|
||||||
android:contentDescription="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo ? @string/content_description_disable_video : @string/content_description_enable_video}"
|
android:contentDescription="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo ? @string/content_description_disable_video : @string/content_description_enable_video}"
|
||||||
android:enabled="@{controlsViewModel.isVideoAvailable && !controlsViewModel.isVideoUpdateInProgress}"
|
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:padding="5dp"
|
||||||
android:selected="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo}"
|
android:selected="@{controlsViewModel.isVideoEnabled && controlsViewModel.isSendingVideo}"
|
||||||
android:src="@drawable/icon_toggle_camera"
|
android:src="@drawable/icon_toggle_camera"
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@
|
||||||
android:visibility="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? View.GONE : View.VISIBLE}"
|
android:visibility="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? View.GONE : View.VISIBLE}"
|
||||||
app:callsViewModel="@{callsViewModel}"
|
app:callsViewModel="@{callsViewModel}"
|
||||||
app:controlsViewModel="@{controlsViewModel}"
|
app:controlsViewModel="@{controlsViewModel}"
|
||||||
|
app:conferenceViewModel="@{conferenceViewModel}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue