aboutsummaryrefslogtreecommitdiff
path: root/androidApp
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 17:57:14 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 17:57:14 -0600
commit21e16e27f047053582d8b0c722feedf3c8badebe (patch)
tree07f1e6844cea6cc42f2a7f5eaa57d4f3b57e0ea2 /androidApp
parentf030f9cc2327fa3825964a9b06430ae5881ebcba (diff)
downloadetbsa-trackermap-mobile-21e16e27f047053582d8b0c722feedf3c8badebe.tar.gz
etbsa-trackermap-mobile-21e16e27f047053582d8b0c722feedf3c8badebe.tar.bz2
etbsa-trackermap-mobile-21e16e27f047053582d8b0c722feedf3c8badebe.zip
Refactored report types into commonMain, added support for event report types in controller and API
Diffstat (limited to 'androidApp')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt42
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt20
2 files changed, 41 insertions, 21 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
index 3b3570b..4c87b31 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
@@ -205,26 +205,28 @@ class UnitReportsFragment : Fragment() {
datetimeText.text = Formatter.formatDate(it)
}
event.event.type?.let {
- eventText.text = getString(when (it) {
- "deviceOnline" -> R.string.event_device_online
- "deviceUnknown" -> R.string.event_device_unknown
- "deviceOffline" -> R.string.event_device_offline
- "deviceInactive" -> R.string.event_device_inactive
- "deviceMoving" -> R.string.event_device_moving
- "deviceStopped" -> R.string.event_device_stopped
- "deviceOverspeed" -> R.string.event_device_overspeed
- "deviceFuelDrop" -> R.string.event_device_fuel_drop
- "commandResult" -> R.string.event_command_result
- "geofenceEnter" -> R.string.event_geofence_enter
- "geofenceExit" -> R.string.event_geofence_exit
- "alarm" -> R.string.event_alarm
- "ignitionOn" -> R.string.event_ignition_on
- "ignitionOff" -> R.string.event_ignition_off
- "maintenance" -> R.string.event_maintenance
- "textMessage" -> R.string.event_text_message
- "driverChanged" -> R.string.event_driver_changed
- else -> R.string.event_unknown
- })
+ eventText.text = getString(
+ when (EventInformation.stringToReportType(it)) {
+ EventInformation.Type.DEVICE_ONLINE -> R.string.event_device_online
+ EventInformation.Type.DEVICE_UNKNOWN -> R.string.event_device_unknown
+ EventInformation.Type.DEVICE_OFFLINE -> R.string.event_device_offline
+ EventInformation.Type.DEVICE_INACTIVE -> R.string.event_device_inactive
+ EventInformation.Type.DEVICE_MOVING -> R.string.event_device_moving
+ EventInformation.Type.DEVICE_STOPPED -> R.string.event_device_stopped
+ EventInformation.Type.DEVICE_OVERSPEED -> R.string.event_device_overspeed
+ EventInformation.Type.DEVICE_FUEL_DROP -> R.string.event_device_fuel_drop
+ EventInformation.Type.COMMAND_RESULT -> R.string.event_command_result
+ EventInformation.Type.GEOFENCE_ENTER -> R.string.event_geofence_enter
+ EventInformation.Type.GEOFENCE_EXIT -> R.string.event_geofence_exit
+ EventInformation.Type.ALARM -> R.string.event_alarm
+ EventInformation.Type.IGNITION_ON -> R.string.event_ignition_on
+ EventInformation.Type.IGNITION_OFF -> R.string.event_ignition_off
+ EventInformation.Type.MAINTENANCE -> R.string.event_maintenance
+ EventInformation.Type.TEXT_MESSAGE -> R.string.event_text_message
+ EventInformation.Type.DRIVER_CHANGED -> R.string.event_driver_changed
+ EventInformation.Type.UNKNOWN -> R.string.event_unknown
+ else -> R.string.event_unknown
+ })
}
event.geofence?.let {
geofenceText.text = it.name
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
index 865f096..62ac4f2 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
@@ -4,6 +4,7 @@ import androidx.lifecycle.*
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
+import mx.trackermap.TrackerMap.client.models.EventInformation
import mx.trackermap.TrackerMap.controllers.ReportController
import mx.trackermap.TrackerMap.utils.ReportDates
import org.koin.core.component.KoinComponent
@@ -84,7 +85,24 @@ class UnitReportsViewModel(
deviceId = id,
reportType = _reportType.value,
reportPeriod = _reportPeriod.value,
- xlsx = xlsx
+ xlsx = xlsx,
+ eventTypes = arrayOf(
+ EventInformation.Type.DEVICE_INACTIVE,
+ EventInformation.Type.DEVICE_MOVING,
+ EventInformation.Type.DEVICE_STOPPED,
+ EventInformation.Type.DEVICE_OVERSPEED,
+ EventInformation.Type.DEVICE_FUEL_DROP,
+ EventInformation.Type.COMMAND_RESULT,
+ EventInformation.Type.GEOFENCE_ENTER,
+ EventInformation.Type.GEOFENCE_EXIT,
+ EventInformation.Type.ALARM,
+ EventInformation.Type.IGNITION_ON,
+ EventInformation.Type.IGNITION_OFF,
+ EventInformation.Type.MAINTENANCE,
+ EventInformation.Type.TEXT_MESSAGE,
+ EventInformation.Type.DRIVER_CHANGED,
+ EventInformation.Type.UNKNOWN
+ )
)
}
}