aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-01-03 19:49:37 -0600
committerIván Ávalos <avalos@disroot.org>2023-01-03 19:49:37 -0600
commit86b5601d7d9965bea7d57f04600b02f5432dc966 (patch)
treea90194abf3278520ce7553fdb9bfd7bcdbc7b5d2 /shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models
parent808fc8d4a121e7658821fc2956bf0c540cbc113f (diff)
downloadetbsa-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/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt21
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) {