Colota - Android GPS Location tracker
fix: persist pause zone state to prevent duplicate anchor points on settings change
Max Dietrich9357fa40686a
diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.ktindex 45924ff0..59b769a8 100644--- a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt@@ -128,6 +128,16 @@ class LocationForegroundService : Service() {loadConfigFromIntent(null)}+ // Restore pause zone state so restarts don't trigger duplicate anchor points+ if (!insidePauseZone) {+ val savedZone = savedSettings["pause_zone_name"]+ if (!savedZone.isNullOrBlank()) {+ insidePauseZone = true+ currentZoneName = savedZone+ AppLogger.d(TAG, "Restored pause zone state: $savedZone")+ }+ }+// Must call startForeground within 5sval initialStatus = notificationHelper.getInitialStatus(insidePauseZone, currentZoneName, lastKnownLocation@@ -442,6 +452,7 @@ class LocationForegroundService : Service() {insidePauseZone = truecurrentZoneName = geofence.namecurrentZoneGeofence = geofence+ dbHelper.saveSetting("pause_zone_name", geofence.name)val loc = lastKnownLocationupdateNotification(@@ -465,6 +476,7 @@ class LocationForegroundService : Service() {insidePauseZone = falsecurrentZoneName = nullcurrentZoneGeofence = null+ dbHelper.saveSetting("pause_zone_name", "")val anchorJob = exitedGeofence?.let { saveAnchorPoint(it) }@@ -557,6 +569,7 @@ class LocationForegroundService : Service() {LocationServiceModule.sendTrackingStoppedEvent(reason)dbHelper.saveSetting("tracking_enabled", "false")+ dbHelper.saveSetting("pause_zone_name", "")stopForeground(Service.STOP_FOREGROUND_DETACH)