forked from upstream-mirrors/OpenTracks
Removed WaypointCreationRequest.
This commit is contained in:
+2
-3
@@ -44,7 +44,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.content.CustomContentProvider;
|
import de.dennisguse.opentracks.content.CustomContentProvider;
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||||
@@ -230,7 +229,7 @@ public class TrackRecordingServiceTest {
|
|||||||
ITrackRecordingService service = ((ITrackRecordingService) mServiceRule.bindService(createStartIntent(context)));
|
ITrackRecordingService service = ((ITrackRecordingService) mServiceRule.bindService(createStartIntent(context)));
|
||||||
Assert.assertFalse(service.isRecording());
|
Assert.assertFalse(service.isRecording());
|
||||||
|
|
||||||
long waypointId = service.insertWaypoint(new WaypointCreationRequest(null, null, null, null, null));
|
long waypointId = service.insertWaypoint(null, null, null, null);
|
||||||
Assert.assertEquals(-1L, waypointId);
|
Assert.assertEquals(-1L, waypointId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +242,7 @@ public class TrackRecordingServiceTest {
|
|||||||
insertLocation(service);
|
insertLocation(service);
|
||||||
|
|
||||||
long trackId = service.getRecordingTrackId();
|
long trackId = service.getRecordingTrackId();
|
||||||
long waypointId = service.insertWaypoint(new WaypointCreationRequest(null, null, null, null, null));
|
long waypointId = service.insertWaypoint(null, null, null, null);
|
||||||
Assert.assertNotEquals(-1L, waypointId);
|
Assert.assertNotEquals(-1L, waypointId);
|
||||||
Waypoint wpt = contentProviderUtils.getWaypoint(waypointId);
|
Waypoint wpt = contentProviderUtils.getWaypoint(waypointId);
|
||||||
Assert.assertEquals(context.getString(R.string.marker_waypoint_icon_url), wpt.getIcon());
|
Assert.assertEquals(context.getString(R.string.marker_waypoint_icon_url), wpt.getIcon());
|
||||||
|
|||||||
+1
-2
@@ -27,7 +27,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.content.CustomContentProvider;
|
import de.dennisguse.opentracks.content.CustomContentProvider;
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||||
@@ -219,7 +218,7 @@ public class TrackRecordingServiceTestLooper {
|
|||||||
service.insertTrackPoint(location);
|
service.insertTrackPoint(location);
|
||||||
|
|
||||||
if (i % 7 == 0) {
|
if (i % 7 == 0) {
|
||||||
service.insertWaypoint(new WaypointCreationRequest(null, null, null, null, null));
|
service.insertWaypoint(null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||||
import de.dennisguse.opentracks.services.TrackRecordingServiceConnection;
|
import de.dennisguse.opentracks.services.TrackRecordingServiceConnection;
|
||||||
|
|
||||||
@@ -157,13 +156,11 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
* Adds a marker.
|
* Adds a marker.
|
||||||
*/
|
*/
|
||||||
private void addMarker() {
|
private void addMarker() {
|
||||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(
|
trackRecordingServiceConnection.addMarker(this,
|
||||||
waypointName.getText().toString(),
|
waypointName.getText().toString(),
|
||||||
waypointMarkerType.getText().toString(),
|
waypointMarkerType.getText().toString(),
|
||||||
waypointDescription.getText().toString(),
|
waypointDescription.getText().toString(),
|
||||||
null,
|
|
||||||
null);
|
null);
|
||||||
trackRecordingServiceConnection.addMarker(this, waypointCreationRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import com.google.android.material.tabs.TabLayout;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||||
import de.dennisguse.opentracks.fragments.ChartDistanceFragment;
|
import de.dennisguse.opentracks.fragments.ChartDistanceFragment;
|
||||||
@@ -108,8 +107,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
|
|||||||
trackController.update(isRecording(), recordingTrackPaused);
|
trackController.update(isRecording(), recordingTrackPaused);
|
||||||
if (hasPhoto && photoUri != null) {
|
if (hasPhoto && photoUri != null) {
|
||||||
hasPhoto = false;
|
hasPhoto = false;
|
||||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(null, null, null, null, photoUri.toString());
|
long markerId = trackRecordingServiceConnection.addMarker(TrackDetailActivity.this, null, null, null, photoUri.toString());
|
||||||
long markerId = trackRecordingServiceConnection.addMarker(TrackDetailActivity.this, waypointCreationRequest);
|
|
||||||
if (markerId != -1L) {
|
if (markerId != -1L) {
|
||||||
//TODO: Make configurable.
|
//TODO: Make configurable.
|
||||||
FileUtils.updateMediaScanner(TrackDetailActivity.this, photoUri);
|
FileUtils.updateMediaScanner(TrackDetailActivity.this, photoUri);
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
package de.dennisguse.opentracks.content;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A request for the service to create a waypoint at the current location.
|
|
||||||
*
|
|
||||||
* @author Sandor Dornbush
|
|
||||||
*/
|
|
||||||
public class WaypointCreationRequest {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String category;
|
|
||||||
private String description;
|
|
||||||
private String iconUrl;
|
|
||||||
private String photoUrl;
|
|
||||||
|
|
||||||
public WaypointCreationRequest(String name, String category, String description, String iconUrl, String photoUrl) {
|
|
||||||
this.name = name;
|
|
||||||
this.category = category;
|
|
||||||
this.description = description;
|
|
||||||
this.iconUrl = iconUrl;
|
|
||||||
this.photoUrl = photoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCategory() {
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIconUrl() {
|
|
||||||
return iconUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPhotoUrl() {
|
|
||||||
return photoUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@ import android.location.Location;
|
|||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,10 +82,9 @@ public interface ITrackRecordingService {
|
|||||||
/**
|
/**
|
||||||
* Inserts a waypoint in the current recording track.
|
* 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
|
* @return the ID of the inserted waypoint
|
||||||
*/
|
*/
|
||||||
long insertWaypoint(WaypointCreationRequest request);
|
long insertWaypoint(String name, String category, String description, String photoUrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ONLY FOR TESTING
|
* ONLY FOR TESTING
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import de.dennisguse.opentracks.content.CustomContentProvider;
|
|||||||
import de.dennisguse.opentracks.content.LocationFactory;
|
import de.dennisguse.opentracks.content.LocationFactory;
|
||||||
import de.dennisguse.opentracks.content.LocationIterator;
|
import de.dennisguse.opentracks.content.LocationIterator;
|
||||||
import de.dennisguse.opentracks.content.SensorDataSetLocation;
|
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.Track;
|
||||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||||
@@ -292,15 +291,13 @@ public class TrackRecordingService extends Service {
|
|||||||
/**
|
/**
|
||||||
* Inserts a waypoint.
|
* Inserts a waypoint.
|
||||||
*
|
*
|
||||||
* @param waypointCreationRequest the waypoint creation request
|
|
||||||
* @return the waypoint id
|
* @return the waypoint id
|
||||||
*/
|
*/
|
||||||
public long insertWaypoint(WaypointCreationRequest waypointCreationRequest) {
|
public long insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||||
if (!isRecording() || isPaused()) {
|
if (!isRecording() || isPaused()) {
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = waypointCreationRequest.getName();
|
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId);
|
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId);
|
||||||
if (nextWaypointNumber == -1) {
|
if (nextWaypointNumber == -1) {
|
||||||
@@ -315,16 +312,15 @@ public class TrackRecordingService extends Service {
|
|||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest.getCategory() : "";
|
category = category != null ? category : "";
|
||||||
String description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest.getDescription() : "";
|
description = description != null ? description : "";
|
||||||
String icon = getString(R.string.marker_waypoint_icon_url);
|
String icon = getString(R.string.marker_waypoint_icon_url);
|
||||||
|
photoUrl = photoUrl != null ? photoUrl : "";
|
||||||
|
|
||||||
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
||||||
double length = stats.getTotalDistance();
|
double length = stats.getTotalDistance();
|
||||||
long duration = stats.getTotalTime();
|
long duration = stats.getTotalTime();
|
||||||
|
|
||||||
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
|
||||||
|
|
||||||
// Insert waypoint
|
// Insert waypoint
|
||||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, length, duration, -1L, -1L, location, null, photoUrl);
|
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, length, duration, -1L, -1L, location, null, photoUrl);
|
||||||
Uri uri = contentProviderUtils.insertWaypoint(waypoint);
|
Uri uri = contentProviderUtils.insertWaypoint(waypoint);
|
||||||
@@ -880,8 +876,8 @@ public class TrackRecordingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertWaypoint(WaypointCreationRequest waypointCreationRequest) {
|
public long insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||||
return trackRecordingService.insertWaypoint(waypointCreationRequest);
|
return trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
+2
-3
@@ -31,7 +31,6 @@ import androidx.annotation.NonNull;
|
|||||||
import de.dennisguse.opentracks.BuildConfig;
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.TrackEditActivity;
|
import de.dennisguse.opentracks.TrackEditActivity;
|
||||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
|
||||||
import de.dennisguse.opentracks.util.IntentUtils;
|
import de.dennisguse.opentracks.util.IntentUtils;
|
||||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||||
import de.dennisguse.opentracks.util.ServiceUtils;
|
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.
|
* @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();
|
ITrackRecordingService trackRecordingService = getServiceIfBound();
|
||||||
if (trackRecordingService == null) {
|
if (trackRecordingService == null) {
|
||||||
Log.d(TAG, "Unable to add marker, no track recording service");
|
Log.d(TAG, "Unable to add marker, no track recording service");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
long markerId = trackRecordingService.insertWaypoint(waypointCreationRequest);
|
long markerId = trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||||
if (markerId != -1L) {
|
if (markerId != -1L) {
|
||||||
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
|
||||||
return markerId;
|
return markerId;
|
||||||
|
|||||||
Reference in New Issue
Block a user