forked from upstream-mirrors/OpenTracks
Add a category icon in Track.java and TracksColumns.java.
Clean up Track.java and TracksColumns.java.
This commit is contained in:
@@ -49,9 +49,9 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
|
||||
List<Track> tracks = MyTracksProviderUtils.Factory.get(this).getAllTracks();
|
||||
TripStatistics tripStatistics = null;
|
||||
if (!tracks.isEmpty()) {
|
||||
tripStatistics = new TripStatistics(tracks.iterator().next().getStatistics());
|
||||
tripStatistics = new TripStatistics(tracks.iterator().next().getTripStatistics());
|
||||
for (int i = 1; i < tracks.size(); i++) {
|
||||
tripStatistics.merge(tracks.get(i).getStatistics());
|
||||
tripStatistics.merge(tracks.get(i).getTripStatistics());
|
||||
}
|
||||
}
|
||||
return tripStatistics;
|
||||
|
||||
@@ -419,7 +419,7 @@ public class SearchListActivity extends AbstractMyTracksActivity implements Dele
|
||||
*/
|
||||
private void prepareTrackForDisplay(Track track, Map<String, Object> resultMap) {
|
||||
boolean isRecording = track.getId() == recordingTrackId;
|
||||
TripStatistics tripStatitics = track.getStatistics();
|
||||
TripStatistics tripStatitics = track.getTripStatistics();
|
||||
resultMap.put(NAME_FIELD, track.getName());
|
||||
resultMap.put(ICON_FIELD, isRecording ? R.drawable.menu_record_track : R.drawable.track);
|
||||
resultMap.put(ICON_CONTENT_DESCRIPTION_FIELD, getString(isRecording ? R.string.icon_recording
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DescriptionGeneratorImpl implements DescriptionGenerator {
|
||||
writeString(track.getName(), builder, R.string.generic_name_line, lineBreak);
|
||||
writeString(track.getCategory(), builder, R.string.description_activity_type, lineBreak);
|
||||
writeString(track.getDescription(), builder, R.string.generic_description_line, lineBreak);
|
||||
builder.append(generateTripStatisticsDescription(track.getStatistics(), html));
|
||||
builder.append(generateTripStatisticsDescription(track.getTripStatistics(), html));
|
||||
|
||||
// Elevation chart
|
||||
if (html && distances != null && elevations != null) {
|
||||
|
||||
@@ -261,7 +261,7 @@ public class SearchEngine {
|
||||
|
||||
score *= getTitleBoost(query, track.getName(), track.getDescription(), track.getCategory());
|
||||
|
||||
TripStatistics statistics = track.getStatistics();
|
||||
TripStatistics statistics = track.getTripStatistics();
|
||||
// TODO: Also boost for proximity to the currently-centered position on the map.
|
||||
score *= getDistanceBoost(query, statistics.getMeanLatitude(), statistics.getMeanLongitude());
|
||||
|
||||
|
||||
@@ -185,11 +185,11 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
|
||||
@Override
|
||||
public void onTrackUpdated(Track track) {
|
||||
if (track == null || track.getStatistics() == null) {
|
||||
if (track == null || track.getTripStatistics() == null) {
|
||||
trackMaxSpeed = 0.0;
|
||||
return;
|
||||
}
|
||||
trackMaxSpeed = track.getStatistics().getMaxSpeed();
|
||||
trackMaxSpeed = track.getTripStatistics().getMaxSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -522,7 +522,7 @@ public class MapFragment extends Fragment
|
||||
return;
|
||||
}
|
||||
|
||||
TripStatistics tripStatistics = track.getStatistics();
|
||||
TripStatistics tripStatistics = track.getTripStatistics();
|
||||
int bottom = tripStatistics.getBottom();
|
||||
int left = tripStatistics.getLeft();
|
||||
int latitudeSpanE6 = tripStatistics.getTop() - bottom;
|
||||
|
||||
@@ -163,15 +163,15 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (track == null || track.getStatistics() == null) {
|
||||
if (track == null || track.getTripStatistics() == null) {
|
||||
lastLocation = null;
|
||||
lastTripStatistics = null;
|
||||
updateUi();
|
||||
return;
|
||||
}
|
||||
lastTripStatistics = track.getStatistics();
|
||||
lastTripStatistics = track.getTripStatistics();
|
||||
|
||||
startTime = track.getStatistics().getStartTime();
|
||||
startTime = track.getTripStatistics().getStartTime();
|
||||
if (!isRecording()) {
|
||||
lastLocation = null;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class SendDocsUtils {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static String getRowContent(Track track, boolean metricUnits, Context context) {
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
|
||||
String distanceUnit = context.getString(
|
||||
metricUnits ? R.string.unit_kilometer : R.string.unit_mile);
|
||||
|
||||
@@ -422,7 +422,7 @@ public class GpxImporter extends DefaultHandler {
|
||||
statsBuilder.pauseAt(lastLocation.getTime());
|
||||
track.setStopId(getLastPointId());
|
||||
track.setNumberOfPoints(numberOfLocations);
|
||||
track.setStatistics(statsBuilder.getStatistics());
|
||||
track.setTripStatistics(statsBuilder.getStatistics());
|
||||
providerUtils.updateTrack(track);
|
||||
tracksWritten.add(track.getId());
|
||||
isCurrentTrackRollbackable = false;
|
||||
|
||||
@@ -147,15 +147,16 @@ public class TcxTrackWriter implements TrackFormatWriter {
|
||||
@Override
|
||||
public void writeBeginTrack(Location firstPoint) {
|
||||
if (printWriter != null) {
|
||||
String startTime = StringUtils.formatDateTimeIso8601(track.getStatistics().getStartTime());
|
||||
long totalTimeInSeconds = track.getStatistics().getTotalTime() / 1000;
|
||||
String startTime = StringUtils.formatDateTimeIso8601(
|
||||
track.getTripStatistics().getStartTime());
|
||||
long totalTimeInSeconds = track.getTripStatistics().getTotalTime() / 1000;
|
||||
|
||||
printWriter.println("<Activities>");
|
||||
printWriter.println("<Activity Sport=\"" + sportType.getName() + "\">");
|
||||
printWriter.println("<Id>" + startTime + "</Id>");
|
||||
printWriter.println("<Lap StartTime=\"" + startTime + "\">");
|
||||
printWriter.println("<TotalTimeSeconds>" + totalTimeInSeconds + "</TotalTimeSeconds>");
|
||||
printWriter.println("<DistanceMeters>" + track.getStatistics().getTotalDistance()
|
||||
printWriter.println("<DistanceMeters>" + track.getTripStatistics().getTotalDistance()
|
||||
+ "</DistanceMeters>");
|
||||
// <Calories> is required, just put in 0.
|
||||
printWriter.println("<Calories>0</Calories>");
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
// For chart server, limit the number of elevation readings to 250.
|
||||
int elevationSamplingFrequency = Math.max(1, (int) (locationsCount / 250.0));
|
||||
TripStatisticsBuilder tripStatisticsBuilder = new TripStatisticsBuilder(
|
||||
track.getStatistics().getStartTime());
|
||||
track.getTripStatistics().getStartTime());
|
||||
DoubleBuffer elevationBuffer = new DoubleBuffer(Constants.ELEVATION_SMOOTHING_FACTOR);
|
||||
Vector<Double> distances = new Vector<Double>();
|
||||
Vector<Double> elevations = new Vector<Double>();
|
||||
|
||||
+2
-2
@@ -52,14 +52,14 @@ public class SendFusionTablesUtils {
|
||||
* @return the url.
|
||||
*/
|
||||
public static String getMapUrl(Track track) {
|
||||
if (track == null || track.getStatistics() == null || track.getTableId() == null) {
|
||||
if (track == null || track.getTripStatistics() == null || track.getTableId() == null) {
|
||||
Log.e(TAG, "Invalid track");
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO(jshih): Determine the correct bounding box and zoom level that
|
||||
// will show the entire track.
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
double latE6 = stats.getBottom() + (stats.getTop() - stats.getBottom()) / 2;
|
||||
double lonE6 = stats.getLeft() + (stats.getRight() - stats.getLeft()) / 2;
|
||||
int z = 15;
|
||||
|
||||
@@ -270,7 +270,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
||||
// For chart server, limit the number of elevation readings to 250.
|
||||
int elevationSamplingFrequency = Math.max(1, (int) (locationsCount / 250.0));
|
||||
TripStatisticsBuilder tripStatisticsBuilder = new TripStatisticsBuilder(
|
||||
track.getStatistics().getStartTime());
|
||||
track.getTripStatistics().getStartTime());
|
||||
DoubleBuffer elevationBuffer = new DoubleBuffer(Constants.ELEVATION_SMOOTHING_FACTOR);
|
||||
Vector<Double> distances = new Vector<Double>();
|
||||
Vector<Double> elevations = new Vector<Double>();
|
||||
|
||||
+4
-4
@@ -56,8 +56,8 @@ public class SendToGoogleUtils {
|
||||
segment.setDescription("");
|
||||
segment.setCategory(track.getCategory());
|
||||
|
||||
TripStatistics segmentStats = segment.getStatistics();
|
||||
TripStatistics trackStats = track.getStatistics();
|
||||
TripStatistics segmentStats = segment.getTripStatistics();
|
||||
TripStatistics trackStats = track.getTripStatistics();
|
||||
segmentStats.setStartTime(trackStats.getStartTime());
|
||||
segmentStats.setStopTime(trackStats.getStopTime());
|
||||
boolean startNewTrackSegment = false;
|
||||
@@ -78,7 +78,7 @@ public class SendToGoogleUtils {
|
||||
segment.setName(track.getName());
|
||||
segment.setDescription("");
|
||||
segment.setCategory(track.getCategory());
|
||||
segmentStats = segment.getStatistics();
|
||||
segmentStats = segment.getTripStatistics();
|
||||
}
|
||||
|
||||
if (loc.getLatitude() <= 90) {
|
||||
@@ -119,7 +119,7 @@ public class SendToGoogleUtils {
|
||||
}
|
||||
|
||||
// For a new segment, sets it stop time
|
||||
TripStatistics segmentStats = segment.getStatistics();
|
||||
TripStatistics segmentStats = segment.getTripStatistics();
|
||||
if (segmentStats.getStopTime() < 0) {
|
||||
Location lastLocation = segment.getLocations().get(segment.getLocations().size() - 1);
|
||||
segmentStats.setStopTime(lastLocation.getTime());
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
||||
Log.d(TAG, "No track for " + selectedTrackId);
|
||||
return false;
|
||||
}
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
double newAverageMovingSpeed = (int) Math.floor(
|
||||
stats.getAverageMovingSpeed() * UnitConversions.MS_TO_KMH);
|
||||
|
||||
|
||||
@@ -420,7 +420,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
// Check if the last modified time is within the acceptable range.
|
||||
long lastModified =
|
||||
track.getStatistics() != null ? track.getStatistics().getStopTime() : 0;
|
||||
track.getTripStatistics() != null ? track.getTripStatistics().getStopTime() : 0;
|
||||
Log.d(TAG,
|
||||
"shouldResumeTrack: lastModified = " + lastModified
|
||||
+ ", autoResumeTrackTimeout: " + autoResumeTrackTimeout);
|
||||
@@ -579,7 +579,7 @@ public class TrackRecordingService extends Service {
|
||||
acquireWakeLock();
|
||||
|
||||
Track track = new Track();
|
||||
TripStatistics trackStats = track.getStatistics();
|
||||
TripStatistics trackStats = track.getTripStatistics();
|
||||
trackStats.setStartTime(startTime);
|
||||
track.setStartId(-1);
|
||||
Uri trackUri = providerUtils.insertTrack(track);
|
||||
@@ -620,7 +620,7 @@ public class TrackRecordingService extends Service {
|
||||
Log.d(TAG,
|
||||
"Restoring stats of track with ID: " + track.getId());
|
||||
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
statsBuilder = new TripStatisticsBuilder(stats.getStartTime());
|
||||
statsBuilder.setMinRecordingDistance(minRecordingDistance);
|
||||
|
||||
@@ -1031,7 +1031,7 @@ public class TrackRecordingService extends Service {
|
||||
isRecording = false;
|
||||
Track recordedTrack = providerUtils.getTrack(recordingTrackId);
|
||||
if (recordedTrack != null) {
|
||||
TripStatistics stats = recordedTrack.getStatistics();
|
||||
TripStatistics stats = recordedTrack.getTripStatistics();
|
||||
stats.setStopTime(System.currentTimeMillis());
|
||||
stats.setTotalTime(stats.getStopTime() - stats.getStartTime());
|
||||
long lastRecordedLocationId =
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ChartURLGenerator {
|
||||
}
|
||||
|
||||
// Round it up.
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
double effectiveMaxY = metricUnits
|
||||
? stats.getMaxElevation()
|
||||
: stats.getMaxElevation() * UnitConversions.M_TO_FT;
|
||||
@@ -155,7 +155,7 @@ public class ChartURLGenerator {
|
||||
}
|
||||
|
||||
private static double getNormalizedDistance(double d, Track track) {
|
||||
return d / track.getStatistics().getTotalDistance();
|
||||
return d / track.getTripStatistics().getTotalDistance();
|
||||
}
|
||||
|
||||
private static double getNormalizedElevation(
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.google.android.apps.mytracks.util;
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
|
||||
import com.google.android.maps.GeoPoint;
|
||||
|
||||
import android.location.Location;
|
||||
@@ -181,7 +180,7 @@ public class LocationUtils {
|
||||
Track piece = null;
|
||||
do {
|
||||
piece = new Track();
|
||||
TripStatistics pieceStats = piece.getStatistics();
|
||||
TripStatistics pieceStats = piece.getTripStatistics();
|
||||
piece.setId(track.getId());
|
||||
piece.setName(track.getName());
|
||||
piece.setDescription(track.getDescription());
|
||||
|
||||
@@ -216,7 +216,7 @@ public class TrackWidgetProvider extends AppWidgetProvider
|
||||
private void updateStatistics(RemoteViews remoteViews) {
|
||||
Track track = selectedTrackId != PreferencesUtils.SELECTED_TRACK_ID_DEFAULT
|
||||
? myTracksProviderUtils.getTrack(selectedTrackId) : myTracksProviderUtils.getLastTrack();
|
||||
TripStatistics tripStatistics = track == null ? null : track.getStatistics();
|
||||
TripStatistics tripStatistics = track == null ? null : track.getTripStatistics();
|
||||
String distance = tripStatistics == null ? unknown
|
||||
: StringUtils.formatDistance(context, tripStatistics.getTotalDistance(), metricUnits);
|
||||
int timeLabelId = useTotalTime ? R.string.stats_total_time : R.string.stats_moving_time;
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
@Override
|
||||
public ContentValues createContentValues(Track track) {
|
||||
ContentValues values = new ContentValues();
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
|
||||
// Values id < 0 indicate no id is available:
|
||||
if (track.getId() >= 0) {
|
||||
@@ -297,7 +297,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
int idxMaxGrade = cursor.getColumnIndexOrThrow(TracksColumns.MAXGRADE);
|
||||
|
||||
Track track = new Track();
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
if (!cursor.isNull(idxId)) {
|
||||
track.setId(cursor.getLong(idxId));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
@@ -24,98 +25,89 @@ import android.os.Parcelable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A class representing a (GPS) Track.
|
||||
*
|
||||
* TODO: hashCode and equals
|
||||
*
|
||||
* A track.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class Track implements Parcelable {
|
||||
|
||||
/**
|
||||
* Creator for a Track object.
|
||||
*/
|
||||
public static class Creator implements Parcelable.Creator<Track> {
|
||||
|
||||
public Track createFromParcel(Parcel source) {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
Track track = new Track();
|
||||
track.id = source.readLong();
|
||||
track.name = source.readString();
|
||||
track.description = source.readString();
|
||||
track.mapId = source.readString();
|
||||
track.category = source.readString();
|
||||
track.startId = source.readLong();
|
||||
track.stopId = source.readLong();
|
||||
track.stats = source.readParcelable(classLoader);
|
||||
|
||||
track.numberOfPoints = source.readInt();
|
||||
for (int i = 0; i < track.numberOfPoints; ++i) {
|
||||
Location loc = source.readParcelable(classLoader);
|
||||
track.locations.add(loc);
|
||||
}
|
||||
|
||||
track.tableId = source.readString();
|
||||
return track;
|
||||
}
|
||||
|
||||
public Track[] newArray(int size) {
|
||||
return new Track[size];
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator CREATOR = new Creator();
|
||||
|
||||
/**
|
||||
* The track points (which may not have been loaded).
|
||||
*/
|
||||
private ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
/**
|
||||
* The number of location points (present even if the points themselves were
|
||||
* not loaded).
|
||||
*/
|
||||
private int numberOfPoints = 0;
|
||||
|
||||
private long id = -1;
|
||||
private String name = "";
|
||||
private String description = "";
|
||||
private String mapId = "";
|
||||
private String tableId = "";
|
||||
private String category = "";
|
||||
private String categoryIcon = "";
|
||||
private long startId = -1;
|
||||
private long stopId = -1;
|
||||
private String category = "";
|
||||
|
||||
private TripStatistics stats = new TripStatistics();
|
||||
// The number of location points (present even if the points themselves are
|
||||
// not loaded)
|
||||
private int numberOfPoints = 0;
|
||||
private String mapId = "";
|
||||
private String tableId = "";
|
||||
|
||||
public Track() {
|
||||
private TripStatistics tripStatistics = new TripStatistics();
|
||||
|
||||
// Location points (which may not have been loaded)
|
||||
private ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
public Track() {}
|
||||
|
||||
private Track(Parcel in) {
|
||||
id = in.readLong();
|
||||
name = in.readString();
|
||||
description = in.readString();
|
||||
category = in.readString();
|
||||
categoryIcon = in.readString();
|
||||
startId = in.readLong();
|
||||
stopId = in.readLong();
|
||||
numberOfPoints = in.readInt();
|
||||
mapId = in.readString();
|
||||
tableId = in.readString();
|
||||
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
for (int i = 0; i < numberOfPoints; ++i) {
|
||||
Location loc = in.readParcelable(classLoader);
|
||||
locations.add(loc);
|
||||
}
|
||||
|
||||
tripStatistics = in.readParcelable(classLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(id);
|
||||
dest.writeString(name);
|
||||
dest.writeString(description);
|
||||
dest.writeString(mapId);
|
||||
dest.writeString(category);
|
||||
dest.writeString(categoryIcon);
|
||||
dest.writeLong(startId);
|
||||
dest.writeLong(stopId);
|
||||
dest.writeParcelable(stats, 0);
|
||||
|
||||
dest.writeInt(numberOfPoints);
|
||||
dest.writeString(mapId);
|
||||
dest.writeString(tableId);
|
||||
for (int i = 0; i < numberOfPoints; ++i) {
|
||||
dest.writeParcelable(locations.get(i), 0);
|
||||
}
|
||||
|
||||
dest.writeString(tableId);
|
||||
dest.writeParcelable(tripStatistics, 0);
|
||||
}
|
||||
|
||||
// Getters and setters:
|
||||
//---------------------
|
||||
public static final Parcelable.Creator<Track> CREATOR = new Parcelable.Creator<Track>() {
|
||||
@Override
|
||||
public Track createFromParcel(Parcel in) {
|
||||
return new Track(in);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public Track[] newArray(int size) {
|
||||
return new Track[size];
|
||||
}
|
||||
};
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -133,6 +125,30 @@ public class Track implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getCategoryIcon() {
|
||||
return categoryIcon;
|
||||
}
|
||||
|
||||
public void setCategoryIcon(String categoryIcon) {
|
||||
this.categoryIcon = categoryIcon;
|
||||
}
|
||||
|
||||
public long getStartId() {
|
||||
return startId;
|
||||
}
|
||||
@@ -149,12 +165,12 @@ public class Track implements Parcelable {
|
||||
this.stopId = stopId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public int getNumberOfPoints() {
|
||||
return numberOfPoints;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setNumberOfPoints(int numberOfPoints) {
|
||||
this.numberOfPoints = numberOfPoints;
|
||||
}
|
||||
|
||||
public String getMapId() {
|
||||
@@ -173,22 +189,6 @@ public class Track implements Parcelable {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public int getNumberOfPoints() {
|
||||
return numberOfPoints;
|
||||
}
|
||||
|
||||
public void setNumberOfPoints(int numberOfPoints) {
|
||||
this.numberOfPoints = numberOfPoints;
|
||||
}
|
||||
|
||||
public void addLocation(Location l) {
|
||||
locations.add(l);
|
||||
}
|
||||
@@ -201,11 +201,11 @@ public class Track implements Parcelable {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public TripStatistics getStatistics() {
|
||||
return stats;
|
||||
public TripStatistics getTripStatistics() {
|
||||
return tripStatistics;
|
||||
}
|
||||
|
||||
public void setStatistics(TripStatistics stats) {
|
||||
this.stats = stats;
|
||||
public void setTripStatistics(TripStatistics tripStatistics) {
|
||||
this.tripStatistics = tripStatistics;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,51 +13,66 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
/**
|
||||
* Defines the URI for the tracks provider and the available column names
|
||||
* and content types.
|
||||
*
|
||||
* Constants for track table.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public interface TracksColumns extends BaseColumns {
|
||||
|
||||
public static final Uri CONTENT_URI =
|
||||
Uri.parse("content://com.google.android.maps.mytracks/tracks");
|
||||
public static final String CONTENT_TYPE =
|
||||
"vnd.android.cursor.dir/vnd.google.track";
|
||||
public static final String CONTENT_ITEMTYPE =
|
||||
"vnd.android.cursor.item/vnd.google.track";
|
||||
/**
|
||||
* Tracks provider uri.
|
||||
*/
|
||||
public static final Uri CONTENT_URI = Uri.parse(
|
||||
"content://com.google.android.maps.mytracks/tracks");
|
||||
|
||||
/**
|
||||
* Track content type.
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.track";
|
||||
|
||||
/**
|
||||
* Track id content type.
|
||||
*/
|
||||
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.track";
|
||||
|
||||
/**
|
||||
* Tracks table default sort order.
|
||||
*/
|
||||
public static final String DEFAULT_SORT_ORDER = "_id";
|
||||
|
||||
/* All columns */
|
||||
public static final String NAME = "name";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String CATEGORY = "category";
|
||||
public static final String STARTID = "startid";
|
||||
public static final String STOPID = "stopid";
|
||||
public static final String STARTTIME = "starttime";
|
||||
public static final String STOPTIME = "stoptime";
|
||||
public static final String NUMPOINTS = "numpoints";
|
||||
public static final String TOTALDISTANCE = "totaldistance";
|
||||
public static final String TOTALTIME = "totaltime";
|
||||
public static final String MOVINGTIME = "movingtime";
|
||||
public static final String AVGSPEED = "avgspeed";
|
||||
public static final String AVGMOVINGSPEED = "avgmovingspeed";
|
||||
public static final String MAXSPEED = "maxspeed";
|
||||
public static final String MINELEVATION = "minelevation";
|
||||
public static final String MAXELEVATION = "maxelevation";
|
||||
public static final String ELEVATIONGAIN = "elevationgain";
|
||||
public static final String MINGRADE = "mingrade";
|
||||
public static final String MAXGRADE = "maxgrade";
|
||||
public static final String MINLAT = "minlat";
|
||||
public static final String MAXLAT = "maxlat";
|
||||
public static final String MINLON = "minlon";
|
||||
public static final String MAXLON = "maxlon";
|
||||
public static final String MAPID = "mapid";
|
||||
public static final String TABLEID = "tableid";
|
||||
// Tracks table columns
|
||||
public static final String NAME = "name"; // track name
|
||||
public static final String DESCRIPTION = "description"; // track description
|
||||
public static final String CATEGORY = "category"; // track activity type
|
||||
public static final String CATEGORY_ICON = "categoryicon"; // track activity type icon
|
||||
public static final String STARTID = "startid"; // first track point id
|
||||
public static final String STOPID = "stopid"; // last track point id
|
||||
public static final String STARTTIME = "starttime"; // track start time
|
||||
public static final String STOPTIME = "stoptime"; // track stop time
|
||||
public static final String NUMPOINTS = "numpoints"; // number of track points
|
||||
public static final String TOTALDISTANCE = "totaldistance"; // total distance
|
||||
public static final String TOTALTIME = "totaltime"; // total time
|
||||
public static final String MOVINGTIME = "movingtime"; // moving time
|
||||
public static final String AVGSPEED = "avgspeed"; // average speed
|
||||
public static final String AVGMOVINGSPEED = "avgmovingspeed"; // average
|
||||
// moving speed
|
||||
public static final String MAXSPEED = "maxspeed"; // maximum speed
|
||||
public static final String MINELEVATION = "minelevation"; // minimum elevation
|
||||
public static final String MAXELEVATION = "maxelevation"; // maximum elevation
|
||||
public static final String ELEVATIONGAIN = "elevationgain"; // elevation gain
|
||||
public static final String MINGRADE = "mingrade"; // minimum grade
|
||||
public static final String MAXGRADE = "maxgrade"; // maximum grade
|
||||
public static final String MINLAT = "minlat"; // minimum latitude
|
||||
public static final String MAXLAT = "maxlat"; // maximum latitude
|
||||
public static final String MINLON = "minlon"; // minimum longitude
|
||||
public static final String MAXLON = "maxlon"; // maximum longitude
|
||||
public static final String MAPID = "mapid"; // Google Maps id
|
||||
public static final String TABLEID = "tableid"; // Google Fusion Tables id
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
|
||||
stats.setMaxGrade(0.42);
|
||||
stats.setMinGrade(0.11);
|
||||
stats.setStartTime(START_TIME);
|
||||
track.setStatistics(stats);
|
||||
track.setTripStatistics(stats);
|
||||
track.setCategory("hiking");
|
||||
String expected = "Created by"
|
||||
+ " <a href='http://www.google.com/mobile/mytracks'>My Tracks</a> on Android.<p>"
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SearchEngineTest extends AndroidTestCase {
|
||||
track.setDescription(description);
|
||||
track.setCategory(category);
|
||||
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
if (hoursAgo > 0) {
|
||||
// Started twice hoursAgo, so the average time is hoursAgo.
|
||||
stats.setStartTime(NOW - hoursAgo * 1000L * 60L * 60L * 2);
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SendDocsUtilsTest extends AndroidTestCase {
|
||||
track.setName("trackName");
|
||||
track.setDescription("trackDescription");
|
||||
track.setMapId("trackMapId");
|
||||
track.setStatistics(stats);
|
||||
track.setTripStatistics(stats);
|
||||
return track;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,9 @@ import static com.google.android.testing.mocking.AndroidMock.eq;
|
||||
import static com.google.android.testing.mocking.AndroidMock.expect;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
||||
import com.google.android.apps.mytracks.io.file.GpxImporter;
|
||||
import com.google.android.apps.mytracks.testing.TestingProviderUtilsFactory;
|
||||
import com.google.android.testing.mocking.AndroidMock;
|
||||
import com.google.android.testing.mocking.UsesMocks;
|
||||
@@ -171,7 +170,7 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
Track track = trackParam.getValue();
|
||||
assertEquals(TRACK_NAME, track.getName());
|
||||
assertEquals(TRACK_DESC, track.getDescription());
|
||||
assertEquals(DATE_FORMAT2.parse(TRACK_TIME_1).getTime(), track.getStatistics()
|
||||
assertEquals(DATE_FORMAT2.parse(TRACK_TIME_1).getTime(), track.getTripStatistics()
|
||||
.getStartTime());
|
||||
assertNotSame(-1, track.getStartId());
|
||||
assertNotSame(-1, track.getStopId());
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
||||
Track track = new Track();
|
||||
TripStatistics stats = new TripStatistics();
|
||||
stats.setBounds((int) 100.E6, (int) 10.E6, (int) 50.E6, (int) 5.E6);
|
||||
track.setStatistics(stats);
|
||||
track.setTripStatistics(stats);
|
||||
track.setTableId(null);
|
||||
assertEquals(null, SendFusionTablesUtils.getMapUrl(track));
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
||||
*/
|
||||
public void testGetMapUrl_null_stats() {
|
||||
Track track = new Track();
|
||||
track.setStatistics(null);
|
||||
track.setTripStatistics(null);
|
||||
track.setTableId("123");
|
||||
assertEquals(null, SendFusionTablesUtils.getMapUrl(track));
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
||||
Track track = new Track();
|
||||
TripStatistics stats = new TripStatistics();
|
||||
stats.setBounds((int) 100.E6, (int) 10.E6, (int) 50.E6, (int) 5.E6);
|
||||
track.setStatistics(stats);
|
||||
track.setTripStatistics(stats);
|
||||
track.setTableId("123");
|
||||
assertEquals(
|
||||
"https://www.google.com/fusiontables/embedviz?"
|
||||
|
||||
+5
-4
@@ -56,13 +56,14 @@ public class SendToGoogleUtilsTest extends TestCase {
|
||||
*/
|
||||
public void testPrepareTrackSegment_noStopTime() {
|
||||
Track trackStub = TrackStubUtils.createTrack(2);
|
||||
assertEquals(-1L, trackStub.getStatistics().getStopTime());
|
||||
assertEquals(-1L, trackStub.getTripStatistics().getStopTime());
|
||||
|
||||
ArrayList<Track> tracksArray = new ArrayList<Track>();
|
||||
assertTrue(SendToGoogleUtils.prepareTrackSegment(trackStub, tracksArray));
|
||||
assertEquals(trackStub, tracksArray.get(0));
|
||||
// The stop time should be the time of last location
|
||||
assertEquals(trackStub.getLocations().get(1).getTime(), trackStub.getStatistics().getStopTime());
|
||||
assertEquals(
|
||||
trackStub.getLocations().get(1).getTime(), trackStub.getTripStatistics().getStopTime());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,12 +76,12 @@ public class SendToGoogleUtilsTest extends TestCase {
|
||||
// Gives a margin to make sure the this time will be not same with the last
|
||||
// location in the track.
|
||||
long stopTime = System.currentTimeMillis() + 1000;
|
||||
trackStub.getStatistics().setStopTime(stopTime);
|
||||
trackStub.getTripStatistics().setStopTime(stopTime);
|
||||
|
||||
ArrayList<Track> tracksArray = new ArrayList<Track>();
|
||||
SendToGoogleUtils.prepareTrackSegment(trackStub, tracksArray);
|
||||
assertEquals(trackStub, tracksArray.get(0));
|
||||
assertEquals(stopTime, trackStub.getStatistics().getStopTime());
|
||||
assertEquals(stopTime, trackStub.getTripStatistics().getStopTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -676,7 +676,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
dummyTrack.setName("Dummy Track");
|
||||
TripStatistics tripStatistics = new TripStatistics();
|
||||
tripStatistics.setStopTime(stopTime);
|
||||
dummyTrack.setStatistics(tripStatistics);
|
||||
dummyTrack.setTripStatistics(tripStatistics);
|
||||
addTrack(dummyTrack, isRecording);
|
||||
return dummyTrack;
|
||||
}
|
||||
@@ -740,7 +740,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
track = providerUtils.getTrack(id);
|
||||
assertNotNull(track);
|
||||
assertEquals(id, track.getId());
|
||||
TripStatistics tripStatistics = track.getStatistics();
|
||||
TripStatistics tripStatistics = track.getTripStatistics();
|
||||
assertNotNull(tripStatistics);
|
||||
assertTrue(tripStatistics.getStartTime() > 0);
|
||||
assertTrue(tripStatistics.getStopTime() >= tripStatistics.getStartTime());
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ChartURLGeneratorTest extends TestCase {
|
||||
Vector<Double> distances = new Vector<Double>();
|
||||
Vector<Double> elevations = new Vector<Double>();
|
||||
Track t = new Track();
|
||||
TripStatistics stats = t.getStatistics();
|
||||
TripStatistics stats = t.getTripStatistics();
|
||||
stats.setMinElevation(0);
|
||||
stats.setMaxElevation(2000);
|
||||
stats.setTotalDistance(100);
|
||||
|
||||
Reference in New Issue
Block a user