Skip to content

Commit

Permalink
fix: hide speaker button from IncomingCallScreen (WPB-9031) (#3099)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored Jun 17, 2024
1 parent e88f509 commit 156c272
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
) {
Expand All @@ -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
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ fun IncomingCallScreen(
IncomingCallContent(
callState = callState,
toggleMute = { sharedCallingViewModel.toggleMute(true) },
toggleSpeaker = ::toggleSpeaker,
toggleVideo = ::toggleVideo,
declineCall = {
incomingCallViewModel.declineCall(
Expand Down Expand Up @@ -165,7 +164,6 @@ fun IncomingCallScreen(
private fun IncomingCallContent(
callState: CallState,
toggleMute: () -> Unit,
toggleSpeaker: () -> Unit,
toggleVideo: () -> Unit,
declineCall: () -> Unit,
acceptCall: () -> Unit,
Expand All @@ -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(
Expand Down Expand Up @@ -292,7 +291,6 @@ fun PreviewIncomingCallScreen() {
IncomingCallContent(
callState = CallState(ConversationId("value", "domain")),
toggleMute = { },
toggleSpeaker = { },
toggleVideo = { },
declineCall = { },
acceptCall = { },
Expand Down

0 comments on commit 156c272

Please sign in to comment.