From 81627e66554051e0b75ae028d5f39ae0d81d705f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Saleniuk?= Date: Mon, 24 Jun 2024 16:32:22 +0200 Subject: [PATCH] fix: camera on/off button when in fullscreen [WPB-9815] --- .../ui/calling/ongoing/OngoingCallScreen.kt | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/calling/ongoing/OngoingCallScreen.kt b/app/src/main/kotlin/com/wire/android/ui/calling/ongoing/OngoingCallScreen.kt index baddd56f441..1fa0a33a87a 100644 --- a/app/src/main/kotlin/com/wire/android/ui/calling/ongoing/OngoingCallScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/calling/ongoing/OngoingCallScreen.kt @@ -81,6 +81,7 @@ import com.wire.android.ui.theme.wireColorScheme import com.wire.android.ui.theme.wireDimensions import com.wire.android.ui.theme.wireTypography import com.wire.android.util.ui.PreviewMultipleThemes +import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import java.util.Locale @@ -122,20 +123,24 @@ fun OngoingCallScreen( hangUpCall = { sharedCallingViewModel.hangUpCall(navigator::navigateBack) }, toggleVideo = sharedCallingViewModel::toggleVideo, flipCamera = sharedCallingViewModel::flipCamera, - setVideoPreview = { - sharedCallingViewModel.setVideoPreview(it) - ongoingCallViewModel.startSendingVideoFeed() - }, - clearVideoPreview = { - sharedCallingViewModel.clearVideoPreview() - ongoingCallViewModel.stopSendingVideoFeed() - }, + setVideoPreview = sharedCallingViewModel::setVideoPreview, + clearVideoPreview = sharedCallingViewModel::clearVideoPreview, navigateBack = navigator::navigateBack, requestVideoStreams = ongoingCallViewModel::requestVideoStreams, hideDoubleTapToast = ongoingCallViewModel::hideDoubleTapToast ) BackHandler(enabled = isCameraOn, navigator::navigateBack) } + + // Start/stop sending video feed based on the camera state when the call is established. + LaunchedEffect(sharedCallingViewModel.callState.callStatus, sharedCallingViewModel.callState.isCameraOn) { + if (sharedCallingViewModel.callState.callStatus == CallStatus.ESTABLISHED) { + when (sharedCallingViewModel.callState.isCameraOn) { + true -> ongoingCallViewModel.startSendingVideoFeed() + false -> ongoingCallViewModel.stopSendingVideoFeed() + } + } + } } @OptIn(ExperimentalMaterial3Api::class)