From 156c2729c99ccb5a50db4bc56851e52d360cff45 Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Mon, 17 Jun 2024 16:50:48 +0200 Subject: [PATCH] fix: hide speaker button from IncomingCallScreen (WPB-9031) (#3099) --- .../controlbuttons/CallOptionsControls.kt | 51 +++++++++++++------ .../ui/calling/incoming/IncomingCallScreen.kt | 6 +-- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/calling/controlbuttons/CallOptionsControls.kt b/app/src/main/kotlin/com/wire/android/ui/calling/controlbuttons/CallOptionsControls.kt index 64d5f4dbfd1..f462712890e 100644 --- a/app/src/main/kotlin/com/wire/android/ui/calling/controlbuttons/CallOptionsControls.kt +++ b/app/src/main/kotlin/com/wire/android/ui/calling/controlbuttons/CallOptionsControls.kt @@ -21,8 +21,8 @@ package com.wire.android.ui.calling.controlbuttons import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material3.Text import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -45,10 +45,12 @@ fun CallOptionsControls( toggleSpeaker: () -> Unit, toggleMute: () -> Unit, toggleVideo: () -> Unit, + modifier: Modifier = Modifier, + shouldShowSpeakerButton: Boolean = true, onPermissionPermanentlyDenied: (type: PermissionDenialType) -> Unit ) { ConstraintLayout( - modifier = Modifier + modifier = modifier .fillMaxWidth() .padding(top = MaterialTheme.wireDimensions.spacing32x) ) { @@ -63,30 +65,49 @@ fun CallOptionsControls( isMuted = isMuted, onMicrophoneButtonClicked = toggleMute ) - CallControlLabel(stringResource(id = R.string.calling_button_label_microphone), microphoneText, microphoneIcon) + CallControlLabel( + stringResource(id = R.string.calling_button_label_microphone), + microphoneText, + microphoneIcon + ) CameraButton( modifier = Modifier .size(dimensions().defaultCallingControlsSize) .constrainAs(cameraIcon) { + val cameraEndLink = if (shouldShowSpeakerButton) { + speakerIcon.start + } else { + parent.end + } start.linkTo(microphoneIcon.end) - end.linkTo(speakerIcon.start) + end.linkTo(cameraEndLink) }, isCameraOn = isCameraOn, onPermissionPermanentlyDenied = onPermissionPermanentlyDenied, onCameraButtonClicked = toggleVideo ) - CallControlLabel(stringResource(id = R.string.calling_button_label_camera), cameraText, cameraIcon) - SpeakerButton( - modifier = Modifier - .size(dimensions().defaultCallingControlsSize) - .constrainAs(speakerIcon) { - start.linkTo(cameraIcon.end) - end.linkTo(parent.end) - }, - isSpeakerOn = isSpeakerOn, - onSpeakerButtonClicked = toggleSpeaker + CallControlLabel( + stringResource(id = R.string.calling_button_label_camera), + cameraText, + cameraIcon ) - CallControlLabel(stringResource(id = R.string.calling_button_label_speaker), speakerText, speakerIcon) + if (shouldShowSpeakerButton) { + SpeakerButton( + modifier = Modifier + .size(dimensions().defaultCallingControlsSize) + .constrainAs(speakerIcon) { + start.linkTo(cameraIcon.end) + end.linkTo(parent.end) + }, + isSpeakerOn = isSpeakerOn, + onSpeakerButtonClicked = toggleSpeaker + ) + CallControlLabel( + stringResource(id = R.string.calling_button_label_speaker), + speakerText, + speakerIcon + ) + } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/calling/incoming/IncomingCallScreen.kt b/app/src/main/kotlin/com/wire/android/ui/calling/incoming/IncomingCallScreen.kt index a78ad684177..431074838fc 100644 --- a/app/src/main/kotlin/com/wire/android/ui/calling/incoming/IncomingCallScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/calling/incoming/IncomingCallScreen.kt @@ -123,7 +123,6 @@ fun IncomingCallScreen( IncomingCallContent( callState = callState, toggleMute = { sharedCallingViewModel.toggleMute(true) }, - toggleSpeaker = ::toggleSpeaker, toggleVideo = ::toggleVideo, declineCall = { incomingCallViewModel.declineCall( @@ -165,7 +164,6 @@ fun IncomingCallScreen( private fun IncomingCallContent( callState: CallState, toggleMute: () -> Unit, - toggleSpeaker: () -> Unit, toggleVideo: () -> Unit, declineCall: () -> Unit, acceptCall: () -> Unit, @@ -189,9 +187,10 @@ private fun IncomingCallContent( isMuted = callState.isMuted ?: true, isCameraOn = callState.isCameraOn, isSpeakerOn = callState.isSpeakerOn, - toggleSpeaker = toggleSpeaker, + toggleSpeaker = {}, toggleMute = toggleMute, toggleVideo = toggleVideo, + shouldShowSpeakerButton = false, onPermissionPermanentlyDenied = onPermissionPermanentlyDenied ) Box( @@ -292,7 +291,6 @@ fun PreviewIncomingCallScreen() { IncomingCallContent( callState = CallState(ConversationId("value", "domain")), toggleMute = { }, - toggleSpeaker = { }, toggleVideo = { }, declineCall = { }, acceptCall = { },