spotless on: ChannelLegend.kt and ChannelSettingsItemList.kt

pull/2935/head
robert 2025-08-30 18:01:26 -07:00
rodzic b3781be373
commit 8465a080a4
2 zmienionych plików z 21 dodań i 30 usunięć

Wyświetl plik

@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
@ -49,10 +49,9 @@ import com.geeksville.mesh.R
import com.geeksville.mesh.model.DeviceVersion import com.geeksville.mesh.model.DeviceVersion
/** /**
* At this firmware version periodic position sharing on a secondary channel was implemented. To * At this firmware version periodic position sharing on a secondary channel was implemented. To enable this feature the
* enable this feature the user must disable position on the primary channel and enable on a secondary * user must disable position on the primary channel and enable on a secondary channel. The lowest indexed secondary
* channel. The lowest indexed secondary channel with the position enabled will conduct the automatic * channel with the position enabled will conduct the automatic position broadcasts.
* position broadcasts.
*/ */
internal const val SECONDARY_CHANNEL_EPOCH = "2.6.10" internal const val SECONDARY_CHANNEL_EPOCH = "2.6.10"
@ -64,33 +63,28 @@ internal enum class ChannelIcons(
LOCATION( LOCATION(
icon = Icons.Filled.LocationOn, icon = Icons.Filled.LocationOn,
descriptionResId = R.string.location_sharing, descriptionResId = R.string.location_sharing,
additionalInfoResId = R.string.periodic_position_broadcast additionalInfoResId = R.string.periodic_position_broadcast,
), ),
UPLINK( UPLINK(
icon = Icons.Filled.CloudUpload, icon = Icons.Filled.CloudUpload,
descriptionResId = R.string.uplink_enabled, descriptionResId = R.string.uplink_enabled,
additionalInfoResId = R.string.uplink_feature_description additionalInfoResId = R.string.uplink_feature_description,
), ),
DOWNLINK( DOWNLINK(
icon = Icons.Filled.CloudDownload, icon = Icons.Filled.CloudDownload,
descriptionResId = R.string.downlink_enabled, descriptionResId = R.string.downlink_enabled,
additionalInfoResId = R.string.downlink_feature_description additionalInfoResId = R.string.downlink_feature_description,
), ),
} }
@Composable @Composable
internal fun ChannelLegend(onClick: () -> Unit) { internal fun ChannelLegend(onClick: () -> Unit) {
Row( Row(
modifier = Modifier modifier = Modifier.fillMaxWidth().clickable { onClick.invoke() },
.fillMaxWidth()
.clickable { onClick.invoke() },
horizontalArrangement = Arrangement.SpaceEvenly, horizontalArrangement = Arrangement.SpaceEvenly,
) { ) {
Row { Row {
Icon( Icon(imageVector = Icons.Filled.Info, contentDescription = stringResource(R.string.info))
imageVector = Icons.Filled.Info,
contentDescription = stringResource(R.string.info),
)
Text( Text(
text = stringResource(R.string.primary), text = stringResource(R.string.primary),
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
@ -119,32 +113,33 @@ internal fun ChannelLegendDialog(firmwareVersion: DeviceVersion, onDismiss: () -
Text( Text(
text = stringResource(R.string.primary), text = stringResource(R.string.primary),
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.titleMedium style = MaterialTheme.typography.titleMedium,
) )
Text( Text(
text = "- ${stringResource(R.string.primary_channel_feature)}", text = "- ${stringResource(R.string.primary_channel_feature)}",
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.bodyMedium style = MaterialTheme.typography.bodyMedium,
) )
Text( Text(
text = stringResource(R.string.secondary), text = stringResource(R.string.secondary),
color = MaterialTheme.colorScheme.onBackground, color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleMedium style = MaterialTheme.typography.titleMedium,
) )
Text( Text(
text = "- ${stringResource(R.string.secondary_no_telemetry)}", text = "- ${stringResource(R.string.secondary_no_telemetry)}",
color = MaterialTheme.colorScheme.onBackground, color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodyMedium style = MaterialTheme.typography.bodyMedium,
) )
Text( Text(
text = if(firmwareVersion >= DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) { text =
if (firmwareVersion >= DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) {
/* 2.6.10+ */ /* 2.6.10+ */
"- ${stringResource(R.string.secondary_channel_position_feature)}" "- ${stringResource(R.string.secondary_channel_position_feature)}"
} else { } else {
"- ${stringResource(R.string.manual_position_request)}" "- ${stringResource(R.string.manual_position_request)}"
}, },
color = MaterialTheme.colorScheme.onBackground, color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodyMedium style = MaterialTheme.typography.bodyMedium,
) )
IconDefinitions() IconDefinitions()
} }
@ -163,10 +158,7 @@ internal fun ChannelLegendDialog(firmwareVersion: DeviceVersion, onDismiss: () -
@Composable @Composable
private fun IconDefinitions() { private fun IconDefinitions() {
Text( Text(text = stringResource(R.string.icon_meanings), style = MaterialTheme.typography.titleLarge)
text = stringResource(R.string.icon_meanings),
style = MaterialTheme.typography.titleLarge
)
ChannelIcons.entries.forEach { icon -> ChannelIcons.entries.forEach { icon ->
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Icon(imageVector = icon.icon, contentDescription = stringResource(icon.descriptionResId)) Icon(imageVector = icon.icon, contentDescription = stringResource(icon.descriptionResId))
@ -184,5 +176,5 @@ private fun IconDefinitions() {
@Preview @Preview
@Composable @Composable
private fun PreviewChannelLegendDialog() { private fun PreviewChannelLegendDialog() {
ChannelLegendDialog(firmwareVersion = DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) { } ChannelLegendDialog(firmwareVersion = DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) {}
} }

Wyświetl plik

@ -198,9 +198,8 @@ private fun ChannelSettingsItemList(
val primarySettings = settingsList.getOrNull(0) ?: return val primarySettings = settingsList.getOrNull(0) ?: return
val modemPresetName by remember(loraConfig) { mutableStateOf(Channel(loraConfig = loraConfig).name) } val modemPresetName by remember(loraConfig) { mutableStateOf(Channel(loraConfig = loraConfig).name) }
val primaryChannel by remember(loraConfig) { mutableStateOf(Channel(primarySettings, loraConfig)) } val primaryChannel by remember(loraConfig) { mutableStateOf(Channel(primarySettings, loraConfig)) }
val fwVersion by remember(firmwareVersion) { val fwVersion by
mutableStateOf(DeviceVersion(firmwareVersion.substringBeforeLast("."))) remember(firmwareVersion) { mutableStateOf(DeviceVersion(firmwareVersion.substringBeforeLast("."))) }
}
val focusManager = LocalFocusManager.current val focusManager = LocalFocusManager.current
val settingsListInput = val settingsListInput =
@ -357,7 +356,7 @@ private fun ChannelsConfigHeader(frequency: Float, slot: Int) {
* @param settingsList Current list of channels on the node. * @param settingsList Current list of channels on the node.
* @return the index of the channel within `settingsList`. * @return the index of the channel within `settingsList`.
*/ */
private fun determineLocationSharingChannel(firmwareVersion: DeviceVersion, settingsList:List<ChannelSettings>): Int { private fun determineLocationSharingChannel(firmwareVersion: DeviceVersion, settingsList: List<ChannelSettings>): Int {
var output = -1 var output = -1
if (firmwareVersion >= DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) { if (firmwareVersion >= DeviceVersion(asString = SECONDARY_CHANNEL_EPOCH)) {
/* Essentially the first index with the setting enabled */ /* Essentially the first index with the setting enabled */