diff options
Diffstat (limited to 'androidApp')
-rw-r--r-- | androidApp/build.gradle.kts | 1 | ||||
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt | 24 | ||||
-rw-r--r-- | androidApp/src/main/res/layout/unit_item.xml | 314 |
3 files changed, 170 insertions, 169 deletions
diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 0e25404..01508ac 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -36,5 +36,6 @@ dependencies { implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("io.ktor:ktor-client-serialization:1.6.6") + implementation("com.github.zerobranch:SwipeLayout:1.3.1") implementation(group = "", name = "WhirlyGlobeMaply", ext = "aar") }
\ No newline at end of file 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 c54e8bf..4852757 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 @@ -32,8 +32,6 @@ class DevicesAdapter( } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.toggleOptions(false) - val unit = units[position] val context = holder.itemView.context holder.binding.apply { @@ -86,25 +84,5 @@ class DevicesAdapter( override fun getItemCount(): Int = units.size - inner class ViewHolder(val binding: UnitItemBinding) : RecyclerView.ViewHolder(binding.root) { - init { - binding.unitCard.setOnLongClickListener { - toggleOptions(binding.itemOptions.visibility == View.GONE) - true - } - } - - fun toggleOptions(shouldExpand: Boolean) { - val context = binding.root.context - binding.unitCard.setCardBackgroundColor( - 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 - } - } + inner class ViewHolder(val binding: UnitItemBinding) : RecyclerView.ViewHolder(binding.root) }
\ 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 f7ace03..8b6b667 100644 --- a/androidApp/src/main/res/layout/unit_item.xml +++ b/androidApp/src/main/res/layout/unit_item.xml @@ -1,173 +1,195 @@ <?xml version="1.0" encoding="utf-8"?> -<com.google.android.material.card.MaterialCardView +<com.zerobranch.layout.SwipeLayout + android:id="@+id/swipeLayout" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/unitCard" android:layout_width="match_parent" android:layout_height="wrap_content" - app:cardCornerRadius="@dimen/card_border_radius" - app:cardElevation="0dp" - app:cardUseCompatPadding="true" - app:contentPadding="@dimen/card_padding"> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:animateLayoutChanges="true"> - - <ImageView - android:id="@+id/statusIcon" + app:draggedItem="@id/unitCard" + app:rightItem="@id/itemOptions" + app:swipeDirection="left"> + + <LinearLayout + android:id="@+id/itemOptions" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="end" + android:paddingTop="@dimen/card_padding" + android:paddingBottom="@dimen/card_padding" + android:paddingEnd="@dimen/card_padding" + android:gravity="center" + android:orientation="horizontal" + android:visibility="visible"> + + <com.google.android.material.button.MaterialButton + android:id="@+id/detailsButton" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="5dp" - android:src="@drawable/ic_baseline_fiber_manual_record_24" - app:tint="?android:textColorPrimary" /> - - <ImageView - android:id="@+id/engineStopIcon" + android:layout_height="match_parent" + android:layout_weight="1" + app:cardBackgroundColor="@color/colorAccent" + android:text="@string/unit_details" + android:textColor="@color/colorAccent" + android:textSize="12sp" + style="?borderlessButtonStyle" /> + + <com.google.android.material.button.MaterialButton + android:id="@+id/reportsButton" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toEndOf="@id/statusIcon" - android:visibility="gone" - android:layout_marginEnd="5dp" - android:src="@drawable/ic_baseline_lock_24" /> + android:layout_height="match_parent" + android:layout_marginHorizontal="8dp" + android:layout_weight="1" + android:text="@string/unit_reports" + android:textColor="@color/colorAccent" + android:textSize="12sp" + style="?borderlessButtonStyle" /> + + <com.google.android.material.button.MaterialButton + android:id="@+id/commandsButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:text="@string/unit_commands" + android:textColor="@color/colorAccent" + android:textSize="12sp" + style="?borderlessButtonStyle" /> - <TextView - android:id="@+id/unitName" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_toEndOf="@id/engineStopIcon" - style="@style/TextAppearance.AppCompat.Body2" - tools:text="1AAUTO" /> + </LinearLayout> - <GridLayout - android:id="@+id/gridLayout" + <com.google.android.material.card.MaterialCardView + android:id="@+id/unitCard" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="visible" + android:foreground="?android:attr/selectableItemBackground" + app:cardCornerRadius="@dimen/card_border_radius" + app:cardElevation="0dp" + app:cardUseCompatPadding="true" + app:contentPadding="@dimen/card_padding" + app:cardBackgroundColor="@color/darkBackground" + android:clickable="true" + android:focusable="true"> + + <RelativeLayout + android:id="@+id/mainContent" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/unitName"> + android:animateLayoutChanges="true"> <ImageView - android:id="@+id/driverNameIcon" + android:id="@+id/statusIcon" 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" /> + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_fiber_manual_record_24" + app:tint="?android:textColorPrimary" /> <ImageView - android:id="@+id/lastAddressIcon" + android:id="@+id/engineStopIcon" 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" /> + android:layout_toEndOf="@id/statusIcon" + android:visibility="gone" + android:layout_marginEnd="5dp" + android:src="@drawable/ic_baseline_lock_24" /> <TextView - android:id="@+id/lastAddress" + android:id="@+id/unitName" 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" /> + android:layout_toEndOf="@id/engineStopIcon" + style="@style/TextAppearance.AppCompat.Body2" + tools:text="1AAUTO" /> - - <TextView - android:id="@+id/lastDate" + <GridLayout + android:id="@+id/gridLayout" 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="visible"> - - <com.google.android.material.button.MaterialButton - android:id="@+id/detailsButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="@string/unit_details" - android:textColor="@color/colorAccent" - style="?borderlessButtonStyle" /> - - <com.google.android.material.button.MaterialButton - android:id="@+id/reportsButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" - android:layout_weight="1" - android:text="@string/unit_reports" - android:textColor="@color/colorAccent" - style="?borderlessButtonStyle" /> - - <com.google.android.material.button.MaterialButton - android:id="@+id/commandsButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="@string/unit_commands" - android:textColor="@color/colorAccent" - style="?borderlessButtonStyle" /> - - </LinearLayout> - - </RelativeLayout> - -</com.google.android.material.card.MaterialCardView>
\ No newline at end of file + android:layout_below="@id/unitName"> + + <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> + + </RelativeLayout> + + </com.google.android.material.card.MaterialCardView> + +</com.zerobranch.layout.SwipeLayout>
\ No newline at end of file |