From fc1883cf3c841e4417a8dce9410f96cf338cf0b4 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 16 Feb 2021 00:28:41 +0500 Subject: [PATCH 1/2] Extend track auto-record during navigation --- .../osmand/plus/activities/SavingTrackHelper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index e173a49ad1..431e371f29 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -19,6 +19,7 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.Version; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; @@ -79,6 +80,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { private int points; private int trkPoints = 0; + private ApplicationMode lastRoutingApplicationMode; + public SavingTrackHelper(OsmandApplication ctx) { super(ctx, DATABASE_NAME, null, DATABASE_VERSION); this.ctx = ctx; @@ -440,12 +443,15 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } else { heading = NO_HEADING; } + if (ctx.getRoutingHelper().isFollowingMode()) { + lastRoutingApplicationMode = settings.getApplicationMode(); + } boolean record = false; if (location != null && OsmAndLocationProvider.isNotSimulatedLocation(location) && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) { if (settings.SAVE_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() - && ctx.getRoutingHelper().isFollowingMode()) { + && (ctx.getRoutingHelper().isFollowingMode() || lastRoutingApplicationMode == settings.getApplicationMode())) { record = true; } else if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) { @@ -705,9 +711,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } public boolean getIsRecording() { + OsmandSettings settings = ctx.getSettings(); return OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null - && ctx.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get() - || (ctx.getSettings().SAVE_TRACK_TO_GPX.get() && ctx.getRoutingHelper().isFollowingMode()); + && settings.SAVE_GLOBAL_TRACK_TO_GPX.get() || settings.SAVE_TRACK_TO_GPX.get() + && (ctx.getRoutingHelper().isFollowingMode() || lastRoutingApplicationMode == settings.getApplicationMode()); } public float getDistance() { From a09ccfca8739bf8527c3c10270a67def0a42caf9 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 16 Feb 2021 11:29:08 +0500 Subject: [PATCH 2/2] Simplify checks --- OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 431e371f29..e5cd6ad237 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -451,7 +451,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) { if (settings.SAVE_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() - && (ctx.getRoutingHelper().isFollowingMode() || lastRoutingApplicationMode == settings.getApplicationMode())) { + && lastRoutingApplicationMode == settings.getApplicationMode()) { record = true; } else if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) { @@ -714,7 +714,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { OsmandSettings settings = ctx.getSettings(); return OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get() || settings.SAVE_TRACK_TO_GPX.get() - && (ctx.getRoutingHelper().isFollowingMode() || lastRoutingApplicationMode == settings.getApplicationMode()); + && lastRoutingApplicationMode == settings.getApplicationMode(); } public float getDistance() {