forked from upstream-mirrors/OpenTracks
Removed WaypointCreationRequest.
This commit is contained in:
@@ -19,7 +19,6 @@ import android.location.Location;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
|
||||
/**
|
||||
@@ -83,10 +82,9 @@ public interface ITrackRecordingService {
|
||||
/**
|
||||
* Inserts a waypoint in the current recording track.
|
||||
*
|
||||
* @param request the details of the waypoint to be inserted
|
||||
* @return the ID of the inserted waypoint
|
||||
*/
|
||||
long insertWaypoint(WaypointCreationRequest request);
|
||||
long insertWaypoint(String name, String category, String description, String photoUrl);
|
||||
|
||||
/**
|
||||
* ONLY FOR TESTING
|
||||
|
||||
@@ -47,7 +47,6 @@ import de.dennisguse.opentracks.content.CustomContentProvider;
|
||||
import de.dennisguse.opentracks.content.LocationFactory;
|
||||
import de.dennisguse.opentracks.content.LocationIterator;
|
||||
import de.dennisguse.opentracks.content.SensorDataSetLocation;
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
@@ -292,15 +291,13 @@ public class TrackRecordingService extends Service {
|
||||
/**
|
||||
* Inserts a waypoint.
|
||||
*
|
||||
* @param waypointCreationRequest the waypoint creation request
|
||||
* @return the waypoint id
|
||||
*/
|
||||
public long insertWaypoint(WaypointCreationRequest waypointCreationRequest) {
|
||||
public long insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||
if (!isRecording() || isPaused()) {
|
||||
return -1L;
|
||||
}
|
||||
|
||||
String name = waypointCreationRequest.getName();
|
||||
if (name == null) {
|
||||
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId);
|
||||
if (nextWaypointNumber == -1) {
|
||||
@@ -315,16 +312,15 @@ public class TrackRecordingService extends Service {
|
||||
return -1L;
|
||||
}
|
||||
|
||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest.getCategory() : "";
|
||||
String description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest.getDescription() : "";
|
||||
category = category != null ? category : "";
|
||||
description = description != null ? description : "";
|
||||
String icon = getString(R.string.marker_waypoint_icon_url);
|
||||
photoUrl = photoUrl != null ? photoUrl : "";
|
||||
|
||||
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
||||
double length = stats.getTotalDistance();
|
||||
long duration = stats.getTotalTime();
|
||||
|
||||
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, length, duration, -1L, -1L, location, null, photoUrl);
|
||||
Uri uri = contentProviderUtils.insertWaypoint(waypoint);
|
||||
@@ -880,8 +876,8 @@ public class TrackRecordingService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long insertWaypoint(WaypointCreationRequest waypointCreationRequest) {
|
||||
return trackRecordingService.insertWaypoint(waypointCreationRequest);
|
||||
public long insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||
return trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
+2
-3
@@ -31,7 +31,6 @@ import androidx.annotation.NonNull;
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.TrackEditActivity;
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.util.IntentUtils;
|
||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
import de.dennisguse.opentracks.util.ServiceUtils;
|
||||
@@ -212,13 +211,13 @@ public class TrackRecordingServiceConnection implements ServiceConnection, Death
|
||||
*
|
||||
* @return the id of the marker or -1L if none could be created.
|
||||
*/
|
||||
public long addMarker(Context context, WaypointCreationRequest waypointCreationRequest) {
|
||||
public long addMarker(Context context, String name, String category, String description, String photoUrl) {
|
||||
ITrackRecordingService trackRecordingService = getServiceIfBound();
|
||||
if (trackRecordingService == null) {
|
||||
Log.d(TAG, "Unable to add marker, no track recording service");
|
||||
} else {
|
||||
try {
|
||||
long markerId = trackRecordingService.insertWaypoint(waypointCreationRequest);
|
||||
long markerId = trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||
if (markerId != -1L) {
|
||||
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
|
||||
return markerId;
|
||||
|
||||
Reference in New Issue
Block a user