sforkowany z mirror/meshtastic-android
fix: show modem preset name if channel name is empty
(or "Default" if not available)master
rodzic
8643d50425
commit
d58e092333
|
@ -126,6 +126,7 @@ fun ChannelScreen(viewModel: UIViewModel = viewModel()) {
|
|||
|
||||
val primaryChannel = ChannelSet(channelSet).primaryChannel
|
||||
val channelUrl = ChannelSet(channelSet).getChannelUrl()
|
||||
val modemPresetName = Channel(Channel.default.settings, channelSet.loraConfig).name
|
||||
|
||||
val barcodeLauncher = rememberLauncherForActivityResult(ScanContract()) { result ->
|
||||
if (result.contents != null) {
|
||||
|
@ -244,6 +245,7 @@ fun ChannelScreen(viewModel: UIViewModel = viewModel()) {
|
|||
channelSettings = with(channelSet) {
|
||||
if (settingsCount > index) getSettings(index) else channelSettings { }
|
||||
},
|
||||
modemPresetName = modemPresetName,
|
||||
onAddClick = {
|
||||
with(channelSet) {
|
||||
if (settingsCount > index) channelSet = copy { settings[index] = it }
|
||||
|
@ -258,6 +260,7 @@ fun ChannelScreen(viewModel: UIViewModel = viewModel()) {
|
|||
var showChannelEditor by remember { mutableStateOf(false) }
|
||||
if (showChannelEditor) ChannelSettingsItemList(
|
||||
settingsList = channelSet.settingsList,
|
||||
modemPresetName = modemPresetName,
|
||||
enabled = enabled,
|
||||
focusManager = focusManager,
|
||||
onNegativeClicked = {
|
||||
|
|
|
@ -107,6 +107,7 @@ fun ChannelSettingsItemList(
|
|||
@Composable
|
||||
fun ChannelSettingsItemList(
|
||||
settingsList: List<ChannelSettings>,
|
||||
modemPresetName: String = "Default",
|
||||
maxChannels: Int = 8,
|
||||
enabled: Boolean,
|
||||
focusManager: FocusManager,
|
||||
|
@ -125,6 +126,7 @@ fun ChannelSettingsItemList(
|
|||
channelSettings = with(settingsListInput) {
|
||||
if (size > index) get(index) else channelSettings { }
|
||||
},
|
||||
modemPresetName = modemPresetName,
|
||||
onAddClick = {
|
||||
if (settingsListInput.size > index) settingsListInput[index] = it
|
||||
else settingsListInput.add(it)
|
||||
|
@ -147,7 +149,7 @@ fun ChannelSettingsItemList(
|
|||
itemsIndexed(settingsListInput) { index, channel ->
|
||||
ChannelCard(
|
||||
index = index,
|
||||
title = channel.name,
|
||||
title = channel.name.ifEmpty { modemPresetName },
|
||||
enabled = enabled,
|
||||
onEditClick = { showEditChannelDialog = index },
|
||||
onDeleteClick = { settingsListInput.removeAt(index) }
|
||||
|
|
|
@ -48,6 +48,7 @@ fun EditChannelDialog(
|
|||
onAddClick: (ChannelProtos.ChannelSettings) -> Unit,
|
||||
onDismissRequest: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
modemPresetName: String = "Default",
|
||||
) {
|
||||
val base64Flags = Base64.URL_SAFE + Base64.NO_WRAP
|
||||
fun encodeToString(input: ByteString) =
|
||||
|
@ -73,9 +74,10 @@ fun EditChannelDialog(
|
|||
text = {
|
||||
AppCompatTheme {
|
||||
Column(modifier.fillMaxWidth()) {
|
||||
var isFocused by remember { mutableStateOf(false) }
|
||||
EditTextPreference(
|
||||
title = stringResource(R.string.channel_name),
|
||||
value = nameInput,
|
||||
value = if (isFocused) nameInput else nameInput.ifEmpty { modemPresetName },
|
||||
maxSize = 11, // name max_size:12
|
||||
enabled = true,
|
||||
isError = false,
|
||||
|
@ -84,6 +86,7 @@ fun EditChannelDialog(
|
|||
),
|
||||
keyboardActions = KeyboardActions(onDone = { }),
|
||||
onValueChanged = { nameInput = it },
|
||||
onFocusChanged = { isFocused = it.isFocused },
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
|
|
Ładowanie…
Reference in New Issue