Add "use trkpt as start" and "use trkpt as end" buttons.

This commit is contained in:
voussoir 2023-03-30 18:40:11 -07:00
parent 9209a30c14
commit 1ef59f49f5
4 changed files with 98 additions and 2 deletions

View file

@ -78,6 +78,8 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
private lateinit var datepicker_changed_listener: DatePicker.OnDateChangedListener
private var datetime_change_listener_enabled: Boolean = true
lateinit var delete_selected_trkpt_button: ImageButton
lateinit var use_trkpt_as_start_button: ImageButton
lateinit var use_trkpt_as_end_button: ImageButton
lateinit var isolate_trkseg_button: ImageButton
lateinit var when_was_i_here_button: ImageButton
var track_query_start_time_previous: Int = 0
@ -262,6 +264,40 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
}
}
use_trkpt_as_start_button = rootView.findViewById(R.id.use_trkpt_as_start_button)
use_trkpt_as_start_button.setOnClickListener {
Log.i("VOUSSOIR", "use selected trkpt as start.")
if (track_points_overlay != null && track_points_overlay!!.selectedPoint != null)
{
val selected = (track_geopoints[track_points_overlay!!.selectedPoint] as Trkpt)
set_datetime(track_query_start_date, track_query_start_time, Date(selected.time), _ending=false)
track.load_trkpts(trackbook.database.select_trkpt_start_end(
track.device_id,
selected.time,
track.trkpts.last().time,
))
deselect_trkpt()
render_track()
}
}
use_trkpt_as_end_button = rootView.findViewById(R.id.use_trkpt_as_end_button)
use_trkpt_as_end_button.setOnClickListener {
Log.i("VOUSSOIR", "use selected trkpt as end.")
if (track_points_overlay != null && track_points_overlay!!.selectedPoint != null)
{
val selected = (track_geopoints[track_points_overlay!!.selectedPoint] as Trkpt)
set_datetime(track_query_end_date, track_query_end_time, Date(selected.time), _ending=true)
track.load_trkpts(trackbook.database.select_trkpt_start_end(
track.device_id,
track.trkpts.first().time,
selected.time,
))
deselect_trkpt()
render_track()
}
}
isolate_trkseg_button = rootView.findViewById(R.id.isolate_trkseg_button)
isolate_trkseg_button.setOnClickListener {
Log.i("VOUSSOIR", "isolate selected trkseg button.")
@ -358,6 +394,8 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
track_points_overlay!!.selectedPoint = null
}
delete_selected_trkpt_button.visibility = View.GONE
use_trkpt_as_start_button.visibility = View.GONE
use_trkpt_as_end_button.visibility = View.GONE
isolate_trkseg_button.visibility = View.GONE
selected_trkpt_info.text = ""
}
@ -428,6 +466,8 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
Log.i("VOUSSOIR", "Clicked ${trkpt.device_id} ${trkpt.time}")
selected_trkpt_info.text = "${trkpt.time}\n${iso8601_local(trkpt.time)}\n${trkpt.latitude}\n${trkpt.longitude}"
delete_selected_trkpt_button.visibility = View.VISIBLE
use_trkpt_as_start_button.visibility = View.VISIBLE
use_trkpt_as_end_button.visibility = View.VISIBLE
if (track_segment_overlays.size > 1)
{
isolate_trkseg_button.visibility = View.VISIBLE
@ -455,6 +495,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
fun set_datetime(datepicker: DatePicker, timepicker: TimePicker, setdate: Date, _ending: Boolean)
{
datetime_change_listener_enabled = false
val start_cal = GregorianCalendar()
start_cal.time = setdate
datepicker.init(start_cal.get(Calendar.YEAR), start_cal.get(Calendar.MONTH), start_cal.get(Calendar.DAY_OF_MONTH), datepicker_changed_listener)
@ -470,6 +511,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
{
track_query_start_time_previous = (setdate.hours * 60) + setdate.minutes
}
datetime_change_listener_enabled = true
}
fun set_datetimes_from_track()
@ -478,10 +520,8 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
{
return
}
datetime_change_listener_enabled = false
set_datetime(track_query_start_date, track_query_start_time, Date(track.trkpts.first().time), _ending=false)
set_datetime(track_query_end_date, track_query_end_time, Date(track.trkpts.last().time), _ending=true)
datetime_change_listener_enabled = true
}
fun get_datetime(datepicker: DatePicker, timepicker: TimePicker, seconds: Int): Date

