feat: Add Status Message module support (#4163)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-25 08:15:47 -06:00 committed by GitHub
parent df592d4d86
commit 355d2260e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1195 additions and 9 deletions

View file

@ -40,6 +40,7 @@ import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.SignalCellularAlt
import androidx.compose.material.icons.filled.Verified
import androidx.compose.material.icons.filled.Work
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@ -128,6 +129,7 @@ private fun MismatchKeyWarning(modifier: Modifier = Modifier) {
}
}
@Suppress("LongMethod")
@Composable
private fun MainNodeDetails(node: Node) {
Column {
@ -149,6 +151,19 @@ private fun MainNodeDetails(node: Node) {
SectionDivider()
PublicKeyItem(publicKey.toByteArray())
}
if (!node.nodeStatus.isNullOrEmpty()) {
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f))
Row(modifier = Modifier.fillMaxWidth()) {
InfoItem(
label = "Status",
value = node.nodeStatus!!,
icon = Icons.Default.CheckCircle,
modifier = Modifier.weight(1f),
)
}
}
}
}

View file

@ -199,6 +199,17 @@ fun NodeItem(
}
}
}
if (!thatNode.nodeStatus.isNullOrEmpty()) {
Spacer(modifier = Modifier.height(2.dp))
Text(
text = thatNode.nodeStatus!!,
style = MaterialTheme.typography.bodySmall,
color = contentColor,
maxLines = 2,
)
}
Spacer(modifier = Modifier.height(2.dp))
Row(
modifier = Modifier.fillMaxWidth(),

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.feature.settings.navigation
import androidx.compose.material.icons.Icons
@ -47,6 +46,7 @@ import org.meshtastic.core.strings.paxcounter
import org.meshtastic.core.strings.range_test
import org.meshtastic.core.strings.remote_hardware
import org.meshtastic.core.strings.serial
import org.meshtastic.core.strings.status_message
import org.meshtastic.core.strings.store_forward
import org.meshtastic.core.strings.telemetry
import org.meshtastic.proto.AdminProtos
@ -131,6 +131,12 @@ enum class ModuleRoute(val title: StringResource, val route: Route, val icon: Im
Icons.Default.PermScanWifi,
AdminProtos.AdminMessage.ModuleConfigType.PAXCOUNTER_CONFIG_VALUE,
),
STATUS_MESSAGE(
Res.string.status_message,
SettingsRoutes.StatusMessage,
Icons.AutoMirrored.Default.Message,
AdminProtos.AdminMessage.ModuleConfigType.STATUSMESSAGE_CONFIG_VALUE,
),
;
val bitfield: Int

View file

@ -0,0 +1,74 @@
/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.feature.settings.radio.component
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.jetbrains.compose.resources.stringResource
import org.meshtastic.core.strings.Res
import org.meshtastic.core.strings.node_status_summary
import org.meshtastic.core.strings.status_message
import org.meshtastic.core.strings.status_message_config
import org.meshtastic.core.ui.component.EditTextPreference
import org.meshtastic.core.ui.component.TitledCard
import org.meshtastic.feature.settings.radio.RadioConfigViewModel
import org.meshtastic.proto.copy
import org.meshtastic.proto.moduleConfig
@Composable
fun StatusMessageConfigScreen(viewModel: RadioConfigViewModel = hiltViewModel(), onBack: () -> Unit) {
val state by viewModel.radioConfigState.collectAsStateWithLifecycle()
val statusMessageConfig = state.moduleConfig.statusmessage
val formState = rememberConfigState(initialValue = statusMessageConfig)
val focusManager = LocalFocusManager.current
RadioConfigScreenList(
title = stringResource(Res.string.status_message),
onBack = onBack,
configState = formState,
enabled = state.connected,
responseState = state.responseState,
onDismissPacketResponse = viewModel::clearPacketResponse,
onSave = {
val config = moduleConfig { statusmessage = it }
viewModel.setModuleConfig(config)
},
) {
item {
TitledCard(title = stringResource(Res.string.status_message_config)) {
EditTextPreference(
title = stringResource(Res.string.node_status_summary),
value = formState.value.nodeStatus,
maxSize = 80, // status_message max_size:80
enabled = state.connected,
isError = false,
keyboardOptions =
KeyboardOptions.Default.copy(keyboardType = KeyboardType.Text, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = { formState.value = formState.value.copy { nodeStatus = it } },
)
}
}
}
}