aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 16:11:47 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 16:11:47 -0600
commit16b614d6f3fcc88924e79ac3a1bffef538b09e8b (patch)
treeb41918082a1bdd5ba4feea3e778cdd9aabf98bf9 /androidApp/src/main
parent484c64d1682f65ad0741228963bdefda87b935ab (diff)
downloadetbsa-trackermap-mobile-16b614d6f3fcc88924e79ac3a1bffef538b09e8b.tar.gz
etbsa-trackermap-mobile-16b614d6f3fcc88924e79ac3a1bffef538b09e8b.tar.bz2
etbsa-trackermap-mobile-16b614d6f3fcc88924e79ac3a1bffef538b09e8b.zip
Added hourmeter field
Diffstat (limited to 'androidApp/src/main')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt8
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/UnitRenderData.kt14
-rw-r--r--androidApp/src/main/res/drawable/position_hourmeter.xml10
-rw-r--r--androidApp/src/main/res/values-es-rMX/strings.xml1
-rw-r--r--androidApp/src/main/res/values/strings.xml1
5 files changed, 34 insertions, 0 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
index 0c3577e..6c15ae4 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
@@ -13,6 +13,7 @@ import androidx.core.widget.TextViewCompat
import androidx.fragment.app.Fragment
import com.google.android.material.button.MaterialButton
import kotlinx.coroutines.DelicateCoroutinesApi
+import kotlinx.serialization.json.longOrNull
import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UnitDetailsInformationBinding
import mx.trackermap.TrackerMap.android.details.UnitDetailsAdapter
@@ -94,6 +95,13 @@ class UnitInformationFragment : Fragment() {
unit.position?.address?.let { address ->
details.add(getString(R.string.unit_info_address) to address)
}
+ unit.position?.attributes?.get("hours")?.longOrNull?.let {
+ if (it > 0) {
+ details.add(
+ getString(R.string.unit_hourmeter) to Formatter.formatHours(it)
+ )
+ }
+ }
unit.position?.protocol?.let { protocol ->
details.add(getString(R.string.unit_info_protocol) to protocol)
}
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/UnitRenderData.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/UnitRenderData.kt
index beeba6f..c7999de 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/UnitRenderData.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/UnitRenderData.kt
@@ -12,6 +12,7 @@ import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.core.content.ContextCompat
import com.zerobranch.layout.SwipeLayout
+import kotlinx.serialization.json.longOrNull
import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.map.MarkerTransformations
import mx.trackermap.TrackerMap.client.models.UnitInformation
@@ -128,6 +129,19 @@ class UnitRenderData {
)
}
+ /* Hourmeter */
+ position.attributes["hours"]?.longOrNull?.let {
+ if (it > 0) {
+ details.add(
+ Triple(
+ R.drawable.position_hourmeter,
+ Formatter.formatHours(it),
+ context.getString(R.string.unit_hourmeter)
+ )
+ )
+ }
+ }
+
/* Date time */
position.fixTime?.let { fixTime ->
details.add(
diff --git a/androidApp/src/main/res/drawable/position_hourmeter.xml b/androidApp/src/main/res/drawable/position_hourmeter.xml
new file mode 100644
index 0000000..52ff427
--- /dev/null
+++ b/androidApp/src/main/res/drawable/position_hourmeter.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="14sp"
+ android:height="14sp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M15,1L9,1v2h6L15,1zM11,14h2L13,8h-2v6zM19.03,7.39l1.42,-1.42c-0.43,-0.51 -0.9,-0.99 -1.41,-1.41l-1.42,1.42C16.07,4.74 14.12,4 12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9 9,-4.03 9,-9c0,-2.12 -0.74,-4.07 -1.97,-5.61zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
+</vector>
diff --git a/androidApp/src/main/res/values-es-rMX/strings.xml b/androidApp/src/main/res/values-es-rMX/strings.xml
index 5e41768..f843c29 100644
--- a/androidApp/src/main/res/values-es-rMX/strings.xml
+++ b/androidApp/src/main/res/values-es-rMX/strings.xml
@@ -31,6 +31,7 @@
<string name="unit_driver_name">Nombre del conductor</string>
<string name="unit_speed">Velocidad</string>
<string name="unit_last_address">Dirección de la última posición</string>
+ <string name="unit_hourmeter">Horómetro</string>
<string name="unit_last_date">Fecha y hora de la última posición</string>
<string name="unit_category_animal">Animal</string>
diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml
index 11c914f..60547d3 100644
--- a/androidApp/src/main/res/values/strings.xml
+++ b/androidApp/src/main/res/values/strings.xml
@@ -44,6 +44,7 @@
<string name="unit_driver_name">Driver name</string>
<string name="unit_speed">Speed</string>
<string name="unit_last_address">Last position address</string>
+ <string name="unit_hourmeter">Hourmeter</string>
<string name="unit_last_date">Last position datetime</string>
<string name="unit_category_animal">Animal</string>