aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2021-12-28 15:54:15 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2021-12-28 15:54:15 -0600
commit085b644ef248be85ef16550917e9c705e02b8f85 (patch)
treec4b2b322ac61ef63e4ea938a39cb7963363ce41b /androidApp/src
parentf37c6de28b014af0cdbf278986a668030f54cc55 (diff)
downloadetbsa-trackermap-mobile-085b644ef248be85ef16550917e9c705e02b8f85.tar.gz
etbsa-trackermap-mobile-085b644ef248be85ef16550917e9c705e02b8f85.tar.bz2
etbsa-trackermap-mobile-085b644ef248be85ef16550917e9c705e02b8f85.zip
Adds period selection UI
Diffstat (limited to 'androidApp/src')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt33
-rw-r--r--androidApp/src/main/res/layout/unit_details_reports.xml112
-rw-r--r--androidApp/src/main/res/menu/report_period_options.xml17
-rw-r--r--androidApp/src/main/res/values/strings.xml12
4 files changed, 132 insertions, 42 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
index dfc0493..9131728 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
@@ -5,7 +5,9 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.PopupMenu
import androidx.fragment.app.Fragment
+import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UnitDetailsReportsBinding
import mx.trackermap.TrackerMap.android.details.UnitDetailsAdapter
import org.koin.androidx.viewmodel.ext.android.viewModel
@@ -48,6 +50,9 @@ class UnitReportsFragment : Fragment() {
else -> UnitReportsViewModel.ReportType.STOPS
}
}
+ binding.periodButton.setOnClickListener {
+ showPeriodPopUp(it)
+ }
unitReportsViewModel.reportPeriod.value = UnitReportsViewModel.ReportPeriod.DAY
unitReportsViewModel.reportType.value = UnitReportsViewModel.ReportType.POSITIONS
}
@@ -56,5 +61,33 @@ class UnitReportsFragment : Fragment() {
unitReportsViewModel.report.observe(this) { report ->
Log.d("UnitReportsFragment", "Report available: $report")
}
+ unitReportsViewModel.reportPeriod.observe(this) { period ->
+ Log.d("UnitReportsFragment", "Period changed: $period")
+ if (period == null) {
+ return@observe
+ }
+
+ binding.periodButton.text = context?.getString(
+ when (period) {
+ UnitReportsViewModel.ReportPeriod.DAY -> R.string.day_period
+ UnitReportsViewModel.ReportPeriod.WEEK -> R.string.week_period
+ UnitReportsViewModel.ReportPeriod.MONTH -> R.string.month_period
+ }
+ )
+ }
+ }
+
+ private fun showPeriodPopUp(view: View) {
+ val popOver = PopupMenu(context, view)
+ popOver.menuInflater.inflate(R.menu.report_period_options, popOver.menu)
+ popOver.setOnMenuItemClickListener { item ->
+ unitReportsViewModel.reportPeriod.value = when (item.itemId) {
+ R.id.dayOption -> UnitReportsViewModel.ReportPeriod.DAY
+ R.id.weekOption -> UnitReportsViewModel.ReportPeriod.WEEK
+ else -> UnitReportsViewModel.ReportPeriod.MONTH
+ }
+ true
+ }
+ popOver.show()
}
} \ No newline at end of file
diff --git a/androidApp/src/main/res/layout/unit_details_reports.xml b/androidApp/src/main/res/layout/unit_details_reports.xml
index f064a3f..d0c50e5 100644
--- a/androidApp/src/main/res/layout/unit_details_reports.xml
+++ b/androidApp/src/main/res/layout/unit_details_reports.xml
@@ -5,52 +5,84 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <com.addisonelliott.segmentedbutton.SegmentedButtonGroup
- android:id="@+id/reportType"
- android:layout_width="0dp"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="@dimen/margin"
- app:borderWidth="1dp"
- app:dividerPadding="10dp"
- app:dividerWidth="1dp"
+ android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:position="0"
- app:radius="30dp"
- app:ripple="true"
- app:selectedBackground="@color/colorPrimary">
+ android:layout_margin="@dimen/margin">
- <com.addisonelliott.segmentedbutton.SegmentedButton
- android:layout_width="0dp"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:padding="10dp"
- app:drawableGravity="top"
- app:selectedTextColor="@color/darkBackground"
- app:text="@string/positions"
- app:textColor="@color/colorPrimaryDark" />
-
- <com.addisonelliott.segmentedbutton.SegmentedButton
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:padding="10dp"
- app:drawableGravity="top"
- app:selectedTextColor="@color/darkBackground"
- app:text="@string/events"
- app:textColor="@color/colorPrimaryDark" />
-
- <com.addisonelliott.segmentedbutton.SegmentedButton
- android:layout_width="0dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/period"
+ android:textColor="@color/colorPrimaryDark"
+ android:textSize="22sp"
+ android:gravity="center_vertical"/>
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/periodButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/select_period"
+ android:textColor="@color/colorPrimaryDark"
+ app:backgroundTint="@color/darkBackground" />
+
+ </LinearLayout>
+
+ <com.addisonelliott.segmentedbutton.SegmentedButtonGroup
+ android:id="@+id/reportType"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:padding="10dp"
- app:drawableGravity="top"
- app:selectedTextColor="@color/darkBackground"
- app:text="@string/stops"
- app:textColor="@color/colorPrimaryDark" />
-
- </com.addisonelliott.segmentedbutton.SegmentedButtonGroup>
+ android:layout_marginTop="@dimen/margin"
+ app:borderWidth="1dp"
+ app:dividerPadding="10dp"
+ app:dividerWidth="1dp"
+ app:position="0"
+ app:radius="30dp"
+ app:ripple="true"
+ app:selectedBackground="@color/colorPrimary">
+
+ <com.addisonelliott.segmentedbutton.SegmentedButton
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="10dp"
+ app:drawableGravity="top"
+ app:selectedTextColor="@color/darkBackground"
+ app:text="@string/positions"
+ app:textColor="@color/colorPrimaryDark" />
+
+ <com.addisonelliott.segmentedbutton.SegmentedButton
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="10dp"
+ app:drawableGravity="top"
+ app:selectedTextColor="@color/darkBackground"
+ app:text="@string/events"
+ app:textColor="@color/colorPrimaryDark" />
+
+ <com.addisonelliott.segmentedbutton.SegmentedButton
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="10dp"
+ app:drawableGravity="top"
+ app:selectedTextColor="@color/darkBackground"
+ app:text="@string/stops"
+ app:textColor="@color/colorPrimaryDark" />
+
+ </com.addisonelliott.segmentedbutton.SegmentedButtonGroup>
+
+ </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/androidApp/src/main/res/menu/report_period_options.xml b/androidApp/src/main/res/menu/report_period_options.xml
new file mode 100644
index 0000000..cf54ec3
--- /dev/null
+++ b/androidApp/src/main/res/menu/report_period_options.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/dayOption"
+ android:title="@string/day_period" />
+
+ <item
+ android:id="@+id/weekOption"
+ android:title="@string/week_period" />
+
+ <item
+ android:id="@+id/monthOption"
+ android:title="@string/month_period" />
+
+</menu> \ No newline at end of file
diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml
index ca9ff5e..77a3048 100644
--- a/androidApp/src/main/res/values/strings.xml
+++ b/androidApp/src/main/res/values/strings.xml
@@ -19,16 +19,24 @@
<string name="unit_speed_format">%1$d km/h</string>
+ <!-- Details -->
<string name="unit_details">Details</string>
<string name="unit_reports">Reports</string>
<string name="unit_commands">Commands</string>
<string name="units_search">Type to search</string>
-
+
+ <!-- Commads -->
<string name="key">Key</string>
<string name="value">Value</string>
<string name="send_command">Send Command</string>
-
+
+ <!-- Reports -->
<string name="positions">Positions</string>
<string name="events">Events</string>
<string name="stops">Stops</string>
+ <string name="day_period">Day</string>
+ <string name="week_period">Week</string>
+ <string name="month_period">Month</string>
+ <string name="period">Period</string>
+ <string name="select_period">Select</string>
</resources> \ No newline at end of file