Lint cleanup.

This commit is contained in:
Dennis Guse
2019-06-25 07:09:51 +02:00
parent 5efe1dba62
commit 3d09ee363d
45 changed files with 286 additions and 314 deletions
@@ -83,9 +83,8 @@ public class TrackStubUtils {
loc.setTime(INITIAL_TIME); loc.setTime(INITIAL_TIME);
loc.setBearing(INITIAL_BEARING); loc.setBearing(INITIAL_BEARING);
SensorDataSet sd = SensorDataSet.newBuilder().build(); SensorDataSet sd = SensorDataSet.newBuilder().build();
MyTracksLocation myTracksLocation = new MyTracksLocation(loc, sd);
return myTracksLocation; return new MyTracksLocation(loc, sd);
} }
} }
@@ -210,7 +210,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
// Id // Id
AndroidMock.expect(cursorMock.getLong(columnIndex++)).andReturn(trackId); AndroidMock.expect(cursorMock.getLong(columnIndex++)).andReturn(trackId);
// Name // Name
String name = NAME_PREFIX + Long.toString(trackId); String name = NAME_PREFIX + trackId;
AndroidMock.expect(cursorMock.getString(columnIndex++)).andReturn(name); AndroidMock.expect(cursorMock.getString(columnIndex++)).andReturn(name);
AndroidMock.replay(cursorMock); AndroidMock.replay(cursorMock);
Track track = providerUtils.createTrack(cursorMock); Track track = providerUtils.createTrack(cursorMock);
@@ -416,7 +416,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
// Id // Id
AndroidMock.expect(cursorMock.getLong(columnIndex++)).andReturn(id); AndroidMock.expect(cursorMock.getLong(columnIndex++)).andReturn(id);
// Name // Name
String name = NAME_PREFIX + Long.toString(id); String name = NAME_PREFIX + id;
AndroidMock.expect(cursorMock.getString(columnIndex++)).andReturn(name); AndroidMock.expect(cursorMock.getString(columnIndex++)).andReturn(name);
// trackIdIndex // trackIdIndex
long trackId = 11L; long trackId = 11L;
@@ -153,12 +153,12 @@ public abstract class TrackWriterTest extends AndroidTestCase {
assertTrue(length > 0); assertTrue(length > 0);
// The children may be a sucession of text elements, just concatenate them // The children may be a sucession of text elements, just concatenate them
String result = ""; StringBuilder result = new StringBuilder();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Text textNode = (Text) children.item(i); Text textNode = (Text) children.item(i);
result += textNode.getNodeValue(); result.append(textNode.getNodeValue());
} }
return result; return result.toString();
} }
/** /**
@@ -212,8 +212,7 @@ public abstract class TrackWriterTest extends AndroidTestCase {
builderFactory.setIgnoringComments(true); builderFactory.setIgnoringComments(true);
builderFactory.setIgnoringElementContentWhitespace(true); builderFactory.setIgnoringElementContentWhitespace(true);
DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
Document doc = documentBuilder.parse(
new InputSource(new StringReader(contents))); return documentBuilder.parse(new InputSource(new StringReader(contents)));
return doc;
} }
} }
@@ -164,26 +164,25 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
@Override @Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) { String sortOrder) {
MockCursor mockCursor = new MockCursor() { return new MockCursor() {
@Override @Override
public int getCount() { public int getCount() {
return 1; return 1;
} }
@Override @Override
public boolean moveToNext() { public boolean moveToNext() {
return true; return true;
} }
@Override @Override
public String getString(int columnIndex) { public String getString(int columnIndex) {
return String.valueOf(GoogleLocationUtils.USE_LOCATION_FOR_SERVICES_ON); return String.valueOf(GoogleLocationUtils.USE_LOCATION_FOR_SERVICES_ON);
} }
@Override @Override
public void close() {} public void close() {}
}; };
return mockCursor;
} }
}; };
mockContentResolver.addProvider("com.google.settings", googleSettingsProvider); mockContentResolver.addProvider("com.google.settings", googleSettingsProvider);
@@ -165,7 +165,7 @@ public class StringUtilsTest extends AndroidTestCase {
* Tests {@link StringUtils#getTimeParts(long)} with a positive number. * Tests {@link StringUtils#getTimeParts(long)} with a positive number.
*/ */
public void testGetTimeParts_postive() { public void testGetTimeParts_postive() {
int parts[] = StringUtils.getTimeParts(61000); int[] parts = StringUtils.getTimeParts(61000);
assertEquals(1, parts[0]); assertEquals(1, parts[0]);
assertEquals(1, parts[1]); assertEquals(1, parts[1]);
assertEquals(0, parts[2]); assertEquals(0, parts[2]);
@@ -175,7 +175,7 @@ public class StringUtilsTest extends AndroidTestCase {
* Tests {@link StringUtils#getTimeParts(long)} with a negative number. * Tests {@link StringUtils#getTimeParts(long)} with a negative number.
*/ */
public void testGetTimeParts_negative() { public void testGetTimeParts_negative() {
int parts[] = StringUtils.getTimeParts(-61000); int[] parts = StringUtils.getTimeParts(-61000);
assertEquals(-1, parts[0]); assertEquals(-1, parts[0]);
assertEquals(-1, parts[1]); assertEquals(-1, parts[1]);
assertEquals(0, parts[2]); assertEquals(0, parts[2]);
@@ -58,13 +58,11 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) { if (requestCode == DELETE_REQUEST_CODE) {
case DELETE_REQUEST_CODE: onDeleted();
onDeleted(); } else {
break; super.onActivityResult(requestCode, resultCode, data);
default: }
super.onActivityResult(requestCode, resultCode, data);
}
} }
public static void configureListViewContextualMenu(final Activity activity, final ListView listView, public static void configureListViewContextualMenu(final Activity activity, final ListView listView,
@@ -33,7 +33,7 @@ public interface ContextualActionModeCallback {
* @param ids the selected items' ids, if available * @param ids the selected items' ids, if available
* @param showSelectAll true to show select all * @param showSelectAll true to show select all
*/ */
public void onPrepare(Menu menu, int[] positions, long[] ids, boolean showSelectAll); void onPrepare(Menu menu, int[] positions, long[] ids, boolean showSelectAll);
/** /**
* Invoked when items are selected. * Invoked when items are selected.
@@ -42,5 +42,5 @@ public interface ContextualActionModeCallback {
* @param positions the selected items' positions * @param positions the selected items' positions
* @param ids the selected items' ids, if available * @param ids the selected items' ids, if available
*/ */
public boolean onClick(int itemId, int[] positions, long[] ids); boolean onClick(int itemId, int[] positions, long[] ids);
} }
@@ -289,12 +289,10 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { if (item.getItemId() == R.id.search_list_search) {
case R.id.search_list_search: return false;
return false;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(item);
} }
@Override @Override
@@ -204,8 +204,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY) photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY)
: null; : null;
hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false) hasPhoto = savedInstanceState != null && savedInstanceState.getBoolean(HAS_PHOTO_KEY, false);
: false;
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this); myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
handleIntent(getIntent()); handleIntent(getIntent());
@@ -215,8 +215,8 @@ public class TrackListActivity extends AbstractSendToGoogleActivity implements F
@Override @Override
public boolean onClick(int itemId, int[] positions, long[] ids) { public boolean onClick(int itemId, int[] positions, long[] ids) {
return handleContextItem(itemId, ids); return handleContextItem(itemId, ids);
}; }
}; };
private final OnClickListener recordListener = new OnClickListener() { private final OnClickListener recordListener = new OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
@@ -563,7 +563,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity implements F
// Hide trackController when search dialog is shown // Hide trackController when search dialog is shown
trackController.hide(); trackController.hide();
return super.onSearchRequested(); return super.onSearchRequested();
}; }
@Override @Override
protected TrackRecordingServiceConnection getTrackRecordingServiceConnection() { protected TrackRecordingServiceConnection getTrackRecordingServiceConnection() {
@@ -27,22 +27,22 @@ public interface DataSourceListener {
/** /**
* Notifies when the tracks table is updated. * Notifies when the tracks table is updated.
*/ */
public void notifyTracksTableUpdated(); void notifyTracksTableUpdated();
/** /**
* Notifies when the waypoints table is updated. * Notifies when the waypoints table is updated.
*/ */
public void notifyWaypointsTableUpdated(); void notifyWaypointsTableUpdated();
/** /**
* Notifies when the track points table is updated. * Notifies when the track points table is updated.
*/ */
public void notifyTrackPointsTableUpdated(); void notifyTrackPointsTableUpdated();
/** /**
* Notifies when a preference changes. * Notifies when a preference changes.
* *
* @param key the preference key * @param key the preference key
*/ */
public void notifyPreferenceChanged(String key); void notifyPreferenceChanged(String key);
} }
@@ -30,8 +30,8 @@ public interface TrackDataListener {
* *
* @author Jimmy Shih * @author Jimmy Shih
*/ */
public enum LocationState { enum LocationState {
DISABLED, NO_FIX, BAD_FIX, GOOD_FIX; DISABLED, NO_FIX, BAD_FIX, GOOD_FIX
} }
/** /**
@@ -39,31 +39,31 @@ public interface TrackDataListener {
* *
* @param track the track * @param track the track
*/ */
public void onTrackUpdated(Track track); void onTrackUpdated(Track track);
/** /**
* Called to clear previously-sent track points. * Called to clear previously-sent track points.
*/ */
public void clearTrackPoints(); void clearTrackPoints();
/** /**
* Called when a sampled in track point is read. * Called when a sampled in track point is read.
* *
* @param location the location * @param location the location
*/ */
public void onSampledInTrackPoint(Location location); void onSampledInTrackPoint(Location location);
/** /**
* Called when a sampled out track point is read. * Called when a sampled out track point is read.
* *
* @param location the location * @param location the location
*/ */
public void onSampledOutTrackPoint(Location location); void onSampledOutTrackPoint(Location location);
/** /**
* Called when an invalid track point representing a segment split is read. * Called when an invalid track point representing a segment split is read.
*/ */
public void onSegmentSplit(Location location); void onSegmentSplit(Location location);
/** /**
* Called when finish sending new track points. This gets called after every * Called when finish sending new track points. This gets called after every
@@ -71,26 +71,26 @@ public interface TrackDataListener {
* {@link #onSampledOutTrackPoint(Location)} and * {@link #onSampledOutTrackPoint(Location)} and
* {@link #onSegmentSplit(Location)}. * {@link #onSegmentSplit(Location)}.
*/ */
public void onNewTrackPointsDone(); void onNewTrackPointsDone();
/** /**
* Called to clear previously sent waypoints. * Called to clear previously sent waypoints.
*/ */
public void clearWaypoints(); void clearWaypoints();
/** /**
* Called when a new waypoint is read. * Called when a new waypoint is read.
* *
* @param waypoint the waypoint * @param waypoint the waypoint
*/ */
public void onNewWaypoint(Waypoint waypoint); void onNewWaypoint(Waypoint waypoint);
/** /**
* Called when finish sending new waypoints. This gets called after every * Called when finish sending new waypoints. This gets called after every
* batch of calls to {@link #clearWaypoints()} and * batch of calls to {@link #clearWaypoints()} and
* {@link #onNewWaypoint(Waypoint)}. * {@link #onNewWaypoint(Waypoint)}.
*/ */
public void onNewWaypointsDone(); void onNewWaypointsDone();
/** /**
* Called when the metric units preference value is change. * Called when the metric units preference value is change.
@@ -98,7 +98,7 @@ public interface TrackDataListener {
* @param metricUnits true to use metric units, false to use imperial units * @param metricUnits true to use metric units, false to use imperial units
* @return true to reload all the data, false otherwise. * @return true to reload all the data, false otherwise.
*/ */
public boolean onMetricUnitsChanged(boolean metricUnits); boolean onMetricUnitsChanged(boolean metricUnits);
/** /**
* Called when the report speed preference value is changed. * Called when the report speed preference value is changed.
@@ -106,7 +106,7 @@ public interface TrackDataListener {
* @param reportSpeed true to report speed, false to report pace * @param reportSpeed true to report speed, false to report pace
* @return true to reload all the data, false otherwise. * @return true to reload all the data, false otherwise.
*/ */
public boolean onReportSpeedChanged(boolean reportSpeed); boolean onReportSpeedChanged(boolean reportSpeed);
/** /**
* Called when the recording gps accuracy preference value is changed. * Called when the recording gps accuracy preference value is changed.
@@ -114,7 +114,7 @@ public interface TrackDataListener {
* @param recordingGpsAccuracy the new value * @param recordingGpsAccuracy the new value
* @return true to reload all the data, false otherwise * @return true to reload all the data, false otherwise
*/ */
public boolean onRecordingGpsAccuracy(int recordingGpsAccuracy); boolean onRecordingGpsAccuracy(int recordingGpsAccuracy);
/** /**
* Called when the recording distance interval preference value is changed. * Called when the recording distance interval preference value is changed.
@@ -122,7 +122,7 @@ public interface TrackDataListener {
* @param recordingDistanceInterval the new value * @param recordingDistanceInterval the new value
* @return true to reload all the data, false otherwise. * @return true to reload all the data, false otherwise.
*/ */
public boolean onRecordingDistanceIntervalChanged(int recordingDistanceInterval); boolean onRecordingDistanceIntervalChanged(int recordingDistanceInterval);
/** /**
* Called when the map type preference value is changed. * Called when the map type preference value is changed.
@@ -130,5 +130,5 @@ public interface TrackDataListener {
* @param mapType the new value * @param mapType the new value
* @return true to reload all the data, false otherwise. * @return true to reload all the data, false otherwise.
*/ */
public boolean onMapTypeChanged(int mapType); boolean onMapTypeChanged(int mapType);
} }
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.util.DialogUtils;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
/** /**
@@ -30,6 +31,7 @@ import android.support.v4.app.DialogFragment;
*/ */
public abstract class AbstractMyTracksDialogFragment extends DialogFragment { public abstract class AbstractMyTracksDialogFragment extends DialogFragment {
@NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
final Dialog dialog = createDialog(); final Dialog dialog = createDialog();
@@ -105,7 +105,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
* data on every onStart or onResume. * data on every onStart or onResume.
*/ */
chartView = new ChartView(getActivity()); chartView = new ChartView(getActivity());
}; }
@Override @Override
public View onCreateView( public View onCreateView(
@@ -28,6 +28,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ShareCompat; import android.support.v4.app.ShareCompat;
import android.view.View; import android.view.View;
@@ -58,7 +59,7 @@ public class ChooseActivityDialogFragment extends AbstractMyTracksDialogFragment
/** /**
* Called when choose activity is done. * Called when choose activity is done.
*/ */
public void onChooseActivityDone(String packageName, String className); void onChooseActivityDone(String packageName, String className);
} }
private static class ViewHolder { private static class ViewHolder {
@@ -91,8 +92,9 @@ public class ChooseActivityDialogFragment extends AbstractMyTracksDialogFragment
ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(fragmentActivity, ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(fragmentActivity,
R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) { R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) {
@NonNull
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View view; View view;
ViewHolder viewHolder; ViewHolder viewHolder;
if (convertView == null) { if (convertView == null) {
@@ -56,7 +56,7 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
/** /**
* Called when choose activity type is done. * Called when choose activity type is done.
*/ */
public void onChooseActivityTypeDone(String iconValue, boolean newWeight); void onChooseActivityTypeDone(String iconValue, boolean newWeight);
} }
public static final String CHOOSE_ACTIVITY_TYPE_DIALOG_TAG = "chooseActivityType"; public static final String CHOOSE_ACTIVITY_TYPE_DIALOG_TAG = "chooseActivityType";
@@ -45,7 +45,7 @@ public class ConfirmDeleteDialogFragment extends AbstractMyTracksDialogFragment
* @param trackIds list of track ids to delete. To delete all, set to size 1 * @param trackIds list of track ids to delete. To delete all, set to size 1
* with trackIds[0] == -1L * with trackIds[0] == -1L
*/ */
public void onConfirmDeleteDone(long[] trackIds); void onConfirmDeleteDone(long[] trackIds);
} }
public static final String CONFIRM_DELETE_DIALOG_TAG = "confirmDeleteDialog"; public static final String CONFIRM_DELETE_DIALOG_TAG = "confirmDeleteDialog";
@@ -44,7 +44,7 @@ public class DeleteMarkerDialogFragment extends AbstractMyTracksDialogFragment {
/** /**
* Called when delete marker is done. * Called when delete marker is done.
*/ */
public void onDeleteMarkerDone(); void onDeleteMarkerDone();
} }
public static final String DELETE_MARKER_DIALOG_TAG = "deleteMarkerDialog"; public static final String DELETE_MARKER_DIALOG_TAG = "deleteMarkerDialog";
@@ -44,7 +44,7 @@ public class FileTypeDialogFragment extends AbstractMyTracksDialogFragment {
/** /**
* Called when file type selection is done. * Called when file type selection is done.
*/ */
public void onFileTypeDone(int menuId, TrackFileFormat trackFileFormat); void onFileTypeDone(int menuId, TrackFileFormat trackFileFormat);
} }
public static final String FILE_TYPE_DIALOG_TAG = "fileType"; public static final String FILE_TYPE_DIALOG_TAG = "fileType";
@@ -143,9 +143,9 @@ public class MarkerDetailFragment extends Fragment {
} }
}); });
return view; return view;
}; }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@@ -425,9 +425,9 @@ public class KmlTrackWriter implements TrackWriter {
private String getCoordinates(Location location, String separator) { private String getCoordinates(Location location, String separator) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append(location.getLongitude() + separator + location.getLatitude()); buffer.append(location.getLongitude()).append(separator).append(location.getLatitude());
if (location.hasAltitude()) { if (location.hasAltitude()) {
buffer.append(separator + location.getAltitude()); buffer.append(separator).append(location.getAltitude());
} }
return buffer.toString(); return buffer.toString();
} }
@@ -185,7 +185,7 @@ public class KmzTrackExporter implements TrackExporter {
try { try {
fileInputStream = new FileInputStream(new File(uri.getPath())); fileInputStream = new FileInputStream(new File(uri.getPath()));
byte[] buffer = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];
int byteCount = 0; int byteCount;
while ((byteCount = fileInputStream.read(buffer)) != -1) { while ((byteCount = fileInputStream.read(buffer)) != -1) {
zipOutputStream.write(buffer, 0, byteCount); zipOutputStream.write(buffer, 0, byteCount);
} }
@@ -29,5 +29,5 @@ public interface TrackExporterListener {
* @param max the maximum number of locations in a track, for calculation of * @param max the maximum number of locations in a track, for calculation of
* completion percentage * completion percentage
*/ */
public void onProgressUpdate(int number, int max); void onProgressUpdate(int number, int max);
} }
@@ -54,60 +54,60 @@ public interface TrackWriter {
/** /**
* Gets the file extension (e.g, gpx, kml, ...). * Gets the file extension (e.g, gpx, kml, ...).
*/ */
public String getExtension(); String getExtension();
/** /**
* Prepares the output stream. * Prepares the output stream.
* *
* @param outputStream the output stream * @param outputStream the output stream
*/ */
public void prepare(OutputStream outputStream); void prepare(OutputStream outputStream);
/** /**
* Closes the output stream. * Closes the output stream.
*/ */
public void close(); void close();
/** /**
* Writes the header * Writes the header
* *
* @param tracks the tracks * @param tracks the tracks
*/ */
public void writeHeader(Track[] tracks); void writeHeader(Track[] tracks);
/** /**
* Writes the footer. * Writes the footer.
*/ */
public void writeFooter(); void writeFooter();
/** /**
* Writes the beginning of the waypoints. * Writes the beginning of the waypoints.
* *
* @param track the track * @param track the track
*/ */
public void writeBeginWaypoints(Track track); void writeBeginWaypoints(Track track);
/** /**
* Writes the end of the waypoints. * Writes the end of the waypoints.
*/ */
public void writeEndWaypoints(); void writeEndWaypoints();
/** /**
* Writes a waypoint. * Writes a waypoint.
* *
* @param waypoint the waypoint * @param waypoint the waypoint
*/ */
public void writeWaypoint(Waypoint waypoint); void writeWaypoint(Waypoint waypoint);
/** /**
* Writes the beginning of the tracks. * Writes the beginning of the tracks.
*/ */
public void writeBeginTracks(); void writeBeginTracks();
/** /**
* Writes the end of the tracks, * Writes the end of the tracks,
*/ */
public void writeEndTracks(); void writeEndTracks();
/** /**
* Writes the beginning of a track. * Writes the beginning of a track.
@@ -115,7 +115,7 @@ public interface TrackWriter {
* @param track the track * @param track the track
* @param startLocation the start location * @param startLocation the start location
*/ */
public void writeBeginTrack(Track track, Location startLocation); void writeBeginTrack(Track track, Location startLocation);
/** /**
* Writes the end of a track. * Writes the end of a track.
@@ -123,22 +123,22 @@ public interface TrackWriter {
* @param track the track * @param track the track
* @param endLocation the end location * @param endLocation the end location
*/ */
public void writeEndTrack(Track track, Location endLocation); void writeEndTrack(Track track, Location endLocation);
/** /**
* Writes open segment. * Writes open segment.
*/ */
public void writeOpenSegment(); void writeOpenSegment();
/** /**
* Writes close segment. * Writes close segment.
*/ */
public void writeCloseSegment(); void writeCloseSegment();
/** /**
* Writes a location. * Writes a location.
* *
* @param location the location * @param location the location
*/ */
public void writeLocation(Location location); void writeLocation(Location location);
} }
@@ -30,5 +30,5 @@ public interface TrackImporter {
* @param inputStream the file's input stream * @param inputStream the file's input stream
* @return the imported track id or -1L. * @return the imported track id or -1L.
*/ */
public long importFile(InputStream inputStream); long importFile(InputStream inputStream);
} }
@@ -30,12 +30,12 @@ public interface LocationListenerPolicy {
* *
* @return the polling interval * @return the polling interval
*/ */
public long getDesiredPollingInterval(); long getDesiredPollingInterval();
/** /**
* Returns the minimum distance between updates. * Returns the minimum distance between updates.
*/ */
public int getMinDistance(); int getMinDistance();
/** /**
* Notifies the amount of time the user has been idle at his current location. * Notifies the amount of time the user has been idle at his current location.
@@ -43,5 +43,5 @@ public interface LocationListenerPolicy {
* @param idleTime the time that the user has been idle at his current * @param idleTime the time that the user has been idle at his current
* location * location
*/ */
public void updateIdleTime(long idleTime); void updateIdleTime(long idleTime);
} }
@@ -31,6 +31,7 @@ import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
import android.os.Process; import android.os.Process;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder; import android.support.v4.app.TaskStackBuilder;
@@ -303,18 +304,6 @@ public class TrackRecordingService extends Service {
} }
} }
/*
* Note that this service, through the AndroidManifest.xml, is configured to
* allow both MyTracks and third party apps to invoke it. For the onStart
* callback, we cannot tell whether the caller is MyTracks or a third party
* app, thus it cannot start/stop a recording or write/update MyTracks
* database.
*/
@Override
public void onStart(Intent intent, int startId) {
handleStartCommand(intent, startId);
}
/* /*
* Note that this service, through the AndroidManifest.xml, is configured to * Note that this service, through the AndroidManifest.xml, is configured to
* allow both MyTracks and third party apps to invoke it. For the * allow both MyTracks and third party apps to invoke it. For the
@@ -1157,12 +1146,12 @@ public class TrackRecordingService extends Service {
} }
@Override @Override
public void linkToDeath(DeathRecipient recipient, int flags) { public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
deathRecipient = recipient; deathRecipient = recipient;
} }
@Override @Override
public boolean unlinkToDeath(DeathRecipient recipient, int flags) { public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
if (!isBinderAlive()) { if (!isBinderAlive()) {
return false; return false;
} }
@@ -25,11 +25,11 @@ import com.google.android.apps.mytracks.content.Sensor;
*/ */
public interface MessageParser { public interface MessageParser {
public int getFrameSize(); int getFrameSize();
public Sensor.SensorDataSet parseBuffer(byte[] readBuff); Sensor.SensorDataSet parseBuffer(byte[] readBuff);
public boolean isValid(byte[] buffer); boolean isValid(byte[] buffer);
public int findNextAlignment(byte[] buffer); int findNextAlignment(byte[] buffer);
} }
@@ -89,12 +89,10 @@ public class PolarMessageParser implements MessageParser {
.setValue(heartRate) .setValue(heartRate)
.setState(Sensor.SensorState.SENDING); .setState(Sensor.SensorState.SENDING);
Sensor.SensorDataSet sds = Sensor.SensorDataSet.newBuilder() return Sensor.SensorDataSet.newBuilder()
.setCreationTime(System.currentTimeMillis()) .setCreationTime(System.currentTimeMillis())
.setHeartRate(b) .setHeartRate(b)
.build(); .build();
return sds;
} }
/** /**
@@ -27,17 +27,17 @@ public interface PeriodicTask {
/** /**
* Sets up this task for subsequent calls to the run method. * Sets up this task for subsequent calls to the run method.
*/ */
public void start(); void start();
/** /**
* This method will be called periodically. * This method will be called periodically.
* *
* @param trackRecordingService the track recording service * @param trackRecordingService the track recording service
*/ */
public void run(TrackRecordingService trackRecordingService); void run(TrackRecordingService trackRecordingService);
/** /**
* Shuts down this task and clean up resources. * Shuts down this task and clean up resources.
*/ */
public void shutdown(); void shutdown();
} }
@@ -30,5 +30,5 @@ public interface PeriodicTaskFactory {
* *
* @return the task, or null if the task is not supported * @return the task, or null if the task is not supported
*/ */
public PeriodicTask create(Context context); PeriodicTask create(Context context);
} }
@@ -203,22 +203,18 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
String displayValue; String displayValue;
if (metricUnits) { if (metricUnits) {
displayValue = getString(R.string.value_integer_meter, value); displayValue = getString(R.string.value_integer_meter, value);
switch (value) { if (value == PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT) {
case PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT: options[i] = getString(R.string.value_integer_meter_recommended, value);
options[i] = getString(R.string.value_integer_meter_recommended, value); } else {
break; options[i] = displayValue;
default:
options[i] = displayValue;
} }
} else { } else {
int feet = (int) (value * UnitConversions.M_TO_FT); int feet = (int) (value * UnitConversions.M_TO_FT);
displayValue = getString(R.string.value_integer_feet, feet); displayValue = getString(R.string.value_integer_feet, feet);
switch (value) { if (value == PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT) {
case PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT: options[i] = getString(R.string.value_integer_feet_recommended, feet);
options[i] = getString(R.string.value_integer_feet_recommended, feet); } else {
break; options[i] = displayValue;
default:
options[i] = displayValue;
} }
} }
summary[i] = getString(R.string.settings_recording_location_frequency_summary, displayValue); summary[i] = getString(R.string.settings_recording_location_frequency_summary, displayValue);
@@ -240,23 +236,19 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
String displayValue; String displayValue;
if (metricUnits) { if (metricUnits) {
displayValue = getString(R.string.value_integer_meter, value); displayValue = getString(R.string.value_integer_meter, value);
switch (value) { if (value == PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT) {
case PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT: options[i] = getString(R.string.value_integer_meter_recommended, value);
options[i] = getString(R.string.value_integer_meter_recommended, value); } else {
break; options[i] = displayValue;
default:
options[i] = displayValue;
} }
} else { } else {
int feet = (int) (value * UnitConversions.M_TO_FT); int feet = (int) (value * UnitConversions.M_TO_FT);
if (feet < 2000) { if (feet < 2000) {
displayValue = getString(R.string.value_integer_feet, feet); displayValue = getString(R.string.value_integer_feet, feet);
switch (value) { if (value == PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT) {
case PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT: options[i] = getString(R.string.value_integer_feet_recommended, feet);
options[i] = getString(R.string.value_integer_feet_recommended, feet); } else {
break; options[i] = displayValue;
default:
options[i] = displayValue;
} }
} else { } else {
double mile = feet * UnitConversions.FT_TO_MI; double mile = feet * UnitConversions.FT_TO_MI;
@@ -314,12 +306,10 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
} else { } else {
double mile = feet * UnitConversions.FT_TO_MI; double mile = feet * UnitConversions.FT_TO_MI;
displayValue = getString(R.string.value_float_mile, mile); displayValue = getString(R.string.value_float_mile, mile);
switch (value) { if (value == PreferencesUtils.RECORDING_GPS_ACCURACY_POOR) {
case PreferencesUtils.RECORDING_GPS_ACCURACY_POOR: options[i] = getString(R.string.value_float_mile_poor_gps, mile);
options[i] = getString(R.string.value_float_mile_poor_gps, mile); } else {
break; options[i] = displayValue;
default:
options[i] = displayValue;
} }
} }
} }
@@ -193,7 +193,7 @@ public class ListItemUtils {
if (buffer.length() != 0) { if (buffer.length() != 0) {
buffer.append(" "); buffer.append(" ");
} }
buffer.append("(" + totalDistance + ")"); buffer.append("(").append(totalDistance).append(")");
} }
return buffer.toString(); return buffer.toString();
} }
@@ -83,6 +83,7 @@ public class StringUtils {
*/ */
public static String formatElapsedTime(long time) { public static String formatElapsedTime(long time) {
/* /*
* TODO
* Temporary workaround for DateUtils.formatElapsedTime(time * MS_TO_S). In API * Temporary workaround for DateUtils.formatElapsedTime(time * MS_TO_S). In API
* level 17, it returns strings like "1:0:00" instead of "1:00:00", which * level 17, it returns strings like "1:0:00" instead of "1:00:00", which
* breaks several unit tests. * breaks several unit tests.
@@ -277,9 +278,9 @@ public class StringUtils {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[" + category + "]"); buffer.append("[").append(category).append("]");
if (description != null && description.length() != 0) { if (description != null && description.length() != 0) {
buffer.append(" " + description); buffer.append(" ").append(description);
} }
return buffer.toString(); return buffer.toString();
} }
@@ -23,6 +23,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.util.Pair; import android.util.Pair;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@@ -134,10 +135,8 @@ public class TrackIconUtils {
* Gets all icon values. * Gets all icon values.
*/ */
public static List<String> getAllIconValues() { public static List<String> getAllIconValues() {
List<String> values = new ArrayList<String>(); List<String> values = new ArrayList<>();
for (String value : MAP.keySet()) { values.addAll(MAP.keySet());
values.add(value);
}
return values; return values;
} }
@@ -191,10 +190,10 @@ public class TrackIconUtils {
final Context context, String iconValue) { final Context context, String iconValue) {
return new ArrayAdapter<StringBuilder>(context, android.R.layout.simple_spinner_item, return new ArrayAdapter<StringBuilder>(context, android.R.layout.simple_spinner_item,
new StringBuilder[] { new StringBuilder(iconValue) }) { new StringBuilder[] { new StringBuilder(iconValue) }) {
@NonNull
@Override @Override
public View getView(int position, View convertView, android.view.ViewGroup parent) { public View getView(int position, View convertView, @NonNull android.view.ViewGroup parent) {
ImageView imageView = convertView != null ? (ImageView) convertView ImageView imageView = convertView != null ? (ImageView) convertView : new ImageView(getContext());
: new ImageView(getContext());
Bitmap source = BitmapFactory.decodeResource( Bitmap source = BitmapFactory.decodeResource(
context.getResources(), TrackIconUtils.getIconDrawable(getItem(position).toString())); context.getResources(), TrackIconUtils.getIconDrawable(getItem(position).toString()));
imageView.setImageBitmap(source); imageView.setImageBitmap(source);
@@ -74,7 +74,7 @@ public class TrackNameUtils {
if (location != null) { if (location != null) {
String address = getReverseGeoCoding(context, location); String address = getReverseGeoCoding(context, location);
if (address != null && !address.equals("")) { if (address != null && !address.equals("")) {
value.append(" " + address); value.append(" ").append(address);
} }
} }
return value.toString(); return value.toString();
@@ -35,13 +35,13 @@ public interface DescriptionGenerator {
* @param elevations a vector of elevations to generate the elevation chart * @param elevations a vector of elevations to generate the elevation chart
* @param html true to output html, false to output plain text * @param html true to output html, false to output plain text
*/ */
public String generateTrackDescription( String generateTrackDescription(
Track track, Vector<Double> distances, Vector<Double> elevations, boolean html); Track track, Vector<Double> distances, Vector<Double> elevations, boolean html);
/** /**
* Generate a waypoint description from a trip statistics. * Generate a waypoint description from a trip statistics.
* *
* @param tripStatistics the trip statistics * @param tripStatistics the trip statistics
*/ */
public String generateWaypointDescription(TripStatistics tripStatistics); String generateWaypointDescription(TripStatistics tripStatistics);
} }
@@ -38,45 +38,45 @@ public interface MyTracksProviderUtils {
* The authority (the first part of the URI) for the My Tracks content * The authority (the first part of the URI) for the My Tracks content
* provider. * provider.
*/ */
public static final String AUTHORITY = "com.google.android.maps.mytracks"; String AUTHORITY = "com.google.android.maps.mytracks";
/** /**
* Clears a track. Removes waypoints and trackpoints. Only keeps the track id. * Clears a track. Removes waypoints and trackpoints. Only keeps the track id.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public void clearTrack(Context context, long trackId); void clearTrack(Context context, long trackId);
/** /**
* Creates a {@link Track} from a cursor. * Creates a {@link Track} from a cursor.
* *
* @param cursor the cursor pointing to the track * @param cursor the cursor pointing to the track
*/ */
public Track createTrack(Cursor cursor); Track createTrack(Cursor cursor);
/** /**
* Deletes all tracks (including waypoints and track points). * Deletes all tracks (including waypoints and track points).
*/ */
public void deleteAllTracks(Context context); void deleteAllTracks(Context context);
/** /**
* Deletes a track. * Deletes a track.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public void deleteTrack(Context context, long trackId); void deleteTrack(Context context, long trackId);
/** /**
* Gets all the tracks. If no track exists, an empty list is returned. * Gets all the tracks. If no track exists, an empty list is returned.
* <p> * <p>
* Note that the returned tracks do not have any track points attached. * Note that the returned tracks do not have any track points attached.
*/ */
public List<Track> getAllTracks(); List<Track> getAllTracks();
/** /**
* Gets the last track. Returns null if doesn't exist. * Gets the last track. Returns null if doesn't exist.
*/ */
public Track getLastTrack(); Track getLastTrack();
/** /**
* Gets a track by a track id. Returns null if not found. * Gets a track by a track id. Returns null if not found.
@@ -85,7 +85,7 @@ public interface MyTracksProviderUtils {
* *
* @param trackId the track id. * @param trackId the track id.
*/ */
public Track getTrack(long trackId); Track getTrack(long trackId);
/** /**
* Gets a track cursor. The caller owns the returned cursor and is responsible * Gets a track cursor. The caller owns the returned cursor and is responsible
@@ -95,7 +95,7 @@ public interface MyTracksProviderUtils {
* @param selectionArgs the selection arguments. Can be null * @param selectionArgs the selection arguments. Can be null
* @param sortOrder the sort order. Can be null * @param sortOrder the sort order. Can be null
*/ */
public Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder); Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder);
/** /**
* Inserts a track. * Inserts a track.
@@ -105,7 +105,7 @@ public interface MyTracksProviderUtils {
* @param track the track * @param track the track
* @return the content provider URI of the inserted track. * @return the content provider URI of the inserted track.
*/ */
public Uri insertTrack(Track track); Uri insertTrack(Track track);
/** /**
* Updates a track. * Updates a track.
@@ -114,14 +114,14 @@ public interface MyTracksProviderUtils {
* *
* @param track the track * @param track the track
*/ */
public void updateTrack(Track track); void updateTrack(Track track);
/** /**
* Creates a waypoint from a cursor. * Creates a waypoint from a cursor.
* *
* @param cursor the cursor pointing to the waypoint * @param cursor the cursor pointing to the waypoint
*/ */
public Waypoint createWaypoint(Cursor cursor); Waypoint createWaypoint(Cursor cursor);
/** /**
* Deletes a waypoint. If deleting a statistics waypoint, this will also * Deletes a waypoint. If deleting a statistics waypoint, this will also
@@ -132,7 +132,7 @@ public interface MyTracksProviderUtils {
* @param descriptionGenerator the description generator. Can be null for * @param descriptionGenerator the description generator. Can be null for
* waypoint marker * waypoint marker
*/ */
public void deleteWaypoint(Context context, long waypointId, DescriptionGenerator descriptionGenerator); void deleteWaypoint(Context context, long waypointId, DescriptionGenerator descriptionGenerator);
/** /**
* Gets the first waypoint id for a track. The first waypoint is special as it * Gets the first waypoint id for a track. The first waypoint is special as it
@@ -140,7 +140,7 @@ public interface MyTracksProviderUtils {
* *
* @param trackId the track id * @param trackId the track id
*/ */
public long getFirstWaypointId(long trackId); long getFirstWaypointId(long trackId);
/** /**
* Gets the last waypoint for a type. Returns null if it doesn't exist. * Gets the last waypoint for a type. Returns null if it doesn't exist.
@@ -148,7 +148,7 @@ public interface MyTracksProviderUtils {
* @param trackId the track id * @param trackId the track id
* @param waypointType the waypoint type * @param waypointType the waypoint type
*/ */
public Waypoint getLastWaypoint(long trackId, WaypointType waypointType); Waypoint getLastWaypoint(long trackId, WaypointType waypointType);
/** /**
* Gets the next waypoint number for a type. Returns -1 if not able to get the * Gets the next waypoint number for a type. Returns -1 if not able to get the
@@ -157,14 +157,14 @@ public interface MyTracksProviderUtils {
* @param trackId the track id * @param trackId the track id
* @param waypointType the waypoint type * @param waypointType the waypoint type
*/ */
public int getNextWaypointNumber(long trackId, WaypointType waypointType); int getNextWaypointNumber(long trackId, WaypointType waypointType);
/** /**
* Gets a waypoint from a waypoint id. Returns null if not found. * Gets a waypoint from a waypoint id. Returns null if not found.
* *
* @param waypointId the waypoint id * @param waypointId the waypoint id
*/ */
public Waypoint getWaypoint(long waypointId); Waypoint getWaypoint(long waypointId);
/** /**
* Gets a waypoint cursor. The caller owns the returned cursor and is * Gets a waypoint cursor. The caller owns the returned cursor and is
@@ -176,8 +176,8 @@ public interface MyTracksProviderUtils {
* @param maxWaypoints the maximum number of waypoints to return. -1 for no * @param maxWaypoints the maximum number of waypoints to return. -1 for no
* limit * limit
*/ */
public Cursor getWaypointCursor( Cursor getWaypointCursor(
String selection, String[] selectionArgs, String sortOrder, int maxWaypoints); String selection, String[] selectionArgs, String sortOrder, int maxWaypoints);
/** /**
* Gets a waypoint cursor for a track. The caller owns the returned cursor and * Gets a waypoint cursor for a track. The caller owns the returned cursor and
@@ -188,14 +188,14 @@ public interface MyTracksProviderUtils {
* @param maxWaypoints the maximum number of waypoints to return. -1 for no * @param maxWaypoints the maximum number of waypoints to return. -1 for no
* limit * limit
*/ */
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints); Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
/** /**
* Gets the number of waypoints for a track. * Gets the number of waypoints for a track.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public int getWaypointCount(long trackId); int getWaypointCount(long trackId);
/** /**
* Inserts a waypoint. * Inserts a waypoint.
@@ -203,14 +203,14 @@ public interface MyTracksProviderUtils {
* @param waypoint the waypoint * @param waypoint the waypoint
* @return the content provider URI of the inserted waypoint. * @return the content provider URI of the inserted waypoint.
*/ */
public Uri insertWaypoint(Waypoint waypoint); Uri insertWaypoint(Waypoint waypoint);
/** /**
* Updates a waypoint. Returns true if successful. * Updates a waypoint. Returns true if successful.
* *
* @param waypoint the waypoint * @param waypoint the waypoint
*/ */
public boolean updateWaypoint(Waypoint waypoint); boolean updateWaypoint(Waypoint waypoint);
/** /**
* Inserts multiple track points. * Inserts multiple track points.
@@ -221,28 +221,28 @@ public interface MyTracksProviderUtils {
* @param trackId the track id * @param trackId the track id
* @return the number of points inserted * @return the number of points inserted
*/ */
public int bulkInsertTrackPoint(Location[] locations, int length, long trackId); int bulkInsertTrackPoint(Location[] locations, int length, long trackId);
/** /**
* Creates a location object from a cursor. * Creates a location object from a cursor.
* *
* @param cursor the cursor pointing to the location * @param cursor the cursor pointing to the location
*/ */
public Location createTrackPoint(Cursor cursor); Location createTrackPoint(Cursor cursor);
/** /**
* Gets the first location id for a track. Returns -1L if it doesn't exist. * Gets the first location id for a track. Returns -1L if it doesn't exist.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public long getFirstTrackPointId(long trackId); long getFirstTrackPointId(long trackId);
/** /**
* Gets the last location id for a track. Returns -1L if it doesn't exist. * Gets the last location id for a track. Returns -1L if it doesn't exist.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public long getLastTrackPointId(long trackId); long getLastTrackPointId(long trackId);
/** /**
* Gets the track point id of a location. * Gets the track point id of a location.
@@ -251,7 +251,7 @@ public interface MyTracksProviderUtils {
* @param location the location * @param location the location
* @return track point id if the location is in the track. -1L otherwise. * @return track point id if the location is in the track. -1L otherwise.
*/ */
public long getTrackPointId(long trackId, Location location); long getTrackPointId(long trackId, Location location);
/** /**
* Gets the first valid location for a track. Returns null if it doesn't * Gets the first valid location for a track. Returns null if it doesn't
@@ -259,20 +259,20 @@ public interface MyTracksProviderUtils {
* *
* @param trackId the track id * @param trackId the track id
*/ */
public Location getFirstValidTrackPoint(long trackId); Location getFirstValidTrackPoint(long trackId);
/** /**
* Gets the last valid location for a track. Returns null if it doesn't exist. * Gets the last valid location for a track. Returns null if it doesn't exist.
* *
* @param trackId the track id * @param trackId the track id
*/ */
public Location getLastValidTrackPoint(long trackId); Location getLastValidTrackPoint(long trackId);
/** /**
* Gets the last valid location. * Gets the last valid location.
*/ */
public Location getLastValidTrackPoint(); Location getLastValidTrackPoint();
/** /**
* Creates a location cursor. The caller owns the returned cursor and is * Creates a location cursor. The caller owns the returned cursor and is
@@ -284,8 +284,8 @@ public interface MyTracksProviderUtils {
* @param descending true to sort the result in descending order (latest * @param descending true to sort the result in descending order (latest
* location first) * location first)
*/ */
public Cursor getTrackPointCursor( Cursor getTrackPointCursor(
long trackId, long startTrackPointId, int maxLocations, boolean descending); long trackId, long startTrackPointId, int maxLocations, boolean descending);
/** /**
* Creates a new read-only iterator over a given track's points. It provides a * Creates a new read-only iterator over a given track's points. It provides a
@@ -304,8 +304,8 @@ public interface MyTracksProviderUtils {
* location first) * location first)
* @param locationFactory the location factory * @param locationFactory the location factory
*/ */
public LocationIterator getTrackPointLocationIterator( LocationIterator getTrackPointLocationIterator(
long trackId, long startTrackPointId, boolean descending, LocationFactory locationFactory); long trackId, long startTrackPointId, boolean descending, LocationFactory locationFactory);
/** /**
* Inserts a track point. * Inserts a track point.
@@ -314,41 +314,41 @@ public interface MyTracksProviderUtils {
* @param trackId the track id * @param trackId the track id
* @return the content provider URI of the inserted track point * @return the content provider URI of the inserted track point
*/ */
public Uri insertTrackPoint(Location location, long trackId); Uri insertTrackPoint(Location location, long trackId);
/** /**
* A lightweight wrapper around the original {@link Cursor} with a method to * A lightweight wrapper around the original {@link Cursor} with a method to
* clean up. * clean up.
*/ */
public interface LocationIterator extends Iterator<Location> { interface LocationIterator extends Iterator<Location> {
/** /**
* Gets the most recently retrieved track point id by {@link #next()}. * Gets the most recently retrieved track point id by {@link #next()}.
*/ */
public long getLocationId(); long getLocationId();
/** /**
* Closes the iterator. * Closes the iterator.
*/ */
public void close(); void close();
} }
/** /**
* A factory for creating new {@link Location}. * A factory for creating new {@link Location}.
*/ */
public interface LocationFactory { interface LocationFactory {
/** /**
* Creates a new {@link Location}. An implementation can create new * Creates a new {@link Location}. An implementation can create new
* instances or reuse existing instances for optimization. * instances or reuse existing instances for optimization.
*/ */
public Location createLocation(); Location createLocation();
} }
/** /**
* The default {@link LocationFactory} which creates a location each time. * The default {@link LocationFactory} which creates a location each time.
*/ */
public LocationFactory DEFAULT_LOCATION_FACTORY = new LocationFactory() { LocationFactory DEFAULT_LOCATION_FACTORY = new LocationFactory() {
@Override @Override
public Location createLocation() { public Location createLocation() {
return new MyTracksLocation(LocationManager.GPS_PROVIDER); return new MyTracksLocation(LocationManager.GPS_PROVIDER);
@@ -359,7 +359,7 @@ public interface MyTracksProviderUtils {
* A factory which can produce instances of {@link MyTracksProviderUtils}, and * A factory which can produce instances of {@link MyTracksProviderUtils}, and
* can be overridden for testing. * can be overridden for testing.
*/ */
public static class Factory { class Factory {
private static Factory instance = new Factory(); private static Factory instance = new Factory();
@@ -45,7 +45,7 @@ public final class Sensor {
private final int index; private final int index;
private final int value; private final int value;
private SensorState(int index, int value) { SensorState(int index, int value) {
this.index = index; this.index = index;
this.value = value; this.value = value;
} }
@@ -31,25 +31,25 @@ import android.provider.BaseColumns;
*/ */
public interface TrackPointsColumns extends BaseColumns { public interface TrackPointsColumns extends BaseColumns {
public static final String TABLE_NAME = "trackpoints"; String TABLE_NAME = "trackpoints";
public static final Uri CONTENT_URI = Uri.parse( Uri CONTENT_URI = Uri.parse(
"content://com.google.android.maps.mytracks/trackpoints"); "content://com.google.android.maps.mytracks/trackpoints");
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint"; String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint";
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint"; String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint";
public static final String DEFAULT_SORT_ORDER = "_id"; String DEFAULT_SORT_ORDER = "_id";
// Columns // Columns
public static final String TRACKID = "trackid"; // track id String TRACKID = "trackid"; // track id
public static final String LONGITUDE = "longitude"; // longitude String LONGITUDE = "longitude"; // longitude
public static final String LATITUDE = "latitude"; // latitude String LATITUDE = "latitude"; // latitude
public static final String TIME = "time"; // time String TIME = "time"; // time
public static final String ALTITUDE = "elevation"; // altitude String ALTITUDE = "elevation"; // altitude
public static final String ACCURACY = "accuracy"; // accuracy String ACCURACY = "accuracy"; // accuracy
public static final String SPEED = "speed"; // speed String SPEED = "speed"; // speed
public static final String BEARING = "bearing"; // bearing String BEARING = "bearing"; // bearing
public static final String SENSOR = "sensor"; // sensor String SENSOR = "sensor"; // sensor
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ TRACKID + " INTEGER, " + TRACKID + " INTEGER, "
+ LONGITUDE + " INTEGER, " + LONGITUDE + " INTEGER, "
@@ -62,7 +62,7 @@ public interface TrackPointsColumns extends BaseColumns {
+ SENSOR + " BLOB" + SENSOR + " BLOB"
+ ");"; + ");";
public static final String[] COLUMNS = { String[] COLUMNS = {
_ID, _ID,
TRACKID, TRACKID,
LONGITUDE, LONGITUDE,
@@ -75,7 +75,7 @@ public interface TrackPointsColumns extends BaseColumns {
SENSOR SENSOR
}; };
public static final byte[] COLUMN_TYPES = { byte[] COLUMN_TYPES = {
LONG_TYPE_ID, // id LONG_TYPE_ID, // id
LONG_TYPE_ID, // track id LONG_TYPE_ID, // track id
INT_TYPE_ID, // longitude INT_TYPE_ID, // longitude
@@ -26,73 +26,73 @@ import android.provider.BaseColumns;
*/ */
public interface TracksColumns extends BaseColumns { public interface TracksColumns extends BaseColumns {
public static final String TABLE_NAME = "tracks"; String TABLE_NAME = "tracks";
/** /**
* Tracks provider uri. * Tracks provider uri.
*/ */
public static final Uri CONTENT_URI = Uri.parse( Uri CONTENT_URI = Uri.parse(
"content://com.google.android.maps.mytracks/tracks"); "content://com.google.android.maps.mytracks/tracks");
/** /**
* Track content type. * Track content type.
*/ */
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.track"; String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.track";
/** /**
* Track id content type. * Track id content type.
*/ */
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.track"; String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.track";
/** /**
* Tracks table default sort order. * Tracks table default sort order.
*/ */
public static final String DEFAULT_SORT_ORDER = "_id"; String DEFAULT_SORT_ORDER = "_id";
// Columns // Columns
public static final String NAME = "name"; // track name String NAME = "name"; // track name
public static final String DESCRIPTION = "description"; // track description String DESCRIPTION = "description"; // track description
public static final String CATEGORY = "category"; // track activity type String CATEGORY = "category"; // track activity type
public static final String STARTID = "startid"; // first track point id String STARTID = "startid"; // first track point id
public static final String STOPID = "stopid"; // last track point id String STOPID = "stopid"; // last track point id
public static final String STARTTIME = "starttime"; // track start time String STARTTIME = "starttime"; // track start time
public static final String STOPTIME = "stoptime"; // track stop time String STOPTIME = "stoptime"; // track stop time
public static final String NUMPOINTS = "numpoints"; // number of track points String NUMPOINTS = "numpoints"; // number of track points
public static final String TOTALDISTANCE = "totaldistance"; // total distance String TOTALDISTANCE = "totaldistance"; // total distance
public static final String TOTALTIME = "totaltime"; // total time String TOTALTIME = "totaltime"; // total time
public static final String MOVINGTIME = "movingtime"; // moving time String MOVINGTIME = "movingtime"; // moving time
public static final String MINLAT = "minlat"; // minimum latitude String MINLAT = "minlat"; // minimum latitude
public static final String MAXLAT = "maxlat"; // maximum latitude String MAXLAT = "maxlat"; // maximum latitude
public static final String MINLON = "minlon"; // minimum longitude String MINLON = "minlon"; // minimum longitude
public static final String MAXLON = "maxlon"; // maximum longitude String MAXLON = "maxlon"; // maximum longitude
public static final String AVGSPEED = "avgspeed"; // average speed String AVGSPEED = "avgspeed"; // average speed
// average moving speed // average moving speed
public static final String AVGMOVINGSPEED = "avgmovingspeed"; String AVGMOVINGSPEED = "avgmovingspeed";
public static final String MAXSPEED = "maxspeed"; // maximum speed String MAXSPEED = "maxspeed"; // maximum speed
public static final String MINELEVATION = "minelevation"; // minimum elevation String MINELEVATION = "minelevation"; // minimum elevation
public static final String MAXELEVATION = "maxelevation"; // maximum elevation String MAXELEVATION = "maxelevation"; // maximum elevation
public static final String ELEVATIONGAIN = "elevationgain"; // elevation gain String ELEVATIONGAIN = "elevationgain"; // elevation gain
public static final String MINGRADE = "mingrade"; // minimum grade String MINGRADE = "mingrade"; // minimum grade
public static final String MAXGRADE = "maxgrade"; // maximum grade String MAXGRADE = "maxgrade"; // maximum grade
public static final String MAPID = "mapid"; // Google Maps id String MAPID = "mapid"; // Google Maps id
public static final String TABLEID = "tableid"; // Google Fusion Tables id String TABLEID = "tableid"; // Google Fusion Tables id
public static final String ICON = "icon"; // track activity type icon String ICON = "icon"; // track activity type icon
public static final String DRIVEID = "driveid"; // Google Drive file id String DRIVEID = "driveid"; // Google Drive file id
// Google drive file modified time // Google drive file modified time
public static final String MODIFIEDTIME = "modifiedtime"; String MODIFIEDTIME = "modifiedtime";
// 1 if the Google Drive file is from the "Shared with me" directory // 1 if the Google Drive file is from the "Shared with me" directory
public static final String SHAREDWITHME = "sharedwithme"; String SHAREDWITHME = "sharedwithme";
// The owner of the shared with me track // The owner of the shared with me track
public static final String SHAREDOWNER = "sharedOwner"; String SHAREDOWNER = "sharedOwner";
// Calorie burned of the track // Calorie burned of the track
public static final String CALORIE = "calorie"; String CALORIE = "calorie";
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id
+ NAME + " STRING, " // name + NAME + " STRING, " // name
+ DESCRIPTION + " STRING, " // description + DESCRIPTION + " STRING, " // description
@@ -126,7 +126,7 @@ public interface TracksColumns extends BaseColumns {
+ SHAREDOWNER + " STRING, " // shared owner + SHAREDOWNER + " STRING, " // shared owner
+ CALORIE + " FLOAT);"; // calorie + CALORIE + " FLOAT);"; // calorie
public static final String[] COLUMNS = { _ID, // id String[] COLUMNS = { _ID, // id
NAME, // name NAME, // name
DESCRIPTION, // description DESCRIPTION, // description
CATEGORY, // category CATEGORY, // category
@@ -159,7 +159,7 @@ public interface TracksColumns extends BaseColumns {
SHAREDOWNER,// shared owner SHAREDOWNER,// shared owner
CALORIE }; // calorie CALORIE }; // calorie
public static final byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id
ContentTypeIds.STRING_TYPE_ID, // name ContentTypeIds.STRING_TYPE_ID, // name
ContentTypeIds.STRING_TYPE_ID, // description ContentTypeIds.STRING_TYPE_ID, // description
ContentTypeIds.STRING_TYPE_ID, // category ContentTypeIds.STRING_TYPE_ID, // category
@@ -30,8 +30,8 @@ import android.os.Parcelable;
*/ */
public final class Waypoint implements Parcelable { public final class Waypoint implements Parcelable {
public static enum WaypointType { public enum WaypointType {
WAYPOINT, STATISTICS; WAYPOINT, STATISTICS
} }
private long id = -1L; private long id = -1L;
@@ -62,7 +62,7 @@ public class WaypointCreationRequest implements Parcelable {
@Override @Override
public WaypointCreationRequest createFromParcel(Parcel source) { public WaypointCreationRequest createFromParcel(Parcel source) {
WaypointCreationRequest request = new WaypointCreationRequest( return new WaypointCreationRequest(
WaypointType.values()[source.readInt()], WaypointType.values()[source.readInt()],
source.readByte() == 1, source.readByte() == 1,
source.readString(), source.readString(),
@@ -70,7 +70,6 @@ public class WaypointCreationRequest implements Parcelable {
source.readString(), source.readString(),
source.readString(), source.readString(),
source.readString()); source.readString());
return request;
} }
public WaypointCreationRequest[] newArray(int size) { public WaypointCreationRequest[] newArray(int size) {
@@ -31,50 +31,50 @@ import android.provider.BaseColumns;
*/ */
public interface WaypointsColumns extends BaseColumns { public interface WaypointsColumns extends BaseColumns {
public static final String TABLE_NAME = "waypoints"; String TABLE_NAME = "waypoints";
public static final Uri CONTENT_URI = Uri.parse( Uri CONTENT_URI = Uri.parse(
"content://com.google.android.maps.mytracks/waypoints"); "content://com.google.android.maps.mytracks/waypoints");
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.waypoint"; String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.waypoint";
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.waypoint"; String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.waypoint";
public static final String DEFAULT_SORT_ORDER = "_id"; String DEFAULT_SORT_ORDER = "_id";
// Columns // Columns
public static final String NAME = "name"; // waypoint name String NAME = "name"; // waypoint name
public static final String DESCRIPTION = "description"; // waypoint description String DESCRIPTION = "description"; // waypoint description
public static final String CATEGORY = "category"; // waypoint category String CATEGORY = "category"; // waypoint category
public static final String ICON = "icon"; // waypoint icon String ICON = "icon"; // waypoint icon
public static final String TRACKID = "trackid"; // track id String TRACKID = "trackid"; // track id
public static final String TYPE = "type"; // type String TYPE = "type"; // type
public static final String LENGTH = "length"; // length of the track (without smoothing) String LENGTH = "length"; // length of the track (without smoothing)
public static final String DURATION = "duration"; // total duration of the track (not from last waypoint) String DURATION = "duration"; // total duration of the track (not from last waypoint)
public static final String STARTTIME = "starttime"; // start time of the trip statistics String STARTTIME = "starttime"; // start time of the trip statistics
public static final String STARTID = "startid"; // start track point id String STARTID = "startid"; // start track point id
public static final String STOPID = "stopid"; // stop track point id String STOPID = "stopid"; // stop track point id
public static final String LONGITUDE = "longitude"; // longitude String LONGITUDE = "longitude"; // longitude
public static final String LATITUDE = "latitude"; // latitude String LATITUDE = "latitude"; // latitude
public static final String TIME = "time"; // time String TIME = "time"; // time
public static final String ALTITUDE = "elevation"; // altitude String ALTITUDE = "elevation"; // altitude
public static final String ACCURACY = "accuracy"; // accuracy String ACCURACY = "accuracy"; // accuracy
public static final String SPEED = "speed"; // speed String SPEED = "speed"; // speed
public static final String BEARING = "bearing"; // bearing String BEARING = "bearing"; // bearing
public static final String TOTALDISTANCE = "totaldistance"; // total distance String TOTALDISTANCE = "totaldistance"; // total distance
public static final String TOTALTIME = "totaltime"; // total time String TOTALTIME = "totaltime"; // total time
public static final String MOVINGTIME = "movingtime"; // moving time String MOVINGTIME = "movingtime"; // moving time
public static final String AVGSPEED = "avgspeed"; // average speed String AVGSPEED = "avgspeed"; // average speed
public static final String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed
public static final String MAXSPEED = "maxspeed"; // max speed String MAXSPEED = "maxspeed"; // max speed
public static final String MINELEVATION = "minelevation"; // min elevation String MINELEVATION = "minelevation"; // min elevation
public static final String MAXELEVATION = "maxelevation"; // max elevation String MAXELEVATION = "maxelevation"; // max elevation
public static final String ELEVATIONGAIN = "elevationgain"; // elevation gain String ELEVATIONGAIN = "elevationgain"; // elevation gain
public static final String MINGRADE = "mingrade"; // min grade String MINGRADE = "mingrade"; // min grade
public static final String MAXGRADE = "maxgrade"; // max grade String MAXGRADE = "maxgrade"; // max grade
public static final String CALORIE = "calorie"; // calorie String CALORIE = "calorie"; // calorie
public static final String PHOTOURL = "photoUrl"; // url for the photo String PHOTOURL = "photoUrl"; // url for the photo
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME + " STRING, " + NAME + " STRING, "
+ DESCRIPTION + " STRING, " + DESCRIPTION + " STRING, "
@@ -109,7 +109,7 @@ public interface WaypointsColumns extends BaseColumns {
+ PHOTOURL + " STRING" + PHOTOURL + " STRING"
+ ");"; + ");";
public static final String[] COLUMNS = { String[] COLUMNS = {
_ID, _ID,
NAME, NAME,
DESCRIPTION, DESCRIPTION,
@@ -144,7 +144,7 @@ public interface WaypointsColumns extends BaseColumns {
PHOTOURL PHOTOURL
}; };
public static final byte[] COLUMN_TYPES = { byte[] COLUMN_TYPES = {
LONG_TYPE_ID, // id LONG_TYPE_ID, // id
STRING_TYPE_ID, // name STRING_TYPE_ID, // name
STRING_TYPE_ID, // description STRING_TYPE_ID, // description
@@ -106,7 +106,7 @@ public class FileUtils {
} }
public static File getPhotoDir(long trackId) { public static File getPhotoDir(long trackId) {
return new File(getPath(PICTURES_DIR, "MyTracks" + Long.toString(trackId))); return new File(getPath(PICTURES_DIR, "MyTracks" + trackId));
} }
/** /**
@@ -197,7 +197,7 @@ public class FileUtils {
File directory, String base, String extension, int suffix) { File directory, String base, String extension, int suffix) {
String suffixName = ""; String suffixName = "";
if (suffix > 0) { if (suffix > 0) {
suffixName += "(" + Integer.toString(suffix) + ")"; suffixName += "(" + suffix + ")";
} }
suffixName += "." + extension; suffixName += "." + extension;