diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OpenTracksController.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OpenTracksController.java
new file mode 100644
index 000000000..a94ba03d0
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OpenTracksController.java
@@ -0,0 +1,56 @@
+/* Copyright (C) 2022 Arjan Schrijver
+
+ This file is part of Gadgetbridge.
+
+ Gadgetbridge is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Gadgetbridge is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see . */
+
+package nodomain.freeyourgadget.gadgetbridge.externalevents;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import nodomain.freeyourgadget.gadgetbridge.GBApplication;
+import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
+
+public class OpenTracksController extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent != null) {
+ Bundle bundle = intent.getExtras();
+ if (bundle != null) {
+ // Handle received OpenTracks Dashboard API intent
+ }
+ }
+ }
+
+ public static void sendIntent(Context context, String className) {
+ Prefs prefs = GBApplication.getPrefs();
+ String packageName = prefs.getString("opentracks_packagename", "de.dennisguse.opentracks");
+ Intent intent = new Intent();
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClassName(packageName, className);
+ context.startActivity(intent);
+ }
+
+ public static void startRecording(Context context) {
+ sendIntent(context, "de.dennisguse.opentracks.publicapi.StartRecording");
+ }
+
+ public static void stopRecording(Context context) {
+ sendIntent(context, "de.dennisguse.opentracks.publicapi.StopRecording");
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
index d836143bc..b1c60ee1d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
@@ -86,6 +86,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HybridHRActivitySamp
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration;
import nodomain.freeyourgadget.gadgetbridge.entities.HybridHRActivitySample;
import nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener;
+import nodomain.freeyourgadget.gadgetbridge.externalevents.OpenTracksController;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
@@ -1578,10 +1579,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
.put("message", "")
.put("type", "success")
);
- Intent intent = new Intent();
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName("de.dennisguse.opentracks.debug", "de.dennisguse.opentracks.publicapi.StartRecording");
- getContext().startActivity(intent);
+ OpenTracksController.startRecording(getContext());
}
if (workoutRequest.optString("type").equals("req_distance")) {
workoutResponse.put("workoutApp._.config.gps", new JSONObject()
@@ -1611,10 +1609,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
.put("message", "")
.put("type", "success")
);
- Intent intent = new Intent();
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName("de.dennisguse.opentracks.debug", "de.dennisguse.opentracks.publicapi.StopRecording");
- getContext().startActivity(intent);
+ OpenTracksController.stopRecording(getContext());
}
if (workoutRequest.optString("type").equals("req_route")) {
// Send the traveled route as an RLE encoded image (example name: 58270405)
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 6b930337c..b7fcb73a3 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -141,6 +141,12 @@
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_location_keep_uptodate"
android:title="@string/pref_title_location_keep_uptodate" />
+