aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx
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/java/mx
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/java/mx')
-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
2 files changed, 22 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(