From 2b0b936902c7b2f60540fdc3a36d34c49427e065 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:48:53 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20camera=20on/off=20button=20when=20in?= =?UTF-8?q?=20fullscreen=20[WPB-9815]=20=F0=9F=8D=92=20(#3122)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Saleniuk <30429749+saleniuk@users.noreply.github.com> Co-authored-by: Michał Saleniuk --- .../ui/calling/ongoing/OngoingCallScreen.kt | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 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 9e06147d6b2..515e106385d 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 @@ -58,6 +58,7 @@ import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import com.wire.android.R import com.wire.android.ui.LocalActivity +import com.wire.android.ui.calling.CallState import com.wire.android.ui.calling.ConversationName import com.wire.android.ui.calling.SharedCallingViewModel import com.wire.android.ui.calling.controlbuttons.CameraButton @@ -138,14 +139,8 @@ fun OngoingCallScreen( hangUpCall = { sharedCallingViewModel.hangUpCall { activity.finishAndRemoveTask() } }, toggleVideo = sharedCallingViewModel::toggleVideo, flipCamera = sharedCallingViewModel::flipCamera, - setVideoPreview = { - sharedCallingViewModel.setVideoPreview(it) - ongoingCallViewModel.startSendingVideoFeed() - }, - clearVideoPreview = { - sharedCallingViewModel.clearVideoPreview() - ongoingCallViewModel.stopSendingVideoFeed() - }, + setVideoPreview = sharedCallingViewModel::setVideoPreview, + clearVideoPreview = sharedCallingViewModel::clearVideoPreview, onCollapse = { activity.moveTaskToBack(true) }, requestVideoStreams = ongoingCallViewModel::requestVideoStreams, hideDoubleTapToast = ongoingCallViewModel::hideDoubleTapToast, @@ -170,25 +165,36 @@ fun OngoingCallScreen( hideDialog = permissionPermanentlyDeniedDialogState::dismiss ) + HandleSendingVideoFeed( + callState = sharedCallingViewModel.callState, + pauseSendingVideoFeed = ongoingCallViewModel::pauseSendingVideoFeed, + startSendingVideoFeed = ongoingCallViewModel::startSendingVideoFeed, + stopSendingVideoFeed = ongoingCallViewModel::stopSendingVideoFeed, + clearVideoPreview = sharedCallingViewModel::clearVideoPreview, + ) +} + +@Composable +private fun HandleSendingVideoFeed( + callState: CallState, + pauseSendingVideoFeed: () -> Unit, + startSendingVideoFeed: () -> Unit, + stopSendingVideoFeed: () -> Unit, + clearVideoPreview: () -> Unit, +) { // Pause the video feed when the lifecycle is paused and resume it when the lifecycle is resumed. val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current DisposableEffect(lifecycleOwner) { val observer = LifecycleEventObserver { _, event -> - if (event == Lifecycle.Event.ON_PAUSE && - sharedCallingViewModel.callState.callStatus == CallStatus.ESTABLISHED && - sharedCallingViewModel.callState.isCameraOn - ) { - ongoingCallViewModel.pauseSendingVideoFeed() + if (event == Lifecycle.Event.ON_PAUSE && callState.callStatus == CallStatus.ESTABLISHED && callState.isCameraOn) { + pauseSendingVideoFeed() } - if (event == Lifecycle.Event.ON_RESUME && - sharedCallingViewModel.callState.callStatus == CallStatus.ESTABLISHED && - sharedCallingViewModel.callState.isCameraOn - ) { - ongoingCallViewModel.startSendingVideoFeed() + if (event == Lifecycle.Event.ON_RESUME && callState.callStatus == CallStatus.ESTABLISHED && callState.isCameraOn) { + startSendingVideoFeed() } if (event == Lifecycle.Event.ON_DESTROY) { - sharedCallingViewModel.clearVideoPreview() + clearVideoPreview() } } @@ -198,6 +204,16 @@ fun OngoingCallScreen( lifecycleOwner.lifecycle.removeObserver(observer) } } + + // Start/stop sending video feed based on the camera state when the call is established. + LaunchedEffect(callState.callStatus, callState.isCameraOn) { + if (callState.callStatus == CallStatus.ESTABLISHED) { + when (callState.isCameraOn) { + true -> startSendingVideoFeed() + false -> stopSendingVideoFeed() + } + } + } } @OptIn(ExperimentalMaterial3Api::class) From ea7ba294ecc40e33f28a51f5e39c5ba3cfec5ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Saleniuk?= Date: Mon, 24 Jun 2024 18:52:29 +0200 Subject: [PATCH 2/2] trigger build