diff options
Diffstat (limited to 'androidApp/src/main')
11 files changed, 222 insertions, 40 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 4aa210d..dd7333d 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 @@ -1,9 +1,15 @@ package mx.trackermap.TrackerMap.android.devices +import android.graphics.Color +import android.graphics.ColorFilter +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.ViewStructure +import androidx.core.content.res.ResourcesCompat import androidx.recyclerview.widget.RecyclerView +import kotlinx.serialization.json.JsonNull import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.android.databinding.UnitItemBinding import mx.trackermap.TrackerMap.client.models.UnitInformation @@ -29,11 +35,46 @@ class DevicesAdapter( holder.toggleOptions(false) val unit = units[position] + val context = holder.itemView.context holder.binding.apply { + + unit.position?.let { position -> + /* Status icon */ + position.speed?.let { speed -> + if (speed >= 2) { + statusIcon.setColorFilter(Color.GREEN) + } else { + statusIcon.setColorFilter(Color.RED) + } + } ?: run { + statusIcon.setColorFilter(Color.GRAY) + } + + /* Engine stop */ + val attributes = position.attributes + if (attributes["out1"].toString() == "null") { + engineStopIcon.visibility = View.GONE + } else { + engineStopIcon.visibility = View.VISIBLE + engineStopIcon.setImageResource( + when (attributes["out1"].toString()) { + "true" -> R.drawable.ic_baseline_lock_24 + "false" -> R.drawable.ic_baseline_lock_open_24 + else -> R.drawable.ic_baseline_lock_open_24 + } + ) + engineStopIcon.contentDescription = when (attributes["out1"].toString()) { + "true" -> context.getString(R.string.unit_lock_on) + "false" -> context.getString(R.string.unit_lock_off) + else -> context.getString(R.string.unit_lock_on) + } + } + } + unitName.text = unit.device.name driverName.text = unit.device.contact - unitSpeed.text = "${unit.position?.speed ?: "--"} Km/h" - lastAddress.text = unit.position?.address ?: "Unknown location" + unitSpeed.text = context.getString(R.string.unit_speed_format, unit.position?.speed?.toInt() ?: 0) + lastAddress.text = unit.position?.address lastDate.text = "yyyy/mm/dd, hh:mm" actionCallback?.let { callback -> detailsButton.setOnClickListener { callback(unit, Action.DETAILS) } @@ -55,9 +96,11 @@ class DevicesAdapter( fun toggleOptions(shouldExpand: Boolean) { val context = binding.root.context binding.unitCard.setCardBackgroundColor( - context - .resources - .getColor(if (shouldExpand) R.color.background else R.color.darkBackground) + ResourcesCompat.getColor( + context.resources, + if (shouldExpand) R.color.background else R.color.darkBackground, + context.theme + ) ) binding.itemOptions.visibility = if (shouldExpand) View.VISIBLE else View.GONE binding.unitCard.cardElevation = if (shouldExpand) 5.0F else 0.0F diff --git a/androidApp/src/main/res/drawable/ic_baseline_calendar_today_24.xml b/androidApp/src/main/res/drawable/ic_baseline_calendar_today_24.xml new file mode 100644 index 0000000..e059617 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_calendar_today_24.xml @@ -0,0 +1,5 @@ +<vector android:height="14dp" android:tint="?attr/colorControlNormal" + android:viewportHeight="24" android:viewportWidth="24" + android:width="14sp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M20,3h-1L19,1h-2v2L7,3L7,1L5,1v2L4,3c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,5c0,-1.1 -0.9,-2 -2,-2zM20,21L4,21L4,8h16v13z"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_fiber_manual_record_24.xml b/androidApp/src/main/res/drawable/ic_baseline_fiber_manual_record_24.xml new file mode 100644 index 0000000..13890d5 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_fiber_manual_record_24.xml @@ -0,0 +1,5 @@ +<vector android:height="14dp" android:tint="?attr/colorControlNormal" + android:viewportHeight="24" android:viewportWidth="24" + android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_location_on_24.xml b/androidApp/src/main/res/drawable/ic_baseline_location_on_24.xml new file mode 100644 index 0000000..71ef7bc --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_location_on_24.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="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_lock_24.xml b/androidApp/src/main/res/drawable/ic_baseline_lock_24.xml new file mode 100644 index 0000000..ed352bf --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_lock_24.xml @@ -0,0 +1,5 @@ +<vector android:height="14sp" android:tint="#B71C1C" + android:viewportHeight="24" android:viewportWidth="24" + android:width="14sp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_lock_open_24.xml b/androidApp/src/main/res/drawable/ic_baseline_lock_open_24.xml new file mode 100644 index 0000000..1fe62c8 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_lock_open_24.xml @@ -0,0 +1,5 @@ +<vector android:height="14sp" android:tint="#1B5E20" + android:viewportHeight="24" android:viewportWidth="24" + android:width="14sp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM18,20L6,20L6,10h12v10z"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_person_24.xml b/androidApp/src/main/res/drawable/ic_baseline_person_24.xml new file mode 100644 index 0000000..0faf05d --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_person_24.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="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/> +</vector> diff --git a/androidApp/src/main/res/drawable/ic_baseline_speed_24.xml b/androidApp/src/main/res/drawable/ic_baseline_speed_24.xml new file mode 100644 index 0000000..febd057 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_speed_24.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="M20.38,8.57l-1.23,1.85a8,8 0,0 1,-0.22 7.58L5.07,18A8,8 0,0 1,15.58 6.85l1.85,-1.23A10,10 0,0 0,3.35 19a2,2 0,0 0,1.72 1h13.85a2,2 0,0 0,1.74 -1,10 10,0 0,0 -0.27,-10.44zM10.59,15.41a2,2 0,0 0,2.83 0l5.66,-8.49 -8.49,5.66a2,2 0,0 0,0 2.83z"/> +</vector> diff --git a/androidApp/src/main/res/layout/unit_item.xml b/androidApp/src/main/res/layout/unit_item.xml index 98fcb1b..f7ace03 100644 --- a/androidApp/src/main/res/layout/unit_item.xml +++ b/androidApp/src/main/res/layout/unit_item.xml @@ -9,56 +9,134 @@ app:cardCornerRadius="@dimen/card_border_radius" app:cardElevation="0dp" app:cardUseCompatPadding="true" - app:contentPadding="16dp"> + app:contentPadding="@dimen/card_padding"> - <LinearLayout + <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" android:animateLayoutChanges="true"> - <TextView - android:id="@+id/unitName" - android:layout_width="match_parent" + <ImageView + android:id="@+id/statusIcon" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="26dp" - tools:text="1AAUTO" /> + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_fiber_manual_record_24" + app:tint="?android:textColorPrimary" /> - <TextView - android:id="@+id/driverName" - android:layout_width="match_parent" + <ImageView + android:id="@+id/engineStopIcon" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="18dp" - tools:text="Javier Zavala" /> + android:layout_toEndOf="@id/statusIcon" + android:visibility="gone" + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_lock_24" /> <TextView - android:id="@+id/unitSpeed" + android:id="@+id/unitName" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textSize="18dp" - tools:text="0 Km/h - Stopped" /> + android:layout_toEndOf="@id/engineStopIcon" + style="@style/TextAppearance.AppCompat.Body2" + tools:text="1AAUTO" /> - <TextView - android:id="@+id/lastAddress" + <GridLayout + android:id="@+id/gridLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textSize="18dp" - tools:text="1000 Emerald Pools, CA" /> + android:layout_below="@id/unitName"> - <TextView - android:id="@+id/lastDate" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="18dp" - tools:text="4 de Diciembre de 2021, 7:00 PM" /> + <ImageView + android:id="@+id/driverNameIcon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="6dp" + android:layout_column="0" + android:layout_row="1" + android:contentDescription="@string/unit_driver_name" + android:src="@drawable/ic_baseline_person_24" + app:tint="?android:textColorSecondary" /> + + <TextView + android:id="@+id/driverName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_column="1" + android:layout_row="1" + style="@style/TextAppearance.AppCompat.Caption" + tools:text="Javier Zavala" /> + + <ImageView + android:id="@+id/unitSpeedIcon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_column="0" + android:layout_row="2" + style="@style/TextAppearance.MaterialComponents.Caption" + android:contentDescription="@string/unit_speed" + android:src="@drawable/ic_baseline_speed_24" + app:tint="?android:textColorSecondary" /> + + <TextView + android:id="@+id/unitSpeed" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_column="1" + android:layout_row="2" + style="@style/TextAppearance.AppCompat.Caption" + tools:text="0 Km/h - Stopped" /> + + <ImageView + android:id="@+id/lastAddressIcon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_column="0" + android:layout_row="3" + android:contentDescription="@string/unit_last_address" + android:src="@drawable/ic_baseline_location_on_24" + app:tint="?android:textColorSecondary" /> + + <TextView + android:id="@+id/lastAddress" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_column="1" + android:layout_row="3" + style="@style/TextAppearance.AppCompat.Caption" + tools:text="1000 Emerald Pools, CA" /> + + <ImageView + android:id="@+id/lastDateIcon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_column="0" + android:layout_row="4" + android:contentDescription="@string/unit_last_date" + android:src="@drawable/ic_baseline_calendar_today_24" + app:tint="?android:textColorSecondary" /> + + + <TextView + android:id="@+id/lastDate" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_column="1" + android:layout_row="4" + style="@style/TextAppearance.AppCompat.Caption" + tools:text="4 de Diciembre de 2021, 7:00 PM" /> + + </GridLayout> <LinearLayout android:id="@+id/itemOptions" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_below="@id/gridLayout" + android:layout_marginTop="@dimen/card_padding" android:gravity="center" android:orientation="horizontal" - android:visibility="gone"> + android:visibility="visible"> <com.google.android.material.button.MaterialButton android:id="@+id/detailsButton" @@ -66,8 +144,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/unit_details" - android:textColor="@color/colorPrimaryDark" - app:backgroundTint="@color/darkBackground" /> + android:textColor="@color/colorAccent" + style="?borderlessButtonStyle" /> <com.google.android.material.button.MaterialButton android:id="@+id/reportsButton" @@ -76,8 +154,8 @@ android:layout_marginHorizontal="8dp" android:layout_weight="1" android:text="@string/unit_reports" - android:textColor="@color/colorPrimaryDark" - app:backgroundTint="@color/darkBackground" /> + android:textColor="@color/colorAccent" + style="?borderlessButtonStyle" /> <com.google.android.material.button.MaterialButton android:id="@+id/commandsButton" @@ -85,11 +163,11 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/unit_commands" - android:textColor="@color/colorPrimaryDark" - app:backgroundTint="@color/darkBackground" /> + android:textColor="@color/colorAccent" + style="?borderlessButtonStyle" /> </LinearLayout> - </LinearLayout> + </RelativeLayout> </com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/androidApp/src/main/res/layout/units_activity.xml b/androidApp/src/main/res/layout/units_activity.xml index 4f4ee77..f0d80ab 100644 --- a/androidApp/src/main/res/layout/units_activity.xml +++ b/androidApp/src/main/res/layout/units_activity.xml @@ -37,7 +37,7 @@ app:layout_constraintBottom_toBottomOf="@id/displayModeToggle" android:layout_marginVertical="@dimen/search_vertical_margin" android:layout_marginHorizontal="@dimen/search_horizontal_margin" - app:cardCornerRadius="25dp" + app:cardCornerRadius="@dimen/card_border_radius" app:cardElevation="@dimen/card_elevation"> <com.google.android.material.textfield.TextInputEditText diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 0a42223..f4d69fb 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -8,6 +8,17 @@ <string name="login_login">Login</string> <!-- Unit Item --> + <string name="unit_status_on">Status on</string> + <string name="unit_status_off">Status off</string> + <string name="unit_lock_on">Engine stop on</string> + <string name="unit_lock_off">Engine stop off</string> + <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_last_date">Last position datetime</string> + + <string name="unit_speed_format">%1$d km/h</string> + <string name="unit_details">Details</string> <string name="unit_reports">Reports</string> <string name="unit_commands">Commands</string> |