fix: set fixed position for local node only

master
andrekir 2023-05-12 18:34:29 -03:00
rodzic ad278f918b
commit 6297cf2b62
3 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -1774,9 +1774,9 @@ class MeshService : Service(), Logging {
// request position
sendPosition(destNum = destNum, wantResponse = true)
} else {
// send fixed position
// send fixed position (local only/no remote method, so we force destNum to null)
val (lat, lon, alt) = position
sendPosition(destNum = destNum, lat = lat, lon = lon, alt = alt)
sendPosition(destNum = null, lat = lat, lon = lon, alt = alt)
}
}

Wyświetl plik

@ -158,6 +158,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
val connected = connectionState == MeshService.ConnectionState.CONNECTED
val destNum = node.num
val isLocal = destNum == viewModel.myNodeNum
val maxChannels = viewModel.myNodeInfo.value?.maxChannels ?: 8
var userConfig by remember { mutableStateOf(MeshProtos.User.getDefaultInstance()) }
@ -308,7 +309,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
composable("home") {
RadioSettingsScreen(
enabled = connected && !isWaiting,
isLocal = destNum == viewModel.myNodeNum,
isLocal = isLocal,
headerText = node.user?.longName ?: stringResource(R.string.unknown_username),
onRouteClick = { configType ->
packetResponseState = PacketResponseState.Loading.apply {
@ -408,6 +409,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
}
composable("position") {
PositionConfigItemList(
isLocal = isLocal,
location = location,
positionConfig = radioConfig.position,
enabled = connected,

Wyświetl plik

@ -25,6 +25,7 @@ import com.geeksville.mesh.ui.components.SwitchPreference
@Composable
fun PositionConfigItemList(
isLocal: Boolean = false,
location: Position?,
positionConfig: PositionConfig,
enabled: Boolean,
@ -93,7 +94,7 @@ fun PositionConfigItemList(
item {
EditTextPreference(title = "Latitude",
value = locationInput?.latitude ?: 0.0,
enabled = enabled,
enabled = enabled && isLocal,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = { value ->
if (value >= -90 && value <= 90.0)
@ -103,7 +104,7 @@ fun PositionConfigItemList(
item {
EditTextPreference(title = "Longitude",
value = locationInput?.longitude ?: 0.0,
enabled = enabled,
enabled = enabled && isLocal,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = { value ->
if (value >= -180 && value <= 180.0)
@ -113,7 +114,7 @@ fun PositionConfigItemList(
item {
EditTextPreference(title = "Altitude (meters)",
value = locationInput?.altitude ?: 0,
enabled = enabled,
enabled = enabled && isLocal,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = { value ->
locationInput?.let { locationInput = it.copy(altitude = value) }