Merge pull request #114 from voussoir/clearconfirm

Add yes/no prompt before clearing active track.
This commit is contained in:
y20k 2022-04-05 21:19:48 +02:00 committed by GitHub
commit 1bb09dc000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>