Add yes/no prompt before clearing active track.

This commit is contained in:
voussoir 2022-04-04 14:14:01 -07:00
parent 472f71f036
commit 517954020a
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
3 changed files with 20 additions and 1 deletions

View file

@ -73,6 +73,7 @@ object Keys {
const val DIALOG_EMPTY_RECORDING: Int = 0
const val DIALOG_DELETE_TRACK: Int = 1
const val DIALOG_DELETE_NON_STARRED: Int = 2
const val DIALOG_CLEAR_RECORDING: Int = 3
// dialog results
const val DIALOG_EMPTY_PAYLOAD_STRING: String = ""

View file

@ -90,7 +90,15 @@ class MapFragment : Fragment(), YesNoDialog.YesNoDialogListener, MapOverlayHelpe
saveTrack()
}
layout.clearButton.setOnClickListener {
trackerService.clearTrack()
if (track.wayPoints.isNotEmpty()) {
YesNoDialog(this as YesNoDialog.YesNoDialogListener).show(
context=activity as Context,
type = Keys.DIALOG_CLEAR_RECORDING,
title = R.string.dialog_clear_recording_title,
message = R.string.dialog_clear_recording_message,
yesButton = R.string.dialog_clear_recording_action_resume
)
}
}
layout.resumeButton.setOnClickListener {
resumeTracking()
@ -192,6 +200,13 @@ class MapFragment : Fragment(), YesNoDialog.YesNoDialogListener, MapOverlayHelpe
}
}
}
Keys.DIALOG_CLEAR_RECORDING -> {
when (dialogResult) {
true -> {
trackerService.clearTrack()
}
}
}
}
}

View file

@ -24,6 +24,9 @@
<string name="fab_sub_menu_save">Save</string>
<string name="fab_sub_menu_resume">Resume</string>
<!-- Dialogs -->
<string name="dialog_clear_recording_title">Clear recorded points?</string>
<string name="dialog_clear_recording_message">Clear all points and start a new track.</string>
<string name="dialog_clear_recording_action_resume">Clear</string>
<string name="dialog_generic_button_cancel">Cancel</string>
<string name="dialog_generic_button_okay">OK</string>
<string name="dialog_generic_details_button">Show details</string>