mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Disable call audio toggle while the switch is processing.
This commit is contained in:
@@ -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)
|
||||
) {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user