fix (#2128): MQTT map reporting interval input (#2135)

This commit is contained in:
James Rich 2025-06-16 16:54:55 +00:00 committed by GitHub
parent 0b368ce0b1
commit 86905942de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -85,6 +85,7 @@ fun EditTextPreference(
title: String,
value: Int,
enabled: Boolean,
isError: Boolean = false,
keyboardActions: KeyboardActions,
onValueChanged: (Int) -> Unit,
modifier: Modifier = Modifier,
@ -97,7 +98,7 @@ fun EditTextPreference(
title = title,
value = valueState,
enabled = enabled,
isError = value.toUInt().toString() != valueState,
isError = value.toUInt().toString() != valueState || isError,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number, imeAction = ImeAction.Done
),

View file

@ -233,6 +233,13 @@ fun MQTTConfigItemList(
mapReportSettings = settings
}
},
publishIntervalSecs = mqttInput.mapReportSettings.publishIntervalSecs,
onPublishIntervalSecsChanged = {
val settings = mqttInput.mapReportSettings.copy { publishIntervalSecs = it }
mqttInput = mqttInput.copy {
mapReportSettings = settings
}
},
enabled = enabled,
focusManager = focusManager
)
@ -241,7 +248,8 @@ fun MQTTConfigItemList(
item {
val consentValid = if (mqttInput.mapReportingEnabled) {
mqttInput.mapReportSettings.shouldReportLocation
mqttInput.mapReportSettings.shouldReportLocation &&
mqttConfig.mapReportSettings.publishIntervalSecs >= MinIntervalSecs
} else {
true
}
@ -260,6 +268,8 @@ fun MQTTConfigItemList(
}
}
private const val MinIntervalSecs = 3600
@Preview(showBackground = true)
@Composable
private fun MQTTConfigPreview() {

View file

@ -138,6 +138,7 @@ fun MapReportingPreference(
modifier = Modifier.Companion.padding(bottom = 16.dp),
title = stringResource(R.string.map_reporting_interval_seconds),
value = publishIntervalSecs,
isError = publishIntervalSecs < 3600,
enabled = enabled,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = onPublishIntervalSecsChanged,