diff --git a/app/src/main/java/org/y20k/trackbook/Keys.kt b/app/src/main/java/org/y20k/trackbook/Keys.kt index eff5dd3..21424d8 100644 --- a/app/src/main/java/org/y20k/trackbook/Keys.kt +++ b/app/src/main/java/org/y20k/trackbook/Keys.kt @@ -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 = "" diff --git a/app/src/main/java/org/y20k/trackbook/MapFragment.kt b/app/src/main/java/org/y20k/trackbook/MapFragment.kt index 14de1c3..7de5274 100644 --- a/app/src/main/java/org/y20k/trackbook/MapFragment.kt +++ b/app/src/main/java/org/y20k/trackbook/MapFragment.kt @@ -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() + } + } + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a2f6e0e..c6571fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,9 @@ Save Resume + Clear recorded points? + Clear all points and start a new track. + Clear Cancel OK Show details