feat: add DeviceConfig RebroadcastMode descriptions

This commit is contained in:
andrekir 2024-11-06 10:21:32 -03:00
parent 336b05236c
commit a8c810bae2
3 changed files with 49 additions and 11 deletions

View file

@ -22,6 +22,27 @@ import androidx.compose.ui.tooling.preview.Preview
import com.geeksville.mesh.R
import com.google.protobuf.ProtocolMessageEnum
@Composable
fun <T : Enum<T>> DropDownPreference(
title: String,
enabled: Boolean,
selectedItem: T,
onItemSelected: (T) -> Unit,
modifier: Modifier = Modifier,
summary: String? = null,
) {
DropDownPreference(
title = title,
enabled = enabled,
items = selectedItem.declaringJavaClass.enumConstants
?.filter { it.name != "UNRECOGNIZED" }?.map { it to it.name } ?: emptyList(),
selectedItem = selectedItem,
onItemSelected = onItemSelected,
modifier = modifier,
summary = summary,
)
}
@Composable
fun <T> DropDownPreference(
title: String,

View file

@ -45,6 +45,17 @@ private val DeviceConfig.Role.stringRes: Int
else -> R.string.unrecognized
}
private val DeviceConfig.RebroadcastMode.stringRes: Int
get() = when (this) {
DeviceConfig.RebroadcastMode.ALL -> R.string.rebroadcast_mode_all
DeviceConfig.RebroadcastMode.ALL_SKIP_DECODING -> R.string.rebroadcast_mode_all_skip_decoding
DeviceConfig.RebroadcastMode.LOCAL_ONLY -> R.string.rebroadcast_mode_local_only
DeviceConfig.RebroadcastMode.KNOWN_ONLY -> R.string.rebroadcast_mode_known_only
DeviceConfig.RebroadcastMode.NONE -> R.string.rebroadcast_mode_none
DeviceConfig.RebroadcastMode.CORE_PORTNUMS_ONLY -> R.string.rebroadcast_mode_core_portnums_only
else -> R.string.unrecognized
}
@Composable
fun DeviceConfigScreen(
viewModel: RadioConfigViewModel = hiltViewModel(),
@ -83,14 +94,13 @@ fun DeviceConfigItemList(
item { PreferenceCategory(text = "Device Config") }
item {
DropDownPreference(title = "Role",
summary = stringResource(id = deviceInput.role.stringRes),
DropDownPreference(
title = "Role",
enabled = enabled,
items = DeviceConfig.Role.entries
.filter { it != DeviceConfig.Role.UNRECOGNIZED }
.map { it to it.name },
selectedItem = deviceInput.role,
onItemSelected = { deviceInput = deviceInput.copy { role = it } })
onItemSelected = { deviceInput = deviceInput.copy { role = it } },
summary = stringResource(id = deviceInput.role.stringRes),
)
}
item { Divider() }
@ -115,13 +125,13 @@ fun DeviceConfigItemList(
}
item {
DropDownPreference(title = "Rebroadcast mode",
DropDownPreference(
title = "Rebroadcast mode",
enabled = enabled,
items = DeviceConfig.RebroadcastMode.entries
.filter { it != DeviceConfig.RebroadcastMode.UNRECOGNIZED }
.map { it to it.name },
selectedItem = deviceInput.rebroadcastMode,
onItemSelected = { deviceInput = deviceInput.copy { rebroadcastMode = it } })
onItemSelected = { deviceInput = deviceInput.copy { rebroadcastMode = it } },
summary = stringResource(id = deviceInput.rebroadcastMode.stringRes),
)
}
item { Divider() }

View file

@ -57,6 +57,13 @@
<string name="role_lost_and_found">Broadcasts location as message to default channel regularly for to assist with device recovery.</string>
<string name="role_tak_tracker">Enables automatic TAK PLI broadcasts and reduces routine broadcasts.</string>
<string name="rebroadcast_mode_all">Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora parameters.</string>
<string name="rebroadcast_mode_all_skip_decoding">Same as behavior as ALL but skips packet decoding and simply rebroadcasts them. Only available in Repeater role. Setting this on any other roles will result in ALL behavior.</string>
<string name="rebroadcast_mode_local_only">Ignores observed messages from foreign meshes that are open or those which it cannot decrypt. Only rebroadcasts message on the nodes local primary / secondary channels.</string>
<string name="rebroadcast_mode_known_only">Ignores observed messages from foreign meshes like LOCAL ONLY, but takes it step further by also ignoring messages from nodes not already in the node\'s known list.</string>
<string name="rebroadcast_mode_none">Only permitted for SENSOR, TRACKER and TAK_TRACKER roles, this will inhibit all rebroadcasts, not unlike CLIENT_MUTE role.</string>
<string name="rebroadcast_mode_core_portnums_only">Ignores packets from non-standard portnums such as: TAK, RangeTest, PaxCounter, etc. Only rebroadcasts packets with standard portnums: NodeInfo, Text, Position, Telemetry, and Routing.</string>
<string name="elevation_suffix" translatable="false">MSL</string>
<string name="channel_air_util" translatable="false">ChUtil %.1f%% AirUtilTX %.1f%%</string>