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;
|
||||
|
||||
Reference in New Issue
Block a user