aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp/src/main')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt40
-rw-r--r--androidApp/src/main/res/layout/unit_details_information.xml65
-rw-r--r--androidApp/src/main/res/values/dimen.xml2
-rw-r--r--androidApp/src/main/res/values/strings.xml2
4 files changed, 55 insertions, 54 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 1af8ec3..758ba36 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
@@ -5,9 +5,13 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.TableRow
+import android.widget.TextView
import androidx.fragment.app.Fragment
+import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UnitDetailsInformationBinding
import mx.trackermap.TrackerMap.android.details.UnitDetailsAdapter
+import mx.trackermap.TrackerMap.client.models.UnitInformation
import org.koin.androidx.viewmodel.ext.android.viewModel
class UnitInformationFragment : Fragment() {
@@ -42,13 +46,7 @@ class UnitInformationFragment : Fragment() {
unitInformationViewModel.unit.observe(this) { unitInformation ->
Log.d("UnitInformationFragment", "Unit Information Fetched - $unitInformation")
unitInformation?.let {
- binding.deviceName.text = it.device.name
- binding.driverDetail.text = it.device.contact
- binding.speedDetail.text = "${it.position?.speed?.times(1.852) ?: "--"} Km/h"
- binding.addressDetail.text = it.position?.address ?: "Unknown location"
- binding.latitudeDetail.text = it.position?.latitude.toString()
- binding.longitudeDetail.text = it.position?.longitude.toString()
- binding.protocolDetail.text = it.position?.protocol ?: "--"
+ displayInformation(it)
}
}
}
@@ -57,4 +55,32 @@ class UnitInformationFragment : Fragment() {
val id = arguments?.getInt(UnitDetailsAdapter.DEVICE_ID_ARG)
unitInformationViewModel.fetchUnit(id ?: 0)
}
+
+ private fun displayInformation(unit: UnitInformation) {
+ val context = context!!
+ val details: MutableMap<String, String> = mutableMapOf()
+ details["Contact"] = unit.device.contact ?: ""
+ details["Speed"] = context.getString(
+ R.string.unit_speed_format,
+ unit.position?.speed?.toInt() ?: 0
+ )
+ details["Address"] = unit.position?.address ?: ""
+ details["Latitude"] = "${unit.position?.latitude}"
+ details["Longitude"] = "${unit.position?.longitude}"
+ details["Protocol"] = unit.position?.protocol ?: ""
+
+ binding.nameDetail.text = unit.device.name
+ details.forEach { entry ->
+ val row = TableRow(context)
+ val keyText = TextView(context)
+ val valueText = TextView(context)
+
+ row.addView(keyText)
+ row.addView(valueText)
+ binding.informationTable.addView(row)
+
+ keyText.text = entry.key
+ valueText.text = entry.value
+ }
+ }
} \ No newline at end of file
diff --git a/androidApp/src/main/res/layout/unit_details_information.xml b/androidApp/src/main/res/layout/unit_details_information.xml
index dae2056..f4b6fae 100644
--- a/androidApp/src/main/res/layout/unit_details_information.xml
+++ b/androidApp/src/main/res/layout/unit_details_information.xml
@@ -22,60 +22,31 @@
android:orientation="vertical">
<TextView
- android:id="@+id/deviceName"
+ android:id="@+id/nameDetail"
+ style="@style/TextAppearance.AppCompat.Headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
- android:textSize="26dp"
tools:text="1AAUTO" />
- <TextView
- android:id="@+id/driverDetail"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="Javier Zavala" />
-
- <TextView
- android:id="@+id/speedDetail"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="0Km/h - Stopped" />
-
- <TextView
- android:id="@+id/addressDetail"
+ <TableLayout
+ android:id="@+id/informationTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="404 Av. Arboledas, Celaya, Gto." />
-
- <TextView
- android:id="@+id/latitudeDetail"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="20.32958356" />
-
- <TextView
- android:id="@+id/longitudeDetail"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="-101.38659274" />
-
- <TextView
- android:id="@+id/protocolDetail"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="18dp"
- tools:text="osmand" />
+ android:stretchColumns="*">
+ <TableRow
+ android:background="@color/colorPrimary">
+ <TextView
+ android:text="@string/key"
+ android:textColor="@color/background"
+ android:paddingHorizontal="@dimen/padding"/>
+
+ <TextView
+ android:text="@string/value"
+ android:textColor="@color/background"
+ android:paddingHorizontal="@dimen/padding"/>
+ </TableRow>
+ </TableLayout>
</LinearLayout>
diff --git a/androidApp/src/main/res/values/dimen.xml b/androidApp/src/main/res/values/dimen.xml
index cd4d970..6ce7887 100644
--- a/androidApp/src/main/res/values/dimen.xml
+++ b/androidApp/src/main/res/values/dimen.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
+ <dimen name="padding">8dp</dimen>
+
<!-- CardView -->
<dimen name="card_border_radius">20dp</dimen>
<dimen name="card_elevation">8dp</dimen>
diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml
index f4d69fb..5692688 100644
--- a/androidApp/src/main/res/values/strings.xml
+++ b/androidApp/src/main/res/values/strings.xml
@@ -23,4 +23,6 @@
<string name="unit_reports">Reports</string>
<string name="unit_commands">Commands</string>
<string name="units_search">Type to search</string>
+ <string name="key">Key</string>
+ <string name="value">Value</string>
</resources> \ No newline at end of file