forked from upstream-mirrors/OpenTracks
@@ -111,19 +111,17 @@ The API can be invoked by sending an explicit Intent to start an activity.
|
|||||||
* **Start a recording:** `de.dennisguse.opentracks.publicapi.StartRecording`
|
* **Start a recording:** `de.dennisguse.opentracks.publicapi.StartRecording`
|
||||||
* **Stop a recording:** `de.dennisguse.opentracks.publicapi.StopRecording`
|
* **Stop a recording:** `de.dennisguse.opentracks.publicapi.StopRecording`
|
||||||
|
|
||||||
For testing via adb: `adb shell am start -n "package/class"`
|
For testing via adb: `adb shell am start -e someParameter someValue -n "package/class"`
|
||||||
|
|
||||||
`StartRecording` supports the following parameters:
|
`StartRecording` supports the following parameters:
|
||||||
|
|
||||||
* Set track data: `TRACK_NAME`, `TRACK_CATEGORY`, and `TRACK_DESCRIPTION`
|
* Set track data: `TRACK_NAME`, `TRACK_DESCRIPTION`, `TRACK_CATEGORY`, and `TRACK_ICON` (non-localized identifier see [/src/main/java/de/dennisguse/opentracks/util/TrackIconUtils.java#L38](/src/main/java/de/dennisguse/opentracks/util/TrackIconUtils.java#L38)).
|
||||||
* Send recorded data to another application via _Dashboard API_: `STATS_TARGET_PACKAGE`
|
NOTE: if `TRACK_ICON` is not present, `TRACK_CATEGORY` will be used to determine the icon (localized).
|
||||||
and `STATS_TARGET_CLASS`
|
* Send recorded data to another application via _Dashboard API_: `STATS_TARGET_PACKAGE` and `STATS_TARGET_CLASS`
|
||||||
|
|
||||||
The Public API is disabled by default to protect the user's privacy, but it can easily be enabled in
|
The Public API is disabled by default to protect the user's privacy, but it can easily be enabled in the settings.
|
||||||
the settings.
|
|
||||||
|
|
||||||
__IMPORTANT__: triggering `StartRecording` does not check if Android permissions (location or
|
__IMPORTANT__: triggering `StartRecording` does not check if Android permissions (location or Bluetooth) were granted. If they are not granted, nothing will be recorded.
|
||||||
Bluetooth) were granted. If they are not granted`
|
|
||||||
|
|
||||||
## Dashboard API (incl. map)
|
## Dashboard API (incl. map)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class StartRecording extends AbstractAPIActivity {
|
|||||||
|
|
||||||
public static final String EXTRA_TRACK_NAME = "TRACK_NAME";
|
public static final String EXTRA_TRACK_NAME = "TRACK_NAME";
|
||||||
public static final String EXTRA_TRACK_CATEGORY = "TRACK_CATEGORY";
|
public static final String EXTRA_TRACK_CATEGORY = "TRACK_CATEGORY";
|
||||||
|
public static final String EXTRA_TRACK_ICON = "TRACK_ICON";
|
||||||
public static final String EXTRA_TRACK_DESCRIPTION = "TRACK_DESCRIPTION";
|
public static final String EXTRA_TRACK_DESCRIPTION = "TRACK_DESCRIPTION";
|
||||||
|
|
||||||
public static final String EXTRA_STATS_TARGET_PACKAGE = "STATS_TARGET_PACKAGE";
|
public static final String EXTRA_STATS_TARGET_PACKAGE = "STATS_TARGET_PACKAGE";
|
||||||
@@ -40,8 +41,11 @@ public class StartRecording extends AbstractAPIActivity {
|
|||||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this);
|
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this);
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
Track track = contentProviderUtils.getTrack(trackId);
|
||||||
|
|
||||||
TrackUtils.updateTrack(this, track, bundle.getString(EXTRA_TRACK_NAME, null),
|
TrackUtils.updateTrack(this, track,
|
||||||
bundle.getString(EXTRA_TRACK_CATEGORY, null), bundle.getString(EXTRA_TRACK_DESCRIPTION, null),
|
bundle.getString(EXTRA_TRACK_NAME, null),
|
||||||
|
bundle.getString(EXTRA_TRACK_CATEGORY, null),
|
||||||
|
bundle.getString(EXTRA_TRACK_ICON, null),
|
||||||
|
bundle.getString(EXTRA_TRACK_DESCRIPTION, null),
|
||||||
contentProviderUtils);
|
contentProviderUtils);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,17 @@ import de.dennisguse.opentracks.data.models.Track;
|
|||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
|
@Deprecated //TODO Refactor: all this should happen somewhere else (ContentProviderUtils?)
|
||||||
public class TrackUtils {
|
public class TrackUtils {
|
||||||
|
|
||||||
private TrackUtils() {
|
private TrackUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateTrack(Context context, Track track, String name, String category, String description, ContentProviderUtils contentProviderUtils) {
|
public static void updateTrack(Context context, Track track, String name, String category, String description, ContentProviderUtils contentProviderUtils) {
|
||||||
|
updateTrack(context, track, name, category, TrackIconUtils.getIconValue(context, category), description, contentProviderUtils);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateTrack(Context context, Track track, String name, String category, String iconValue, String description, ContentProviderUtils contentProviderUtils) {
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
track.setName(name);
|
track.setName(name);
|
||||||
@@ -39,9 +44,13 @@ public class TrackUtils {
|
|||||||
}
|
}
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
track.setCategory(category);
|
track.setCategory(category);
|
||||||
track.setIcon(TrackIconUtils.getIconValue(context, category));
|
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
if (iconValue != null) {
|
||||||
|
track.setIcon(iconValue);
|
||||||
|
} else if (category != null){
|
||||||
|
track.setIcon(TrackIconUtils.getIconValue(context, category));
|
||||||
|
}
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
track.setDescription(description);
|
track.setDescription(description);
|
||||||
update = true;
|
update = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user