From b94cce6b9606503ac9817147fc431cfb321228a5 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Sun, 16 Feb 2020 23:06:50 +0200 Subject: [PATCH 1/3] Fix #8406 Add Save/Clear current GPX track functionality --- .../plus/helpers/ExternalApiHelper.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 64ed3acfcb..7b5b5b2f44 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -92,6 +92,8 @@ public class ExternalApiHelper { public static final String API_CMD_START_GPX_REC = "start_gpx_rec"; public static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec"; + public static final String API_CMD_SAVE_GPX_TRACK = "save_gpx_track"; + public static final String API_CMD_CLEAR_GPX_TRACK = "clear_gpx_track"; public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications"; public static final int VERSION_CODE = 1; @@ -554,6 +556,24 @@ public class ExternalApiHelper { finish = true; } resultCode = Activity.RESULT_OK; + } else if (API_CMD_SAVE_GPX_TRACK.equals(cmd)) { + OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); + if (plugin == null) { + resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE; + finish = true; + } else { + plugin.saveCurrentTrack(); + } + resultCode = Activity.RESULT_OK; + } else if (API_CMD_CLEAR_GPX_TRACK.equals(cmd)) { + OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); + if (plugin == null) { + resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE; + finish = true; + } else { + app.getSavingTrackHelper().clearRecordedData(true); + } + resultCode = Activity.RESULT_OK; } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) { // not implemented yet resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED; From 0739829d8de6789003b37fb92174b4065415bc89 Mon Sep 17 00:00:00 2001 From: Nazar Date: Mon, 17 Feb 2020 11:26:23 +0200 Subject: [PATCH 2/3] Add auto close condition Rename --- .../net/osmand/plus/helpers/ExternalApiHelper.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 7b5b5b2f44..9bd9a26ccf 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -92,8 +92,8 @@ public class ExternalApiHelper { public static final String API_CMD_START_GPX_REC = "start_gpx_rec"; public static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec"; - public static final String API_CMD_SAVE_GPX_TRACK = "save_gpx_track"; - public static final String API_CMD_CLEAR_GPX_TRACK = "clear_gpx_track"; + public static final String API_CMD_SAVE_CURRENT_GPX = "save_current_gpx"; + public static final String API_CMD_CLEAR_CURRENT_GPX = "clear_current_gpx"; public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications"; public static final int VERSION_CODE = 1; @@ -556,7 +556,7 @@ public class ExternalApiHelper { finish = true; } resultCode = Activity.RESULT_OK; - } else if (API_CMD_SAVE_GPX_TRACK.equals(cmd)) { + } else if (API_CMD_SAVE_CURRENT_GPX.equals(cmd)) { OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin == null) { resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE; @@ -564,8 +564,11 @@ public class ExternalApiHelper { } else { plugin.saveCurrentTrack(); } + if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) { + finish = true; + } resultCode = Activity.RESULT_OK; - } else if (API_CMD_CLEAR_GPX_TRACK.equals(cmd)) { + } else if (API_CMD_CLEAR_CURRENT_GPX.equals(cmd)) { OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin == null) { resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE; @@ -573,6 +576,9 @@ public class ExternalApiHelper { } else { app.getSavingTrackHelper().clearRecordedData(true); } + if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) { + finish = true; + } resultCode = Activity.RESULT_OK; } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) { // not implemented yet From 7cd3e678f085a5539ae2ad3c32697a6a747a2a04 Mon Sep 17 00:00:00 2001 From: Nazar Date: Mon, 17 Feb 2020 11:40:13 +0200 Subject: [PATCH 3/3] Rename p.2 --- OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 9bd9a26ccf..4cc790d587 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -92,8 +92,8 @@ public class ExternalApiHelper { public static final String API_CMD_START_GPX_REC = "start_gpx_rec"; public static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec"; - public static final String API_CMD_SAVE_CURRENT_GPX = "save_current_gpx"; - public static final String API_CMD_CLEAR_CURRENT_GPX = "clear_current_gpx"; + public static final String API_CMD_SAVE_GPX = "save_gpx"; + public static final String API_CMD_CLEAR_GPX = "clear_gpx"; public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications"; public static final int VERSION_CODE = 1; @@ -556,7 +556,7 @@ public class ExternalApiHelper { finish = true; } resultCode = Activity.RESULT_OK; - } else if (API_CMD_SAVE_CURRENT_GPX.equals(cmd)) { + } else if (API_CMD_SAVE_GPX.equals(cmd)) { OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin == null) { resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE; @@ -568,7 +568,7 @@ public class ExternalApiHelper { finish = true; } resultCode = Activity.RESULT_OK; - } else if (API_CMD_CLEAR_CURRENT_GPX.equals(cmd)) { + } else if (API_CMD_CLEAR_GPX.equals(cmd)) { OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin == null) { resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;