From 9d6148e05a7706eacf89f2836110a5b0f526bbee Mon Sep 17 00:00:00 2001 From: WilliamRelken Date: Mon, 26 Feb 2024 13:20:34 -0500 Subject: [PATCH 1/2] Add STOP_LOGGING_ON_APP_LAUNCH preference --- .../main/java/com/mendhak/gpslogger/GpsMainActivity.java | 5 +++++ .../com/mendhak/gpslogger/common/PreferenceHelper.java | 8 ++++++++ .../com/mendhak/gpslogger/common/PreferenceNames.java | 1 + 3 files changed, 14 insertions(+) diff --git a/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java b/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java index ced702289..d6242f3f5 100644 --- a/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java +++ b/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java @@ -174,6 +174,11 @@ protected void onCreate(Bundle savedInstanceState) { LOG.debug("Start logging on app launch"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } + + if(preferenceHelper.shouldStopLoggingOnAppLaunch()){ + LOG.debug("Stop logging on app launch"); + EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); + } } } diff --git a/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceHelper.java b/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceHelper.java index a45bd10c2..8f18330a1 100644 --- a/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceHelper.java +++ b/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceHelper.java @@ -447,6 +447,14 @@ public boolean shouldStartLoggingOnAppLaunch() { return prefs.getBoolean(PreferenceNames.START_LOGGING_ON_APP_LAUNCH, false); } + /** + * Whether to stop logging on application launch + */ + @ProfilePreference(name= PreferenceNames.STOP_LOGGING_ON_APP_LAUNCH) + public boolean shouldStopLoggingOnAppLaunch() { + return prefs.getBoolean(PreferenceNames.STOP_LOGGING_ON_APP_LAUNCH, false); + } + /** * Whether to start logging when phone is booted up */ diff --git a/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceNames.java b/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceNames.java index 065c533db..c2fc6c3c3 100644 --- a/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceNames.java +++ b/gpslogger/src/main/java/com/mendhak/gpslogger/common/PreferenceNames.java @@ -28,6 +28,7 @@ public class PreferenceNames { public static final String LOGGING_RETRY_TIME = "retry_time"; public static final String ABSOLUTE_TIMEOUT = "absolute_timeout"; public static final String START_LOGGING_ON_APP_LAUNCH = "startonapplaunch"; + public static final String STOP_LOGGING_ON_APP_LAUNCH = "stoponapplaunch"; public static final String START_LOGGING_ON_BOOTUP = "startonbootup"; public static final String LOG_TO_KML = "log_kml"; public static final String LOG_TO_GPX = "log_gpx"; From 32d7ae7dbd42a0f8ccb4455b7785c261624d16b1 Mon Sep 17 00:00:00 2001 From: WilliamRelken Date: Thu, 29 Feb 2024 13:16:49 -0500 Subject: [PATCH 2/2] log single point on stop logging. --- .../src/main/java/com/mendhak/gpslogger/GpsMainActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java b/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java index d6242f3f5..c19d4f1a5 100644 --- a/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java +++ b/gpslogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java @@ -178,6 +178,7 @@ protected void onCreate(Bundle savedInstanceState) { if(preferenceHelper.shouldStopLoggingOnAppLaunch()){ LOG.debug("Stop logging on app launch"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); + logSinglePoint(); } } }