diff options
author | Iván Ávalos <avalos@disroot.org> | 2023-01-03 19:49:37 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2023-01-03 19:49:37 -0600 |
commit | 86b5601d7d9965bea7d57f04600b02f5432dc966 (patch) | |
tree | a90194abf3278520ce7553fdb9bfd7bcdbc7b5d2 /shared | |
parent | 808fc8d4a121e7658821fc2956bf0c540cbc113f (diff) | |
download | etbsa-trackermap-mobile-86b5601d7d9965bea7d57f04600b02f5432dc966.tar.gz etbsa-trackermap-mobile-86b5601d7d9965bea7d57f04600b02f5432dc966.tar.bz2 etbsa-trackermap-mobile-86b5601d7d9965bea7d57f04600b02f5432dc966.zip |
[android] Changed way that online status is calculated, and added ignition icon
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt index 1e23396..6afa350 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt @@ -17,6 +17,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.json.boolean import kotlinx.serialization.json.longOrNull data class UnitInformation( @@ -31,17 +32,15 @@ data class UnitInformation( ON, OFF, UNKNOWN } - /** - * Status is calculated from speed, because status based on - * the actual connection to the server is useless for our clients. - */ - fun getStatus() = position?.speed?.let { - if (it >= 2) { - Status.ONLINE - } else { - Status.OFFLINE - } - } ?: Status.UNKNOWN + fun getStatus() = when (device.status) { + "online" -> Status.ONLINE + "offline" -> Status.OFFLINE + else -> Status.UNKNOWN + } + + fun getIgnition() = if (position?.attributes?.containsKey("ignition") == true) { + position.attributes["ignition"]?.boolean ?: false + } else false /* Many GPS devices reserve pin 1 for engine stop */ fun getEngineStop() = if (position?.attributes?.containsKey("out1") == true) { |