From 7466f98bf3ae5f71245531a9cfac2f567c5fbe39 Mon Sep 17 00:00:00 2001 From: Milton Barrera Date: Wed, 4 Dec 2024 17:21:33 -0600 Subject: [PATCH 1/2] Fix #476: Resume tracking btn change the state to stopped --- app/src/main/java/net/osmtracker/activity/TrackManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/osmtracker/activity/TrackManager.java b/app/src/main/java/net/osmtracker/activity/TrackManager.java index 0c6c9b57..0f64e5bb 100644 --- a/app/src/main/java/net/osmtracker/activity/TrackManager.java +++ b/app/src/main/java/net/osmtracker/activity/TrackManager.java @@ -399,7 +399,9 @@ public boolean onContextItemSelected(MenuItem item) { case R.id.trackmgr_contextmenu_resume: // let's activate the track and start the TrackLogger activity - setActiveTrack(contextMenuSelectedTrackid); + if (currentTrackId == TRACK_ID_NO_TRACK) { + setActiveTrack(contextMenuSelectedTrackid); + } i = new Intent(this, TrackLogger.class); i.putExtra(TrackContentProvider.Schema.COL_TRACK_ID, contextMenuSelectedTrackid); tryStartTrackLogger(i); From e8bab90229d13f6998af17c7b940c59ac4e10aba Mon Sep 17 00:00:00 2001 From: Milton Barrera Date: Sat, 7 Dec 2024 00:38:48 -0600 Subject: [PATCH 2/2] Update track activation check to compare selected and active tracks on resume --- .../main/java/net/osmtracker/activity/TrackManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/osmtracker/activity/TrackManager.java b/app/src/main/java/net/osmtracker/activity/TrackManager.java index 0f64e5bb..c9738aa2 100644 --- a/app/src/main/java/net/osmtracker/activity/TrackManager.java +++ b/app/src/main/java/net/osmtracker/activity/TrackManager.java @@ -396,12 +396,13 @@ public boolean onContextItemSelected(MenuItem item) { // stop the active track stopActiveTrack(); break; - case R.id.trackmgr_contextmenu_resume: - // let's activate the track and start the TrackLogger activity - if (currentTrackId == TRACK_ID_NO_TRACK) { + // Activate the selected track if it is different from the currently active one + // (or if no track is currently active) + if (currentTrackId != contextMenuSelectedTrackid) { setActiveTrack(contextMenuSelectedTrackid); } + // Start the TrackLogger activity to begin logging the selected track i = new Intent(this, TrackLogger.class); i.putExtra(TrackContentProvider.Schema.COL_TRACK_ID, contextMenuSelectedTrackid); tryStartTrackLogger(i);