diff options
Diffstat (limited to 'androidApp')
8 files changed, 153 insertions, 37 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt index d42a8aa..175e908 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt @@ -28,6 +28,7 @@ class DevicesAdapter( UnitRenderData.render( UnitRenderData.UnitRenderViewHolder( unitName = unitName, + unitIcon = unitIcon, statusIcon = statusIcon, engineStopIcon = engineStopIcon, gridLayout = gridLayout, 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 39ef472..beeba6f 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 @@ -13,6 +13,7 @@ import androidx.cardview.widget.CardView import androidx.core.content.ContextCompat import com.zerobranch.layout.SwipeLayout import mx.trackermap.TrackerMap.android.R +import mx.trackermap.TrackerMap.android.map.MarkerTransformations import mx.trackermap.TrackerMap.client.models.UnitInformation import mx.trackermap.TrackerMap.utils.Formatter import mx.trackermap.TrackerMap.utils.SpeedUnit @@ -22,6 +23,7 @@ typealias ActionCallback = (unit: UnitInformation, action: Action) -> Unit class UnitRenderData { data class UnitRenderViewHolder( val unitName: TextView, + val unitIcon: ImageView? = null, val statusIcon: ImageView, val engineStopIcon: ImageView, val gridLayout: GridLayout, @@ -45,6 +47,14 @@ class UnitRenderData { /* Device name */ unitName.text = unit.device.name + /* Device icon */ + unitIcon?.setImageResource( + MarkerTransformations.categoryToResourceId(unit.device.category) + ) + unitIcon?.contentDescription = context.getString( + MarkerTransformations.categoryToStringId(unit.device.category) + ) + /* Contact */ unit.device.contact?.let { contact -> if (contact.isNotEmpty()) { diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index 002b981..34ff655 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -317,32 +317,7 @@ class MapFragment : GlobeMapFragment() { private fun getIcon(markerType: MarkerType): Bitmap { return ResourcesCompat.getDrawable( activity!!.resources, - when (markerType) { - MarkerType.ANIMAL -> R.drawable.map_animal - MarkerType.BICYCLE -> R.drawable.map_bicycle - MarkerType.BOAT -> R.drawable.map_boat - MarkerType.BUS -> R.drawable.map_bus - MarkerType.CAR -> R.drawable.map_car - MarkerType.CRANE -> R.drawable.map_crane - MarkerType.DEFAULT -> R.drawable.map_default - MarkerType.HELICOPTER -> R.drawable.map_helicopter - MarkerType.MOTORCYCLE -> R.drawable.map_motorcycle - MarkerType.OFFROAD -> R.drawable.map_offroad - MarkerType.PERSON -> R.drawable.map_person - MarkerType.PICKUP -> R.drawable.map_pickup - MarkerType.PLANE -> R.drawable.map_plane - MarkerType.SCOOTER -> R.drawable.map_scooter - MarkerType.SHIP -> R.drawable.map_ship - MarkerType.TRACTOR -> R.drawable.map_tractor - MarkerType.TRAIN -> R.drawable.map_train - MarkerType.TRAM -> R.drawable.map_tram - MarkerType.TROLLEYBUS -> R.drawable.map_trolleybus - MarkerType.TRUCK -> R.drawable.map_truck - MarkerType.VAN -> R.drawable.map_van - - MarkerType.REPORT_POSITION -> R.drawable.map_report_position - MarkerType.REPORT_START -> R.drawable.map_report_start - MarkerType.REPORT_END -> R.drawable.map_report_end - }, activity!!.theme)!!.toBitmap(144, 144) + MarkerTransformations.markerTypeToResourceId(markerType), + activity!!.theme)!!.toBitmap(144, 144) } }
\ No newline at end of file diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt index b1d52fb..e77471b 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MarkerTransformations.kt @@ -1,5 +1,6 @@ package mx.trackermap.TrackerMap.android.map +import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.client.models.Position import mx.trackermap.TrackerMap.client.models.Stop import mx.trackermap.TrackerMap.client.models.UnitInformation @@ -46,8 +47,8 @@ object MarkerTransformations { ) } - private fun categoryToMarkerType(category: String): MarkerType { - return when (category.lowercase()) { + private fun categoryToMarkerType(category: String?): MarkerType { + return when (category?.lowercase()) { "animal" -> MarkerType.ANIMAL "bicycle" -> MarkerType.BICYCLE "boat" -> MarkerType.BOAT @@ -71,4 +72,69 @@ object MarkerTransformations { else -> MarkerType.DEFAULT } } + + fun markerTypeToResourceId(markerType: MarkerType): Int { + return when (markerType) { + MarkerType.ANIMAL -> R.drawable.map_animal + MarkerType.BICYCLE -> R.drawable.map_bicycle + MarkerType.BOAT -> R.drawable.map_boat + MarkerType.BUS -> R.drawable.map_bus + MarkerType.CAR -> R.drawable.map_car + MarkerType.CRANE -> R.drawable.map_crane + MarkerType.DEFAULT -> R.drawable.map_default + MarkerType.HELICOPTER -> R.drawable.map_helicopter + MarkerType.MOTORCYCLE -> R.drawable.map_motorcycle + MarkerType.OFFROAD -> R.drawable.map_offroad + MarkerType.PERSON -> R.drawable.map_person + MarkerType.PICKUP -> R.drawable.map_pickup + MarkerType.PLANE -> R.drawable.map_plane + MarkerType.SCOOTER -> R.drawable.map_scooter + MarkerType.SHIP -> R.drawable.map_ship + MarkerType.TRACTOR -> R.drawable.map_tractor + MarkerType.TRAIN -> R.drawable.map_train + MarkerType.TRAM -> R.drawable.map_tram + MarkerType.TROLLEYBUS -> R.drawable.map_trolleybus + MarkerType.TRUCK -> R.drawable.map_truck + MarkerType.VAN -> R.drawable.map_van + + MarkerType.REPORT_POSITION -> R.drawable.map_report_position + MarkerType.REPORT_START -> R.drawable.map_report_start + MarkerType.REPORT_END -> R.drawable.map_report_end + } + } + + fun markerTypeToStringId(markerType: MarkerType): Int { + return when (markerType) { + MarkerType.ANIMAL -> R.string.unit_category_animal + MarkerType.BICYCLE -> R.string.unit_category_bicycle + MarkerType.BOAT -> R.string.unit_category_boat + MarkerType.BUS -> R.string.unit_category_bus + MarkerType.CAR -> R.string.unit_category_car + MarkerType.CRANE -> R.string.unit_category_crane + MarkerType.DEFAULT -> R.string.unit_category_default + MarkerType.HELICOPTER -> R.string.unit_category_helicopter + MarkerType.MOTORCYCLE -> R.string.unit_category_motorcycle + MarkerType.OFFROAD -> R.string.unit_category_offroad + MarkerType.PERSON -> R.string.unit_category_person + MarkerType.PICKUP -> R.string.unit_category_pickup + MarkerType.PLANE -> R.string.unit_category_plane + MarkerType.SCOOTER -> R.string.unit_category_scooter + MarkerType.SHIP -> R.string.unit_category_ship + MarkerType.TRACTOR -> R.string.unit_category_tractor + MarkerType.TRAIN -> R.string.unit_category_train + MarkerType.TRAM -> R.string.unit_category_tram + MarkerType.TROLLEYBUS -> R.string.unit_category_trolleybus + MarkerType.TRUCK -> R.string.unit_category_truck + MarkerType.VAN -> R.string.unit_category_van + else -> R.string.unit_category_default + } + } + + fun categoryToResourceId(category: String?): Int { + return markerTypeToResourceId(categoryToMarkerType(category)) + } + + fun categoryToStringId(category: String?): Int { + return markerTypeToResourceId(categoryToMarkerType(category)) + } }
\ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_item.xml b/androidApp/src/main/res/layout/unit_item.xml index e827940..833e56b 100644 --- a/androidApp/src/main/res/layout/unit_item.xml +++ b/androidApp/src/main/res/layout/unit_item.xml @@ -57,18 +57,33 @@ android:clickable="true" android:focusable="true"> - <LinearLayout + <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/mainContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> + <ImageView + android:id="@+id/unitIcon" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:padding="@dimen/card_icon_padding" + android:paddingStart="0dp" + android:src="@drawable/map_default" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + tools:ignore="ContentDescription,RtlSymmetry" /> + <LinearLayout android:id="@+id/titleLayout" - android:layout_width="match_parent" + android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center_vertical" - android:orientation="horizontal"> + android:orientation="horizontal" + app:layout_constraintStart_toEndOf="@id/unitIcon" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent"> <ImageView android:id="@+id/statusIcon" @@ -83,26 +98,30 @@ android:id="@+id/engineStopIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:visibility="gone" android:layout_marginEnd="5dp" android:src="@drawable/device_unlocked" + android:visibility="gone" tools:ignore="ContentDescription" /> <TextView android:id="@+id/unitName" + style="@style/TextAppearance.AppCompat.Body2" android:layout_width="match_parent" android:layout_height="wrap_content" - style="@style/TextAppearance.AppCompat.Body2" tools:text="1AAUTO" /> </LinearLayout> <GridLayout android:id="@+id/gridLayout" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_width="0dp" + android:layout_height="wrap_content" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/unitIcon" + app:layout_constraintTop_toBottomOf="@id/titleLayout" + app:layout_constraintBottom_toBottomOf="parent"/> - </LinearLayout> + </androidx.constraintlayout.widget.ConstraintLayout> </com.google.android.material.card.MaterialCardView> diff --git a/androidApp/src/main/res/values-es-rMX/strings.xml b/androidApp/src/main/res/values-es-rMX/strings.xml index a57d66a..6aee861 100644 --- a/androidApp/src/main/res/values-es-rMX/strings.xml +++ b/androidApp/src/main/res/values-es-rMX/strings.xml @@ -31,6 +31,28 @@ <string name="unit_last_address">Dirección de la última posición</string> <string name="unit_last_date">Fecha y hora de la última posición</string> + <string name="unit_category_animal">Animal</string> + <string name="unit_category_bicycle">Bicicleta</string> + <string name="unit_category_boat">Bote</string> + <string name="unit_category_bus">Autobús</string> + <string name="unit_category_car">Automóvil</string> + <string name="unit_category_crane">Grúa</string> + <string name="unit_category_default">Predeterminado</string> + <string name="unit_category_helicopter">Helicóptero</string> + <string name="unit_category_motorcycle">Motocicleta</string> + <string name="unit_category_offroad">Todoterreno</string> + <string name="unit_category_person">Persona</string> + <string name="unit_category_pickup">Pickup</string> + <string name="unit_category_plane">Avión</string> + <string name="unit_category_scooter">Moto</string> + <string name="unit_category_ship">Barco</string> + <string name="unit_category_tractor">Tractor</string> + <string name="unit_category_train">Tren</string> + <string name="unit_category_tram">Tranvía</string> + <string name="unit_category_trolleybus">Trolebús</string> + <string name="unit_category_truck">Camión</string> + <string name="unit_category_van">Furgoneta</string> + <!-- Details --> <string name="unit_details">Detalles</string> <string name="unit_reports">Reportes</string> diff --git a/androidApp/src/main/res/values/dimen.xml b/androidApp/src/main/res/values/dimen.xml index a016dbd..d557010 100644 --- a/androidApp/src/main/res/values/dimen.xml +++ b/androidApp/src/main/res/values/dimen.xml @@ -9,6 +9,7 @@ <dimen name="card_large_padding">32dp</dimen> <dimen name="card_padding">16dp</dimen> <dimen name="card_margin">16dp</dimen> + <dimen name="card_icon_padding">5dp</dimen> <!-- Card Buttons --> <dimen name="card_action_text">12sp</dimen> diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index e078b39..b8080f5 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -49,6 +49,28 @@ <string name="unit_last_address">Last position address</string> <string name="unit_last_date">Last position datetime</string> + <string name="unit_category_animal">Animal</string> + <string name="unit_category_bicycle">Bicycle</string> + <string name="unit_category_boat">Boat</string> + <string name="unit_category_bus">Bus</string> + <string name="unit_category_car">Car</string> + <string name="unit_category_crane">Crane</string> + <string name="unit_category_default">Default</string> + <string name="unit_category_helicopter">Helicopter</string> + <string name="unit_category_motorcycle">Motorcycle</string> + <string name="unit_category_offroad">Offroad</string> + <string name="unit_category_person">Person</string> + <string name="unit_category_pickup">Pickup</string> + <string name="unit_category_plane">Plane</string> + <string name="unit_category_scooter">Scooter</string> + <string name="unit_category_ship">Ship</string> + <string name="unit_category_tractor">Tractor</string> + <string name="unit_category_train">Train</string> + <string name="unit_category_tram">Tram</string> + <string name="unit_category_trolleybus">Trolleybus</string> + <string name="unit_category_truck">Truck</string> + <string name="unit_category_van">Van</string> + <!-- Details --> <string name="unit_details">Details</string> <string name="unit_reports">Reports</string> |