Disable call audio toggle while the switch is processing.

This commit is contained in:
Alex Hart
2026-01-22 16:11:59 -04:00
committed by GitHub
parent c0d9efc930
commit 96273bb724
12 changed files with 53 additions and 8 deletions

View File

@@ -55,7 +55,8 @@ fun CallAudioToggleButton(
contentDescription: String,
onSheetDisplayChanged: (Boolean) -> Unit,
pickerController: AudioOutputPickerController,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
enabled: Boolean = true
) {
val buttonSize = dimensionResource(id = R.dimen.webrtc_button_size)
@@ -79,9 +80,12 @@ fun CallAudioToggleButton(
onClick = {
pickerController.show()
},
enabled = enabled,
colors = IconButtons.iconButtonColors(
containerColor = containerColor,
contentColor = contentColor
contentColor = contentColor,
disabledContainerColor = containerColor.copy(alpha = 0.38f),
disabledContentColor = contentColor.copy(alpha = 0.38f)
),
modifier = modifier.size(buttonSize)
) {

View File

@@ -76,7 +76,8 @@ fun CallControls(
CallAudioToggleButton(
contentDescription = stringResource(id = R.string.WebRtcAudioOutputToggle__audio_output),
onSheetDisplayChanged = callScreenSheetDisplayListener::onAudioDeviceSheetDisplayChanged,
pickerController = audioOutputPickerController
pickerController = audioOutputPickerController,
enabled = !callControlsState.isAudioOutputChangePending
)
}
@@ -202,6 +203,7 @@ data class CallControlsState(
val skipHiddenState: Boolean = true,
val displayAudioOutputToggle: Boolean = false,
val audioOutput: WebRtcAudioOutput = WebRtcAudioOutput.HANDSET,
val isAudioOutputChangePending: Boolean = false,
val displayVideoToggle: Boolean = false,
val isVideoEnabled: Boolean = false,
val displayMicToggle: Boolean = false,
@@ -222,7 +224,8 @@ data class CallControlsState(
fun fromViewModelData(
callParticipantsState: CallParticipantsState,
webRtcControls: WebRtcControls,
groupMemberCount: Int
groupMemberCount: Int,
isAudioDeviceChangePending: Boolean = false
): CallControlsState {
return CallControlsState(
isEarpieceAvailable = webRtcControls.isEarpieceAvailableForAudioToggle,
@@ -231,6 +234,7 @@ data class CallControlsState(
skipHiddenState = !(webRtcControls.isFadeOutEnabled || webRtcControls == WebRtcControls.PIP || webRtcControls.displayErrorControls()),
displayAudioOutputToggle = webRtcControls.displayAudioToggle(),
audioOutput = webRtcControls.audioOutput,
isAudioOutputChangePending = isAudioDeviceChangePending,
displayVideoToggle = webRtcControls.displayVideoToggle(),
isVideoEnabled = callParticipantsState.localParticipant.isVideoEnabled,
displayMicToggle = webRtcControls.displayMuteAudio(),

View File

@@ -56,6 +56,7 @@ class WebRtcCallViewModel : ViewModel() {
private val callPeerRepository = CallPeerRepository(viewModelScope)
private val internalMicrophoneEnabled = MutableStateFlow(true)
private val isAudioDeviceChangePending = MutableStateFlow(false)
private val remoteMutedBy = MutableStateFlow<CallParticipant?>(null)
private val isInPipMode = MutableStateFlow(false)
private val _savedLocalParticipantLandscape = MutableStateFlow(false)
@@ -177,8 +178,10 @@ class WebRtcCallViewModel : ViewModel() {
callParticipantsState,
getWebRtcControls(),
groupSize,
CallControlsState::fromViewModelData
)
isAudioDeviceChangePending
) { participantsState, controls, groupMemberCount, audioChangePending ->
CallControlsState.fromViewModelData(participantsState, controls, groupMemberCount, audioChangePending)
}
}
val callParticipantsState: Flow<CallParticipantsState> get() = participantsState
@@ -311,6 +314,7 @@ class WebRtcCallViewModel : ViewModel() {
}
internalMicrophoneEnabled.value = localParticipant.isMicrophoneEnabled
isAudioDeviceChangePending.value = webRtcViewModel.isAudioDeviceChangePending
if (internalMicrophoneEnabled.value) {
remoteMutedBy.update { null }