andreynovikov / trekarta

Simple, responsive map for your trek. You decide how to journey today, not the application!
https://trekarta.info
GNU General Public License v3.0
169 stars 25 forks source link

Unable to stop track recording from the ongoing notification #216

Closed strpbrk closed 5 months ago

strpbrk commented 1 year ago

Steps to reproduce.

  1. Hold the "track" button to start track recording.
  2. Make a bit of track.
  3. Pull down the ongoing notification and click "Stop".
  4. Bring the application to the background.
  5. Bring the application to the foreground.

Unexpected behavior: Track recording will start again.

Cause: Tracking state is contained in both MainActivity.mTrackingState and LocationService.mTrackingEnabled, and there is a race between them.

Opinion on the fix: Refactor to have one source for the state that will be accessed by all interested parties (MainActivity and LocationService), and which will be the only authority to store the state into shared preferences.

For my purposes, I have created an ugly workaround that always writes to the shared preference variable and reads it in "onResume". It is not consistent, as it leaves the track button red, but at least it allows me to quickly and reliably stop track recording, as I used to unintentionally have location tracking and track recording on, draining my battery, when I was sure it should have been stopped.

The other way to stop track recording is that small "ic_record_stop" button. I think that one works properly, but I only became aware of it while searching for a resolution to this issue.

Regards, Dragan

andreynovikov commented 5 months ago

Fixed in 2024.02