android radio: add volume PTT toggle to radio panel
This commit is contained in:
1 parent
40e6bd36c3
commit
de54c2d059
3 files changed
+13
-3
No files matched your search
@@ -249,7 +249,7 @@ private fun RadioPttButton(
|
||||
}
|
||||
}
|
||||
|
||||
/* Единый выбор входа/выхода, VAD и плавающая PTT-кнопка. */
|
||||
/* Единый выбор входа/выхода, PTT громкостью, VAD и плавающая PTT-кнопка. */
|
||||
@Composable
|
||||
private fun RadioSourceBar(viewModel: ChatViewModel) {
|
||||
val radioAuto by viewModel.radioAuto.collectAsState()
|
||||
@@ -261,6 +261,7 @@ private fun RadioSourceBar(viewModel: ChatViewModel) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val overlayEnabled by provider.radioOverlayEnabled.collectAsState(initial = provider.getRadioOverlay())
|
||||
val vadEnabled by provider.radioVadEnabled.collectAsState(initial = provider.getInt("radio.vad_enabled") != 0)
|
||||
val volumePttEnabled by provider.radioVolumePttEnabled.collectAsState(initial = provider.getRadioVolumePtt())
|
||||
val overlayShown by RadioOverlayService.isShown.collectAsState()
|
||||
val overlayStatus by RadioOverlayService.status.collectAsState()
|
||||
|
||||
@@ -300,6 +301,9 @@ private fun RadioSourceBar(viewModel: ChatViewModel) {
|
||||
}
|
||||
}
|
||||
VerticalDivider(modifier = Modifier.height(32.dp), color = Color(0xFF344550))
|
||||
RadioControlButton(Icons.AutoMirrored.Filled.VolumeUp, stringResource(R.string.volume_ptt), volumePttEnabled) {
|
||||
viewModel.setRadioVolumePtt(!volumePttEnabled)
|
||||
}
|
||||
RadioControlButton(null, stringResource(if (vadEnabled) R.string.disable_vad else R.string.enable_vad),
|
||||
vadEnabled, text = stringResource(R.string.vad_button)) {
|
||||
viewModel.setRadioVad(!vadEnabled)
|
||||
|
||||
@@ -604,11 +604,10 @@ private fun RadioSettingsTab() {
|
||||
HorizontalDivider(Modifier.padding(vertical = 4.dp))
|
||||
|
||||
/* ── Volume-кнопки PTT ── */
|
||||
var volumePtt by remember { mutableStateOf(provider.getRadioVolumePtt()) }
|
||||
val volumePtt by provider.radioVolumePttEnabled.collectAsState(initial = provider.getRadioVolumePtt())
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(stringResource(R.string.volume_ptt), modifier = Modifier.weight(1f))
|
||||
Switch(checked = volumePtt, onCheckedChange = {
|
||||
volumePtt = it
|
||||
scope.launch { provider.setRadioVolumePtt(it) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -661,6 +661,13 @@ class ChatViewModel : ViewModel() {
|
||||
radioAudio.talkEnd()
|
||||
}
|
||||
|
||||
fun setRadioVolumePtt(enabled: Boolean) {
|
||||
if (!_radioActive.value) return
|
||||
viewModelScope.launch {
|
||||
ChatApplication.instance.configProvider.setRadioVolumePtt(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
/** Переключатель авто-PTT на панели рации: сохранить выбор и перенастроить захват. */
|
||||
fun setRadioVad(enabled: Boolean) {
|
||||
if (!_radioActive.value) return
|
||||
|
||||
Reference in new issue
Block a user