View file

@ -0,0 +1,16 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:name="group">
<path
android:pathData="M 12.033 5.563 L 10.619 6.978 L 14.639 11.001 L 1.715 11.001 L 1.715 13.001 L 14.643 13.001 L 10.619 17.022 L 12.033 18.437 L 17.055 13.415 L 18.469 12.003 L 17.055 10.587 Z"
android:fillColor="@color/icon_default"/>
<path
android:pathData="M 16.981 6.696 C 16.114 6.698 15.261 6.912 14.496 7.319 L 17.408 10.233 L 19.178 12.003 L 17.408 13.769 L 14.494 16.683 C 15.26 17.09 16.113 17.304 16.981 17.306 C 19.911 17.306 22.286 14.931 22.285 12.001 C 22.286 9.071 19.911 6.696 16.981 6.696 Z"
android:fillColor="@color/icon_default"/>
</group>
</vector>

View file

@ -0,0 +1,16 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:name="group">
<path
android:pathData="M 15.563 5.563 L 14.148 6.978 L 18.168 11.001 L 5.244 11.001 L 5.244 13.001 L 18.172 13.001 L 14.148 17.022 L 15.563 18.437 L 20.584 13.415 L 21.998 12.003 L 20.584 10.587 Z"
android:fillColor="@color/icon_default"/>
<path
android:pathData="M 7.307 6.696 C 6.375 6.696 5.461 6.941 4.654 7.407 C 3.848 7.872 3.178 8.542 2.712 9.348 C 2.247 10.155 2.002 11.07 2.002 12.001 C 2.002 12.932 2.247 13.847 2.712 14.654 C 3.178 15.46 3.848 16.13 4.654 16.595 C 5.461 17.061 6.375 17.306 7.307 17.306 C 8.451 17.305 9.565 16.934 10.481 16.248 C 11.397 15.563 12.067 14.599 12.391 13.501 L 4.742 13.501 L 4.742 10.501 L 12.389 10.501 C 12.065 9.404 11.396 8.44 10.48 7.754 C 9.564 7.069 8.451 6.697 7.307 6.696 Z M 5.744 11.501 L 5.744 12.501 L 12.586 12.501 C 12.602 12.335 12.609 12.168 12.609 12.001 C 12.607 11.834 12.598 11.667 12.58 11.501 Z"
android:fillColor="@color/icon_default"/>
</group>
</vector>

View file

@ -83,6 +83,30 @@
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_gps_24dp" />
<ImageButton
android:id="@+id/use_trkpt_as_end_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tooltipText="End here"
android:src="@drawable/ic_end_here_24dp"
android:visibility="gone"
app:backgroundTint="@color/default_transparent"
app:layout_constraintTop_toBottomOf="@+id/when_was_i_here_button"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_end_here_24dp" />
<ImageButton
android:id="@+id/use_trkpt_as_start_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tooltipText="Start here"
android:src="@drawable/ic_start_here_24dp"
android:visibility="gone"
app:backgroundTint="@color/default_transparent"
app:layout_constraintTop_toTopOf="@+id/use_trkpt_as_end_button"
app:layout_constraintEnd_toStartOf="@+id/use_trkpt_as_end_button"
app:srcCompat="@drawable/ic_start_here_24dp" />
<ImageButton
android:id="@+id/isolate_trkseg_button"
android:layout_width="wrap_content"