mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Merge heads
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
#Tue Jul 17 10:23:26 PDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
@@ -17,7 +8,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
@@ -74,7 +64,6 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=1585
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent=1585|-1|1585
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.stats.ExtremityMonitor;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
@@ -565,7 +566,7 @@ public class ChartView extends View {
|
||||
x, topBorder + spacer + markerHeight / 2, x, topBorder + effectiveHeight, markerPaint);
|
||||
canvas.translate(
|
||||
x - (float) (markerWidth * MapOverlay.WAYPOINT_X_ANCHOR), topBorder + spacer);
|
||||
if (waypoints.get(i).getType() == Waypoint.TYPE_STATISTICS) {
|
||||
if (waypoints.get(i).getType() == WaypointType.STATISTICS) {
|
||||
statisticsMarker.draw(canvas);
|
||||
} else {
|
||||
waypointMarker.draw(canvas);
|
||||
|
||||
@@ -174,7 +174,7 @@ public class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
try {
|
||||
int minRecordingDistance = PreferencesUtils.getInt(importActivity,
|
||||
R.string.min_recording_distance_key, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
long trackIds[] = GpxImporter.importGPXFile(
|
||||
long trackIds[] = GpxImporter.importGPXFile(importActivity,
|
||||
new FileInputStream(file), myTracksProviderUtils, minRecordingDistance);
|
||||
int length = trackIds.length;
|
||||
if (length > 0) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.google.android.apps.mytracks;
|
||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.maps.TrackPath;
|
||||
import com.google.android.apps.mytracks.maps.TrackPathFactory;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
@@ -274,7 +275,7 @@ public class MapOverlay {
|
||||
for (Waypoint waypoint : waypoints) {
|
||||
Location location = waypoint.getLocation();
|
||||
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
int drawableId = waypoint.getType() == Waypoint.TYPE_STATISTICS ? R.drawable.yellow_pushpin
|
||||
int drawableId = waypoint.getType() == WaypointType.STATISTICS ? R.drawable.yellow_pushpin
|
||||
: R.drawable.blue_pushpin;
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(latLng)
|
||||
.anchor(WAYPOINT_X_ANCHOR, WAYPOINT_Y_ANCHOR).draggable(false).visible(true)
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||
@@ -78,7 +79,7 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
|
||||
return;
|
||||
}
|
||||
name.setText(getString(R.string.generic_name_line, waypoint.getName()));
|
||||
if (waypoint.getType() == Waypoint.TYPE_WAYPOINT) {
|
||||
if (waypoint.getType() == WaypointType.WAYPOINT) {
|
||||
waypointSection.setVisibility(View.VISIBLE);
|
||||
statisticsSection.setVisibility(View.GONE);
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest.WaypointType;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -131,7 +131,7 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
|
||||
statisticsSection.setVisibility(View.GONE);
|
||||
waypointSection.setVisibility(View.VISIBLE);
|
||||
int nextWaypointNumber = trackId == -1L ? -1
|
||||
: MyTracksProviderUtils.Factory.get(this).getNextWaypointNumber(trackId, false);
|
||||
: MyTracksProviderUtils.Factory.get(this).getNextWaypointNumber(trackId, WaypointType.WAYPOINT);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
|
||||
boolean statistics = waypoint.getType() == WaypointType.STATISTICS;
|
||||
statisticsSection.setVisibility(statistics ? View.VISIBLE : View.GONE);
|
||||
waypointSection.setVisibility(statistics ? View.GONE : View.VISIBLE);
|
||||
if (statistics) {
|
||||
@@ -178,7 +178,7 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
|
||||
* Saves a marker.
|
||||
*/
|
||||
private void saveMarker() {
|
||||
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
|
||||
boolean statistics = waypoint.getType() == WaypointType.STATISTICS;
|
||||
if (statistics) {
|
||||
waypoint.setName(statisticsName.getText().toString());
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointsColumns;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
@@ -149,7 +149,8 @@ public class MarkerListActivity extends AbstractMyTracksActivity {
|
||||
int timeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
|
||||
int descriptionIndex = cursor.getColumnIndex(WaypointsColumns.DESCRIPTION);
|
||||
|
||||
boolean statistics = cursor.getInt(typeIndex) == Waypoint.TYPE_STATISTICS;
|
||||
boolean statistics = WaypointType.values()[cursor.getInt(typeIndex)]
|
||||
== WaypointType.STATISTICS;
|
||||
int iconId = statistics ? R.drawable.yellow_pushpin : R.drawable.blue_pushpin;
|
||||
String category = statistics ? null : cursor.getString(categoryIndex);
|
||||
String description = statistics ? null : cursor.getString(descriptionIndex);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.android.apps.mytracks.content.SearchEngine.SearchQuery;
|
||||
import com.google.android.apps.mytracks.content.SearchEngineProvider;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
||||
@@ -432,7 +433,7 @@ public class SearchListActivity extends AbstractMyTracksActivity implements Dele
|
||||
}
|
||||
}
|
||||
|
||||
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
|
||||
boolean statistics = waypoint.getType() == WaypointType.STATISTICS;
|
||||
long time = waypoint.getLocation().getTime();
|
||||
|
||||
resultMap.put(IS_RECORDING_FIELD, false);
|
||||
|
||||
@@ -13,16 +13,25 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.io.file;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingService;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
@@ -52,25 +61,67 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
*/
|
||||
public class GpxImporter extends DefaultHandler {
|
||||
|
||||
// GPX tag names and attributes
|
||||
/**
|
||||
* Data for the current track.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
private class TrackData {
|
||||
|
||||
// The current track
|
||||
Track track = new Track();
|
||||
|
||||
// The parsed depth for the current track
|
||||
int parsedDepth = 0;
|
||||
|
||||
// The number of segments processed for the current track
|
||||
int numberOfSegments = 0;
|
||||
|
||||
/*
|
||||
* The last location in the current segment. Null if the current segment
|
||||
* doesn't have a last location.
|
||||
*/
|
||||
Location lastLocationInCurrentSegment;
|
||||
|
||||
// The number of locations processed for the current track
|
||||
int numberOfLocations = 0;
|
||||
|
||||
// The trip statistics updater for the current track
|
||||
TripStatisticsUpdater tripStatisticsUpdater;
|
||||
|
||||
// The default location time for the current track. -1L to not use it.
|
||||
long defaultLocationTime = -1L;
|
||||
|
||||
// The buffered locations
|
||||
Location[] bufferedLocations = new Location[MAX_BUFFERED_LOCATIONS];
|
||||
|
||||
// The number of buffered locations
|
||||
int numBufferedLocations = 0;
|
||||
}
|
||||
|
||||
// GPX tags
|
||||
private static final String TAG_ALTITUDE = "ele";
|
||||
private static final String TAG_DESCRIPTION = "desc";
|
||||
private static final String TAG_COMMENT = "cmt";
|
||||
private static final String TAG_GPX = "gpx";
|
||||
private static final String TAG_NAME = "name";
|
||||
private static final String TAG_TIME = "time";
|
||||
private static final String TAG_TRACK = "trk";
|
||||
private static final String TAG_TRACK_POINT = "trkpt";
|
||||
private static final Object TAG_TRACK_SEGMENT = "trkseg";
|
||||
private static final String TAG_TRACK_SEGMENT = "trkseg";
|
||||
private static final String TAG_TYPE = "type";
|
||||
private static final String TAG_WAYPOINT = "wpt";
|
||||
|
||||
// GPX attributes
|
||||
private static final String ATT_LAT = "lat";
|
||||
private static final String ATT_LON = "lon";
|
||||
|
||||
// The maximum number of buffered locations for bulk-insertion
|
||||
private static final int MAX_BUFFERED_LOCATIONS = 512;
|
||||
|
||||
private final Context context;
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final int minRecordingDistance;
|
||||
|
||||
// List of successfully imported track ids
|
||||
private final List<Long> tracksIds;
|
||||
|
||||
// The SAX locator to get the current line information
|
||||
@@ -79,60 +130,37 @@ public class GpxImporter extends DefaultHandler {
|
||||
// The current element content
|
||||
private String content;
|
||||
|
||||
// True if if we're inside a track's xml element
|
||||
private boolean isInTrackElement = false;
|
||||
// The current track data
|
||||
private TrackData trackData = null;
|
||||
|
||||
// The current child depth for the current track
|
||||
private int trackChildDepth = 0;
|
||||
// The current waypoint
|
||||
private Waypoint currentWaypoint;
|
||||
|
||||
// The current track
|
||||
private Track track;
|
||||
// The list of waypoints
|
||||
private List<Waypoint> waypoints = new ArrayList<Waypoint>();
|
||||
|
||||
// True if the current track parsing is finished
|
||||
private boolean isCurrentTrackFinished = true;
|
||||
|
||||
// The number of track segments processed for the current track
|
||||
private int numberOfTrackSegments = 0;
|
||||
|
||||
// The number of locations processed for the current track
|
||||
private int numberOfLocations = 0;
|
||||
|
||||
// The trip statistics updater for the current track
|
||||
private TripStatisticsUpdater tripStatisticsUpdater;
|
||||
|
||||
// True if the current track has a start time
|
||||
private boolean hasStartTime;
|
||||
|
||||
// The import time
|
||||
private long importTime;
|
||||
|
||||
// The current location
|
||||
/*
|
||||
* The current location, used for both track point location and waypoint
|
||||
* location.
|
||||
*/
|
||||
private Location location;
|
||||
|
||||
// The last location in the current segment
|
||||
private Location lastLocationInSegment;
|
||||
|
||||
// The buffered locations
|
||||
private Location[] bufferedLocations = new Location[MAX_BUFFERED_LOCATIONS];
|
||||
|
||||
// The number of buffered locations
|
||||
private int numBufferedLocations = 0;
|
||||
|
||||
/**
|
||||
* Reads GPS tracks from a GPX file and writes tracks and their coordinates to
|
||||
* the database.
|
||||
* Reads GPS tracks from a GPX file and writes tracks, waypoints, and track
|
||||
* points to the database.
|
||||
*
|
||||
* @param context the context
|
||||
* @param inputStream the input stream for the GPX file
|
||||
* @param myTracksProviderUtils my tracks provider utils
|
||||
* @param minRecordingDistance the min recording distance
|
||||
* @return long[] array of track ids written to the database.
|
||||
*/
|
||||
public static long[] importGPXFile(InputStream inputStream,
|
||||
public static long[] importGPXFile(Context context, InputStream inputStream,
|
||||
MyTracksProviderUtils myTracksProviderUtils, int minRecordingDistance)
|
||||
throws ParserConfigurationException, SAXException, IOException {
|
||||
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
|
||||
SAXParser saxParser = saxParserFactory.newSAXParser();
|
||||
GpxImporter gpxImporter = new GpxImporter(myTracksProviderUtils, minRecordingDistance);
|
||||
GpxImporter gpxImporter = new GpxImporter(context, myTracksProviderUtils, minRecordingDistance);
|
||||
long[] trackIds = new long[0];
|
||||
|
||||
try {
|
||||
@@ -154,10 +182,12 @@ public class GpxImporter extends DefaultHandler {
|
||||
return trackIds;
|
||||
}
|
||||
|
||||
public GpxImporter(MyTracksProviderUtils myTracksProviderUtils, int minRecordingDistance) {
|
||||
public GpxImporter(
|
||||
Context context, MyTracksProviderUtils myTracksProviderUtils, int minRecordingDistance) {
|
||||
this.context = context;
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
this.minRecordingDistance = minRecordingDistance;
|
||||
tracksIds = new ArrayList<Long>();
|
||||
this.tracksIds = new ArrayList<Long>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,55 +208,58 @@ public class GpxImporter extends DefaultHandler {
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String name, Attributes attributes)
|
||||
throws SAXException {
|
||||
if (isInTrackElement) {
|
||||
trackChildDepth++;
|
||||
if (trackData != null) {
|
||||
trackData.parsedDepth++;
|
||||
if (localName.equals(TAG_TRACK)) {
|
||||
throw new SAXException(createErrorMessage("Invalid GPX. Already inside a track."));
|
||||
} else if (localName.equals(TAG_TRACK_SEGMENT)) {
|
||||
onTrackSegmentElementStart();
|
||||
} else if (localName.equals(TAG_TRACK_POINT)) {
|
||||
onTrackPointElementStart(attributes);
|
||||
}
|
||||
} else if (localName.equals(TAG_TRACK)) {
|
||||
isInTrackElement = true;
|
||||
trackChildDepth = 0;
|
||||
onTrackElementStart();
|
||||
}
|
||||
} else {
|
||||
if (localName.equals(TAG_TRACK)) {
|
||||
onTrackElementStart();
|
||||
} else if (localName.equals(TAG_WAYPOINT)) {
|
||||
onWaypointElementStart(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String name) throws SAXException {
|
||||
if (!isInTrackElement) {
|
||||
content = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (localName.equals(TAG_TRACK)) {
|
||||
onTrackElementEnd();
|
||||
isInTrackElement = false;
|
||||
trackChildDepth = 0;
|
||||
} else if (localName.equals(TAG_NAME)) {
|
||||
// we are only interested in the first level name element
|
||||
if (trackChildDepth == 1) {
|
||||
onNameElementEnd();
|
||||
}
|
||||
if (localName.equals(TAG_NAME)) {
|
||||
onNameElementEnd();
|
||||
} else if (localName.equals(TAG_DESCRIPTION)) {
|
||||
// we are only interested in the first level description element
|
||||
if (trackChildDepth == 1) {
|
||||
onDescriptionElementEnd();
|
||||
}
|
||||
} else if (localName.equals(TAG_TRACK_SEGMENT)) {
|
||||
onTrackSegmentElementEnd();
|
||||
} else if (localName.equals(TAG_TRACK_POINT)) {
|
||||
onTrackPointElementEnd();
|
||||
onDescriptionElementEnd();
|
||||
} else if (localName.equals(TAG_TYPE)) {
|
||||
onTypeElementEnd();
|
||||
} else if (localName.equals(TAG_ALTITUDE)) {
|
||||
onAltitudeElementEnd();
|
||||
} else if (localName.equals(TAG_TIME)) {
|
||||
onTimeElementEnd();
|
||||
} else if (localName.equals(TAG_GPX)) {
|
||||
onGpxElementEnd();
|
||||
}
|
||||
trackChildDepth--;
|
||||
|
||||
// reset element content
|
||||
if (trackData != null) {
|
||||
trackData.parsedDepth--;
|
||||
if (localName.equals(TAG_TRACK)) {
|
||||
onTrackElementEnd();
|
||||
} else if (localName.equals(TAG_TRACK_SEGMENT)) {
|
||||
onTrackSegmentElementEnd();
|
||||
} else if (localName.equals(TAG_TRACK_POINT)) {
|
||||
onTrackPointElementEnd();
|
||||
}
|
||||
} else {
|
||||
if (localName.equals(TAG_WAYPOINT)) {
|
||||
onWaypointElementEnd();
|
||||
} else if (localName.equals(TAG_COMMENT)) {
|
||||
onCommentElementEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset element content
|
||||
content = null;
|
||||
}
|
||||
|
||||
@@ -239,9 +272,23 @@ public class GpxImporter extends DefaultHandler {
|
||||
* Rolls back last track if possible.
|
||||
*/
|
||||
public void rollbackUnfinishedTracks() {
|
||||
if (!isCurrentTrackFinished && track != null) {
|
||||
myTracksProviderUtils.deleteTrack(track.getId());
|
||||
isCurrentTrackFinished = true;
|
||||
if (trackData != null) {
|
||||
myTracksProviderUtils.deleteTrack(trackData.track.getId());
|
||||
trackData = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On gpx element end.
|
||||
*/
|
||||
private void onGpxElementEnd() {
|
||||
int size = tracksIds.size();
|
||||
if (size > 0) {
|
||||
long trackId = tracksIds.get(size - 1);
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
if (track != null) {
|
||||
addWaypoints(track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,64 +296,44 @@ public class GpxImporter extends DefaultHandler {
|
||||
* On track element start.
|
||||
*/
|
||||
private void onTrackElementStart() {
|
||||
track = new Track();
|
||||
Uri uri = myTracksProviderUtils.insertTrack(track);
|
||||
track.setId(Long.parseLong(uri.getLastPathSegment()));
|
||||
isCurrentTrackFinished = false;
|
||||
numberOfTrackSegments = 0;
|
||||
numberOfLocations = 0;
|
||||
tripStatisticsUpdater = null;
|
||||
trackData = new TrackData();
|
||||
Uri uri = myTracksProviderUtils.insertTrack(trackData.track);
|
||||
trackData.track.setId(Long.parseLong(uri.getLastPathSegment()));
|
||||
}
|
||||
|
||||
/**
|
||||
* On track element end.
|
||||
*/
|
||||
private void onTrackElementEnd() {
|
||||
flushPoints();
|
||||
if (tripStatisticsUpdater == null) {
|
||||
flushPoints(trackData);
|
||||
if (trackData.tripStatisticsUpdater == null) {
|
||||
long now = System.currentTimeMillis();
|
||||
tripStatisticsUpdater = new TripStatisticsUpdater(now);
|
||||
tripStatisticsUpdater.updateTime(now);
|
||||
}
|
||||
track.setStopId(getLastPointId());
|
||||
track.setTripStatistics(tripStatisticsUpdater.getTripStatistics());
|
||||
track.setNumberOfPoints(numberOfLocations);
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
tracksIds.add(track.getId());
|
||||
isCurrentTrackFinished = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* On name element end.
|
||||
*/
|
||||
private void onNameElementEnd() {
|
||||
if (content != null) {
|
||||
track.setName(content.toString().trim());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On description element end.
|
||||
*/
|
||||
private void onDescriptionElementEnd() {
|
||||
if (content != null) {
|
||||
track.setDescription(content.toString().trim());
|
||||
trackData.tripStatisticsUpdater = new TripStatisticsUpdater(now);
|
||||
trackData.tripStatisticsUpdater.updateTime(now);
|
||||
}
|
||||
trackData.track.setTripStatistics(trackData.tripStatisticsUpdater.getTripStatistics());
|
||||
trackData.track.setNumberOfPoints(trackData.numberOfLocations);
|
||||
myTracksProviderUtils.updateTrack(trackData.track);
|
||||
tracksIds.add(trackData.track.getId());
|
||||
insertFirstWaypoint(trackData.track);
|
||||
trackData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* On track segment start.
|
||||
*/
|
||||
private void onTrackSegmentElementStart() {
|
||||
numberOfTrackSegments++;
|
||||
// If not the first segment, add a pause separator if there is at least one
|
||||
// location in the last segment
|
||||
if (numberOfTrackSegments > 1 && lastLocationInSegment != null) {
|
||||
insertPoint(createNewLocation(
|
||||
TrackRecordingService.PAUSE_LATITUDE, 0.0, lastLocationInSegment.getTime()));
|
||||
trackData.numberOfSegments++;
|
||||
|
||||
/*
|
||||
* If not the first segment, add a pause separator if there is at least one
|
||||
* location in the last segment.
|
||||
*/
|
||||
if (trackData.numberOfSegments > 1 && trackData.lastLocationInCurrentSegment != null) {
|
||||
insertPoint(createNewLocation(TrackRecordingService.PAUSE_LATITUDE, 0.0,
|
||||
trackData.lastLocationInCurrentSegment.getTime()));
|
||||
}
|
||||
location = null;
|
||||
lastLocationInSegment = null;
|
||||
trackData.lastLocationInCurrentSegment = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,27 +349,7 @@ public class GpxImporter extends DefaultHandler {
|
||||
* @param attributes the attributes
|
||||
*/
|
||||
private void onTrackPointElementStart(Attributes attributes) throws SAXException {
|
||||
if (location != null) {
|
||||
throw new SAXException(createErrorMessage("Found a track point inside another one."));
|
||||
}
|
||||
String latitude = attributes.getValue(ATT_LAT);
|
||||
String longitude = attributes.getValue(ATT_LON);
|
||||
|
||||
if (latitude == null || longitude == null) {
|
||||
throw new SAXException(createErrorMessage("Point with no longitude or latitude."));
|
||||
}
|
||||
double latitudeValue;
|
||||
double longitudeValue;
|
||||
try {
|
||||
latitudeValue = Double.parseDouble(latitude);
|
||||
longitudeValue = Double.parseDouble(longitude);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new SAXException(
|
||||
createErrorMessage("Unable to parse latitude/longitude: " + latitude + "/" + longitude),
|
||||
e);
|
||||
}
|
||||
|
||||
location = createNewLocation(latitudeValue, longitudeValue, -1L);
|
||||
parseLocation(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,25 +360,95 @@ public class GpxImporter extends DefaultHandler {
|
||||
throw new SAXException(createErrorMessage("Invalid location detected: " + location));
|
||||
}
|
||||
|
||||
if (numberOfTrackSegments > 1 && lastLocationInSegment == null) {
|
||||
// If not the first segment, add a resume separator before adding the
|
||||
// first location.
|
||||
if (trackData.numberOfSegments > 1 && trackData.lastLocationInCurrentSegment == null) {
|
||||
/*
|
||||
* If not the first segment, add a resume separator before adding the
|
||||
* first location.
|
||||
*/
|
||||
insertPoint(
|
||||
createNewLocation(TrackRecordingService.RESUME_LATITUDE, 0.0, location.getTime()));
|
||||
}
|
||||
|
||||
// insert in db
|
||||
insertPoint(location);
|
||||
|
||||
// set the start id if necessary
|
||||
if (track.getStartId() == -1L) {
|
||||
track.setStartId(getFirstPointId());
|
||||
if (trackData.track.getStartId() == -1L) {
|
||||
// Flush the location to set the track start id and the track end id
|
||||
flushPoints(trackData);
|
||||
}
|
||||
|
||||
lastLocationInSegment = location;
|
||||
trackData.lastLocationInCurrentSegment = location;
|
||||
location = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* On waypoint element start.
|
||||
*
|
||||
* @param attributes the attributes
|
||||
*/
|
||||
private void onWaypointElementStart(Attributes attributes) throws SAXException {
|
||||
if (currentWaypoint != null) {
|
||||
throw new SAXException(createErrorMessage("Found waypoint inside another waypoint."));
|
||||
}
|
||||
parseLocation(attributes);
|
||||
currentWaypoint = new Waypoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* On waypoint element end.
|
||||
*/
|
||||
private void onWaypointElementEnd() throws SAXException {
|
||||
if (!LocationUtils.isValidLocation(location)) {
|
||||
throw new SAXException(createErrorMessage("Invalid location detected: " + location));
|
||||
}
|
||||
currentWaypoint.setLocation(location);
|
||||
waypoints.add(currentWaypoint);
|
||||
location = null;
|
||||
currentWaypoint = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* On name element end.
|
||||
*/
|
||||
private void onNameElementEnd() {
|
||||
if (content != null) {
|
||||
String name = content.toString().trim();
|
||||
if (trackData != null && trackData.parsedDepth == 1) {
|
||||
trackData.track.setName(name);
|
||||
} else if (currentWaypoint != null) {
|
||||
currentWaypoint.setName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On description element end.
|
||||
*/
|
||||
private void onDescriptionElementEnd() {
|
||||
if (content != null) {
|
||||
String description = content.toString().trim();
|
||||
if (trackData != null && trackData.parsedDepth == 1) {
|
||||
trackData.track.setDescription(description);
|
||||
} else if (currentWaypoint != null) {
|
||||
currentWaypoint.setDescription(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On type element end.
|
||||
*/
|
||||
private void onTypeElementEnd() {
|
||||
if (content != null) {
|
||||
String type = content.toString().trim();
|
||||
if (trackData != null && trackData.parsedDepth == 1) {
|
||||
trackData.track.setCategory(type);
|
||||
trackData.track.setIcon(TrackIconUtils.getIconValue(context, type));
|
||||
} else if (currentWaypoint != null) {
|
||||
currentWaypoint.setCategory(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On altitude element end.
|
||||
*/
|
||||
@@ -407,11 +484,12 @@ public class GpxImporter extends DefaultHandler {
|
||||
}
|
||||
location.setTime(time);
|
||||
|
||||
// Calculate derived attributes from previous point
|
||||
if (lastLocationInSegment != null && lastLocationInSegment.getTime() != 0) {
|
||||
long timeDifference = time - lastLocationInSegment.getTime();
|
||||
// Calculate derived attributes from the previous point
|
||||
if (trackData != null && trackData.lastLocationInCurrentSegment != null
|
||||
&& trackData.lastLocationInCurrentSegment.getTime() != 0) {
|
||||
long timeDifference = time - trackData.lastLocationInCurrentSegment.getTime();
|
||||
|
||||
// check for negative time change
|
||||
// Check for negative time change
|
||||
if (timeDifference <= 0) {
|
||||
Log.w(Constants.TAG, "Time difference not postive.");
|
||||
} else {
|
||||
@@ -422,29 +500,74 @@ public class GpxImporter extends DefaultHandler {
|
||||
* speed and bearing will likely be off, so the statistics for things
|
||||
* like max speed will also be off.
|
||||
*/
|
||||
float speed = lastLocationInSegment.distanceTo(location) * 1000.0f / timeDifference;
|
||||
float speed = trackData.lastLocationInCurrentSegment.distanceTo(location) * 1000.0f
|
||||
/ timeDifference;
|
||||
location.setSpeed(speed);
|
||||
}
|
||||
location.setBearing(lastLocationInSegment.bearingTo(location));
|
||||
location.setBearing(trackData.lastLocationInCurrentSegment.bearingTo(location));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On comment element end.
|
||||
*/
|
||||
private void onCommentElementEnd() {
|
||||
if (content != null) {
|
||||
String comment = content.toString().trim();
|
||||
if (currentWaypoint != null) {
|
||||
WaypointType waypointType = WaypointType.STATISTICS.name().equals(comment) ? WaypointType.STATISTICS
|
||||
: WaypointType.WAYPOINT;
|
||||
currentWaypoint.setType(waypointType);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a location.
|
||||
*
|
||||
* @param attributes the attributes
|
||||
*/
|
||||
private void parseLocation(Attributes attributes) throws SAXException {
|
||||
if (location != null) {
|
||||
throw new SAXException(createErrorMessage("Found a location inside another one."));
|
||||
}
|
||||
String latitude = attributes.getValue(ATT_LAT);
|
||||
String longitude = attributes.getValue(ATT_LON);
|
||||
|
||||
if (latitude == null || longitude == null) {
|
||||
throw new SAXException(createErrorMessage("Point with no longitude or latitude."));
|
||||
}
|
||||
double latitudeValue;
|
||||
double longitudeValue;
|
||||
try {
|
||||
latitudeValue = Double.parseDouble(latitude);
|
||||
longitudeValue = Double.parseDouble(longitude);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new SAXException(
|
||||
createErrorMessage("Unable to parse latitude/longitude: " + latitude + "/" + longitude),
|
||||
e);
|
||||
}
|
||||
location = createNewLocation(latitudeValue, longitudeValue, -1L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new location
|
||||
*
|
||||
* @param latitude location latitude
|
||||
* @param longitude location longitude
|
||||
* @param time location time
|
||||
*/
|
||||
private Location createNewLocation(double latitude, double longitude, long time) {
|
||||
Location loc = new Location(LocationManager.GPS_PROVIDER);
|
||||
loc.setLatitude(latitude);
|
||||
loc.setLongitude(longitude);
|
||||
loc.setAltitude(0.0f);
|
||||
loc.setTime(time);
|
||||
loc.removeAccuracy();
|
||||
loc.removeBearing();
|
||||
loc.removeSpeed();
|
||||
return loc;
|
||||
Location newLocation = new Location(LocationManager.GPS_PROVIDER);
|
||||
newLocation.setLatitude(latitude);
|
||||
newLocation.setLongitude(longitude);
|
||||
newLocation.setAltitude(0.0f);
|
||||
newLocation.setTime(time);
|
||||
newLocation.removeAccuracy();
|
||||
newLocation.removeBearing();
|
||||
newLocation.removeSpeed();
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,36 +576,43 @@ public class GpxImporter extends DefaultHandler {
|
||||
* @param newLocation the location
|
||||
*/
|
||||
private void insertPoint(Location newLocation) {
|
||||
if (tripStatisticsUpdater == null) {
|
||||
hasStartTime = newLocation.getTime() != -1L;
|
||||
importTime = System.currentTimeMillis();
|
||||
tripStatisticsUpdater = new TripStatisticsUpdater(
|
||||
hasStartTime ? newLocation.getTime() : importTime);
|
||||
if (trackData.tripStatisticsUpdater == null) {
|
||||
// Set the default location time if the newLocation does not have a time
|
||||
trackData.defaultLocationTime = newLocation.getTime() == -1L ? System.currentTimeMillis()
|
||||
: -1L;
|
||||
trackData.tripStatisticsUpdater = new TripStatisticsUpdater(
|
||||
newLocation.getTime() != -1L ? newLocation.getTime() : trackData.defaultLocationTime);
|
||||
}
|
||||
if (!hasStartTime) {
|
||||
newLocation.setTime(importTime);
|
||||
if (trackData.defaultLocationTime != -1L) {
|
||||
newLocation.setTime(trackData.defaultLocationTime);
|
||||
}
|
||||
tripStatisticsUpdater.addLocation(newLocation, minRecordingDistance);
|
||||
|
||||
bufferedLocations[numBufferedLocations] = newLocation;
|
||||
numBufferedLocations++;
|
||||
numberOfLocations++;
|
||||
trackData.tripStatisticsUpdater.addLocation(newLocation, minRecordingDistance);
|
||||
|
||||
if (numBufferedLocations >= MAX_BUFFERED_LOCATIONS) {
|
||||
flushPoints();
|
||||
trackData.bufferedLocations[trackData.numBufferedLocations] = newLocation;
|
||||
trackData.numBufferedLocations++;
|
||||
trackData.numberOfLocations++;
|
||||
|
||||
if (trackData.numBufferedLocations >= MAX_BUFFERED_LOCATIONS) {
|
||||
flushPoints(trackData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the points to the database.
|
||||
*
|
||||
* @param data the track data
|
||||
*/
|
||||
private void flushPoints() {
|
||||
if (numBufferedLocations <= 0) {
|
||||
private void flushPoints(TrackData data) {
|
||||
if (data.numBufferedLocations <= 0) {
|
||||
return;
|
||||
}
|
||||
myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
bufferedLocations, numBufferedLocations, track.getId());
|
||||
numBufferedLocations = 0;
|
||||
data.bufferedLocations, data.numBufferedLocations, data.track.getId());
|
||||
data.numBufferedLocations = 0;
|
||||
if (data.track.getStartId() == -1L) {
|
||||
data.track.setStartId(myTracksProviderUtils.getFirstTrackPointId(data.track.getId()));
|
||||
}
|
||||
data.track.setStopId(myTracksProviderUtils.getLastTrackPointId(data.track.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,22 +626,6 @@ public class GpxImporter extends DefaultHandler {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first point id inserted into the database.
|
||||
*/
|
||||
private long getFirstPointId() {
|
||||
flushPoints();
|
||||
return myTracksProviderUtils.getFirstTrackPointId(track.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last point id inserted into the database.
|
||||
*/
|
||||
private long getLastPointId() {
|
||||
flushPoints();
|
||||
return myTracksProviderUtils.getLastTrackPointId(track.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an error message.
|
||||
*
|
||||
@@ -521,4 +635,115 @@ public class GpxImporter extends DefaultHandler {
|
||||
return String.format(Locale.US, "Parsing error at line: %d column: %d. %s",
|
||||
locator.getLineNumber(), locator.getColumnNumber(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the first track waypoint, the track statistics waypoint.
|
||||
*
|
||||
* @param track the track
|
||||
*/
|
||||
private void insertFirstWaypoint(Track track) {
|
||||
String name = context.getString(R.string.marker_split_name_format, 0);
|
||||
String category = "";
|
||||
TripStatisticsUpdater updater = new TripStatisticsUpdater(
|
||||
track.getTripStatistics().getStartTime());
|
||||
TripStatistics tripStatistics = updater.getTripStatistics();
|
||||
String description = new DescriptionGeneratorImpl(context).generateWaypointDescription(
|
||||
tripStatistics);
|
||||
String icon = context.getString(R.string.marker_statistics_icon_url);
|
||||
double length = 0.0;
|
||||
long duration = 0L;
|
||||
Location waypointLocation = new Location("");
|
||||
waypointLocation.setLatitude(100);
|
||||
waypointLocation.setLongitude(180);
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, track.getId(),
|
||||
WaypointType.STATISTICS, length, duration, -1L, -1L, waypointLocation, tripStatistics);
|
||||
myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds waypoints to a track.
|
||||
*
|
||||
* @param track the track
|
||||
*/
|
||||
private void addWaypoints(Track track) {
|
||||
Cursor trackPointCursor = null;
|
||||
try {
|
||||
trackPointCursor = myTracksProviderUtils.getTrackPointCursor(track.getId(), -1L, -1, false);
|
||||
if (trackPointCursor == null) {
|
||||
return;
|
||||
}
|
||||
int waypointPosition = -1;
|
||||
Waypoint waypoint = null;
|
||||
int trackPointPosition = -1;
|
||||
Location trackPoint = null;
|
||||
TripStatisticsUpdater trackTripStatisticstrackUpdater = new TripStatisticsUpdater(
|
||||
track.getTripStatistics().getStartTime());
|
||||
TripStatisticsUpdater markerTripStatisticsUpdater = new TripStatisticsUpdater(
|
||||
track.getTripStatistics().getStartTime());
|
||||
|
||||
while (true) {
|
||||
if (waypoint == null) {
|
||||
waypointPosition++;
|
||||
waypoint = waypointPosition < waypoints.size() ? waypoints.get(waypointPosition) : null;
|
||||
if (waypoint == null) {
|
||||
// No more waypoints
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (trackPoint == null) {
|
||||
trackPointPosition++;
|
||||
trackPoint = trackPointCursor.moveToPosition(trackPointPosition) ? myTracksProviderUtils
|
||||
.createTrackPoint(trackPointCursor)
|
||||
: null;
|
||||
if (trackPoint == null) {
|
||||
// No more track points. Ignore the rest of the waypoints.
|
||||
return;
|
||||
}
|
||||
trackTripStatisticstrackUpdater.addLocation(trackPoint, minRecordingDistance);
|
||||
markerTripStatisticsUpdater.addLocation(trackPoint, minRecordingDistance);
|
||||
}
|
||||
if (waypoint.getLocation().getTime() > trackPoint.getTime()) {
|
||||
trackPoint = null;
|
||||
} else if (waypoint.getLocation().getTime() < trackPoint.getTime()) {
|
||||
waypoint = null;
|
||||
} else {
|
||||
// The waypoint location time matches the track point time
|
||||
if (trackPoint.getLatitude() == waypoint.getLocation().getLatitude()
|
||||
&& trackPoint.getLongitude() == waypoint.getLocation().getLongitude()) {
|
||||
|
||||
// Get tripStatistics, description, and icon
|
||||
TripStatistics tripStatistics;
|
||||
String description;
|
||||
String icon;
|
||||
if (waypoint.getType() == WaypointType.STATISTICS) {
|
||||
tripStatistics = markerTripStatisticsUpdater.getTripStatistics();
|
||||
markerTripStatisticsUpdater = new TripStatisticsUpdater(trackPoint.getTime());
|
||||
description = new DescriptionGeneratorImpl(context).generateWaypointDescription(
|
||||
tripStatistics);
|
||||
icon = context.getString(R.string.marker_statistics_icon_url);
|
||||
} else {
|
||||
tripStatistics = null;
|
||||
description = waypoint.getDescription();
|
||||
icon = context.getString(R.string.marker_waypoint_icon_url);
|
||||
}
|
||||
|
||||
// Get length and duration
|
||||
double length = trackTripStatisticstrackUpdater.getTripStatistics().getTotalDistance();
|
||||
long duration = trackTripStatisticstrackUpdater.getTripStatistics().getTotalTime();
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint newWaypoint = new Waypoint(waypoint.getName(), description,
|
||||
waypoint.getCategory(), icon, track.getId(), waypoint.getType(), length, duration,
|
||||
-1L, -1L, trackPoint, tripStatistics);
|
||||
myTracksProviderUtils.insertWaypoint(newWaypoint);
|
||||
}
|
||||
waypoint = null;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (trackPointCursor != null) {
|
||||
trackPointCursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.io.file;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
@@ -31,7 +32,7 @@ import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Write track as GPX to a file.
|
||||
*
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class GpxTrackWriter implements TrackFormatWriter {
|
||||
@@ -39,8 +40,10 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
private static final NumberFormat ELEVATION_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||
private static final NumberFormat COORDINATE_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||
static {
|
||||
// GPX readers expect to see fractional numbers with US-style punctuation.
|
||||
// That is, they want periods for decimal points, rather than commas.
|
||||
/*
|
||||
* GPX readers expect to see fractional numbers with US-style punctuation.
|
||||
* That is, they want periods for decimal points, rather than commas.
|
||||
*/
|
||||
ELEVATION_FORMAT.setMaximumFractionDigits(1);
|
||||
ELEVATION_FORMAT.setGroupingUsed(false);
|
||||
|
||||
@@ -112,6 +115,7 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
printWriter.println("<trk>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
printWriter.println("<desc>" + StringUtils.formatCData(track.getDescription()) + "</desc>");
|
||||
printWriter.println("<type>" + StringUtils.formatCData(track.getCategory()) + "</type>");
|
||||
printWriter.println("<extensions><topografix:color>c0c0c0</topografix:color></extensions>");
|
||||
}
|
||||
}
|
||||
@@ -138,7 +142,8 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<trkpt " + formatLocation(location) + ">");
|
||||
printWriter.println("<ele>" + ELEVATION_FORMAT.format(location.getAltitude()) + "</ele>");
|
||||
printWriter.println("<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println(
|
||||
"<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println("</trkpt>");
|
||||
}
|
||||
}
|
||||
@@ -160,10 +165,13 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
if (location != null) {
|
||||
printWriter.println("<wpt " + formatLocation(location) + ">");
|
||||
printWriter.println("<ele>" + ELEVATION_FORMAT.format(location.getAltitude()) + "</ele>");
|
||||
printWriter.println("<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println(
|
||||
"<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(waypoint.getName()) + "</name>");
|
||||
printWriter.println("<cmt>" + StringUtils.formatCData(waypoint.getType().name()) + "</cmt>");
|
||||
printWriter.println(
|
||||
"<desc>" + StringUtils.formatCData(waypoint.getDescription()) + "</desc>");
|
||||
printWriter.println("<type>" + StringUtils.formatCData(waypoint.getCategory()) + "</type>");
|
||||
printWriter.println("</wpt>");
|
||||
}
|
||||
}
|
||||
@@ -171,7 +179,7 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
|
||||
/**
|
||||
* Formats a location with latitude and longitude coordinates.
|
||||
*
|
||||
*
|
||||
* @param location the location
|
||||
*/
|
||||
private String formatLocation(Location location) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.android.apps.mytracks.content.Sensor.SensorData;
|
||||
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -37,7 +38,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Write track as KML to a file.
|
||||
*
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class KmlTrackWriter implements TrackFormatWriter {
|
||||
@@ -57,16 +58,16 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
private static final String HEART_RATE = "heart_rate";
|
||||
private static final String POWER = "power";
|
||||
|
||||
private static final String WAYPOINT_ICON =
|
||||
"http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png";
|
||||
private static final String STATISTICS_ICON =
|
||||
"http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png";
|
||||
private static final String START_ICON =
|
||||
"http://maps.google.com/mapfiles/kml/paddle/grn-circle.png";
|
||||
private static final String END_ICON =
|
||||
"http://maps.google.com/mapfiles/kml/paddle/red-circle.png";
|
||||
private static final String TRACK_ICON =
|
||||
"http://earth.google.com/images/kml-icons/track-directional/track-0.png";
|
||||
private static final String
|
||||
WAYPOINT_ICON = "http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png";
|
||||
private static final String
|
||||
STATISTICS_ICON = "http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png";
|
||||
private static final String
|
||||
START_ICON = "http://maps.google.com/mapfiles/kml/paddle/grn-circle.png";
|
||||
private static final String
|
||||
END_ICON = "http://maps.google.com/mapfiles/kml/paddle/red-circle.png";
|
||||
private static final String
|
||||
TRACK_ICON = "http://earth.google.com/images/kml-icons/track-directional/track-0.png";
|
||||
|
||||
private final Context context;
|
||||
private final DescriptionGenerator descriptionGenerator;
|
||||
@@ -113,16 +114,14 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
printWriter.println("<kml xmlns=\"http://www.opengis.net/kml/2.2\"");
|
||||
printWriter.println("xmlns:atom=\"http://www.w3.org/2005/Atom\"");
|
||||
printWriter.println("xmlns:gx=\"http://www.google.com/kml/ext/2.2\">");
|
||||
printWriter.println("xmlns:gx=\"http://www.google.com/kml/ext/2.2\"");
|
||||
printWriter.println("xmlns:atom=\"http://www.w3.org/2005/Atom\">");
|
||||
printWriter.println("<Document>");
|
||||
printWriter.println("<open>1</open>");
|
||||
printWriter.println("<visibility>1</visibility>");
|
||||
printWriter.println(
|
||||
"<description>" + StringUtils.formatCData(track.getDescription()) + "</description>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
printWriter.println("<atom:author><atom:name>" + StringUtils.formatCData(
|
||||
context.getString(R.string.send_google_by_my_tracks, "", ""))
|
||||
printWriter.println("<atom:author><atom:name>"
|
||||
+ StringUtils.formatCData(context.getString(R.string.send_google_by_my_tracks, "", ""))
|
||||
+ "</atom:name></atom:author>");
|
||||
writeTrackStyle();
|
||||
writePlacemarkerStyle(START_STYLE, START_ICON, 32, 1);
|
||||
@@ -148,9 +147,9 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
@Override
|
||||
public void writeBeginWaypoints() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println(
|
||||
"<Folder><name>" + StringUtils.formatCData(context.getString(R.string.menu_markers))
|
||||
+ "</name>");
|
||||
printWriter.println("<Folder><name>"
|
||||
+ StringUtils.formatCData(context.getString(R.string.menu_markers)) + "</name>");
|
||||
printWriter.println("<open>1</open>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,10 +163,10 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
if (printWriter != null) {
|
||||
String styleName = waypoint.getType() == Waypoint.TYPE_STATISTICS ? STATISTICS_STYLE
|
||||
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE
|
||||
: WAYPOINT_STYLE;
|
||||
writePlacemark(
|
||||
waypoint.getName(), waypoint.getDescription(), styleName, waypoint.getLocation());
|
||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
|
||||
styleName, waypoint.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,12 +174,13 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
public void writeBeginTrack(Location firstLocation) {
|
||||
if (printWriter != null) {
|
||||
String name = context.getString(R.string.marker_label_start, track.getName());
|
||||
writePlacemark(name, track.getDescription(), START_STYLE, firstLocation);
|
||||
writePlacemark(name, "", "", START_STYLE, firstLocation);
|
||||
printWriter.println("<Placemark id=\"" + TOUR_FEATURE_ID + "\">");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
printWriter.println(
|
||||
"<description>" + StringUtils.formatCData(track.getDescription()) + "</description>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
printWriter.println("<styleUrl>#" + TRACK_STYLE + "</styleUrl>");
|
||||
writeCategory(track.getCategory());
|
||||
printWriter.println("<gx:MultiTrack>");
|
||||
printWriter.println("<altitudeMode>absolute</altitudeMode>");
|
||||
printWriter.println("<gx:interpolate>1</gx:interpolate>");
|
||||
@@ -194,7 +194,7 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
printWriter.println("</Placemark>");
|
||||
String name = context.getString(R.string.marker_label_end, track.getName());
|
||||
String description = descriptionGenerator.generateTrackDescription(track, null, null, false);
|
||||
writePlacemark(name, description, END_STYLE, lastLocation);
|
||||
writePlacemark(name, "", description, END_STYLE, lastLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,10 +234,10 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
@Override
|
||||
public void writeLocation(Location location) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<when>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</when>");
|
||||
printWriter.println(
|
||||
"<gx:coord>" + location.getLongitude() + " " + location.getLatitude() + " "
|
||||
+ location.getAltitude() + "</gx:coord>");
|
||||
"<when>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</when>");
|
||||
printWriter.println("<gx:coord>" + location.getLongitude() + " " + location.getLatitude()
|
||||
+ " " + location.getAltitude() + "</gx:coord>");
|
||||
if (location instanceof MyTracksLocation) {
|
||||
SensorDataSet sensorDataSet = ((MyTracksLocation) location).getSensorDataSet();
|
||||
int power = -1;
|
||||
@@ -265,7 +265,7 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
hasHeartRate = true;
|
||||
heartRate = sensorData.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
powerList.add(power);
|
||||
cadenceList.add(cadence);
|
||||
@@ -276,7 +276,7 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
|
||||
/**
|
||||
* Writes the sensor data.
|
||||
*
|
||||
*
|
||||
* @param list a list of sensor data
|
||||
* @param name the name of the sensor data
|
||||
*/
|
||||
@@ -290,29 +290,45 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
|
||||
/**
|
||||
* Writes a placemark.
|
||||
*
|
||||
* @param name the name of the placemark
|
||||
*
|
||||
* @param name the name
|
||||
* @param category the category
|
||||
* @param description the description
|
||||
* @param styleName the style name
|
||||
* @param location the location
|
||||
*/
|
||||
private void writePlacemark(
|
||||
String name, String description, String styleName, Location location) {
|
||||
String name, String category, String description, String styleName, Location location) {
|
||||
if (location != null) {
|
||||
printWriter.println("<Placemark>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(name) + "</name>");
|
||||
printWriter.println(
|
||||
"<description>" + StringUtils.formatCData(description) + "</description>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(name) + "</name>");
|
||||
printWriter.println("<styleUrl>#" + styleName + "</styleUrl>");
|
||||
writeCategory(category);
|
||||
printWriter.println("<Point>");
|
||||
printWriter.println(
|
||||
"<coordinates>" + location.getLongitude() + "," + location.getLatitude() + ","
|
||||
+ location.getAltitude() + "</coordinates>");
|
||||
printWriter.println("<coordinates>" + location.getLongitude() + "," + location.getLatitude()
|
||||
+ "," + location.getAltitude() + "</coordinates>");
|
||||
printWriter.println("</Point>");
|
||||
printWriter.println("</Placemark>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the category.
|
||||
*
|
||||
* @param category the category
|
||||
*/
|
||||
private void writeCategory(String category) {
|
||||
if (category == null || category.equals("")) {
|
||||
return;
|
||||
}
|
||||
printWriter.println("<ExtendedData>");
|
||||
printWriter.println(
|
||||
"<Data name=\"type\"><value>" + StringUtils.formatCData(category) + "</value></Data>");
|
||||
printWriter.println("</ExtendedData>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the track style.
|
||||
*/
|
||||
@@ -328,7 +344,7 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
|
||||
/**
|
||||
* Writes a placemarker style.
|
||||
*
|
||||
*
|
||||
* @param name the name of the style
|
||||
* @param url the url of the style icon
|
||||
* @param x the x position of the hotspot
|
||||
@@ -345,14 +361,13 @@ public class KmlTrackWriter implements TrackFormatWriter {
|
||||
|
||||
/**
|
||||
* Writes a sensor style.
|
||||
*
|
||||
*
|
||||
* @param name the name of the sesnor
|
||||
* @param displayName the sensor display name
|
||||
*/
|
||||
private void writeSensorStyle(String name, String displayName) {
|
||||
printWriter.println("<gx:SimpleArrayField name=\"" + name + "\" type=\"int\">");
|
||||
printWriter.println(
|
||||
"<displayName>" + StringUtils.formatCData(displayName) + "</displayName>");
|
||||
printWriter.println("<displayName>" + StringUtils.formatCData(displayName) + "</displayName>");
|
||||
printWriter.println("</gx:SimpleArrayField>");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||
@@ -335,7 +336,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
// track).
|
||||
while (cursor.moveToNext()) {
|
||||
Waypoint wpt = myTracksProviderUtils.createWaypoint(cursor);
|
||||
String type = wpt.getType() == Waypoint.TYPE_STATISTICS ? MARKER_TYPE_STATISTICS
|
||||
String type = wpt.getType() == WaypointType.STATISTICS ? MARKER_TYPE_STATISTICS
|
||||
: MARKER_TYPE_WAYPOINT;
|
||||
if (!createNewPoint(wpt.getName(), wpt.getDescription(), wpt.getLocation(), type)) {
|
||||
Log.d(TAG, "Upload waypoints failed");
|
||||
|
||||
@@ -28,8 +28,8 @@ import com.google.android.apps.mytracks.content.Sensor;
|
||||
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest.WaypointType;
|
||||
import com.google.android.apps.mytracks.services.sensors.SensorManager;
|
||||
import com.google.android.apps.mytracks.services.sensors.SensorManagerFactory;
|
||||
import com.google.android.apps.mytracks.services.tasks.AnnouncementPeriodicTaskFactory;
|
||||
@@ -413,13 +413,16 @@ public class TrackRecordingService extends Service {
|
||||
return -1L;
|
||||
}
|
||||
|
||||
boolean isStatistics = waypointCreationRequest.getType() == WaypointType.STATISTICS;
|
||||
WaypointType waypointType = waypointCreationRequest.getType();
|
||||
boolean isStatistics = waypointType == WaypointType.STATISTICS;
|
||||
|
||||
// Get name
|
||||
String name;
|
||||
if (waypointCreationRequest.getName() != null) {
|
||||
name = waypointCreationRequest.getName();
|
||||
} else {
|
||||
int nextWaypointNumber = myTracksProviderUtils.getNextWaypointNumber(
|
||||
recordingTrackId, isStatistics);
|
||||
recordingTrackId, waypointType);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
}
|
||||
@@ -428,29 +431,33 @@ public class TrackRecordingService extends Service {
|
||||
nextWaypointNumber);
|
||||
}
|
||||
|
||||
// Get category
|
||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest
|
||||
.getCategory()
|
||||
: "";
|
||||
|
||||
// Get tripStatistics, description, and icon
|
||||
TripStatistics tripStatistics;
|
||||
String description;
|
||||
String icon;
|
||||
if (isStatistics) {
|
||||
long now = System.currentTimeMillis();
|
||||
markerTripStatisticsUpdater.updateTime(now);
|
||||
tripStatistics = markerTripStatisticsUpdater.getTripStatistics();
|
||||
markerTripStatisticsUpdater = new TripStatisticsUpdater(now);
|
||||
description = new DescriptionGeneratorImpl(this).generateWaypointDescription(tripStatistics);
|
||||
icon = getString(R.string.marker_statistics_icon_url);
|
||||
} else {
|
||||
tripStatistics = null;
|
||||
description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest
|
||||
.getDescription()
|
||||
: "";
|
||||
icon = getString(R.string.marker_waypoint_icon_url);
|
||||
}
|
||||
|
||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest
|
||||
.getCategory()
|
||||
: "";
|
||||
String icon = getString(
|
||||
isStatistics ? R.string.marker_statistics_icon_url : R.string.marker_waypoint_icon_url);
|
||||
int type = isStatistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT;
|
||||
long duration;
|
||||
// Get length and duration
|
||||
double length;
|
||||
long duration;
|
||||
Location location = getLastValidTrackPointInCurrentSegment(recordingTrackId);
|
||||
if (location != null && trackTripStatisticsUpdater != null) {
|
||||
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
||||
@@ -464,10 +471,12 @@ public class TrackRecordingService extends Service {
|
||||
location = new Location("");
|
||||
location.setLatitude(100);
|
||||
location.setLongitude(180);
|
||||
length = 0;
|
||||
duration = 0;
|
||||
length = 0.0;
|
||||
duration = 0L;
|
||||
}
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, type,
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, waypointType,
|
||||
length, duration, -1L, -1L, location, tripStatistics);
|
||||
Uri uri = myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
return Long.parseLong(uri.getLastPathSegment());
|
||||
@@ -592,7 +601,7 @@ public class TrackRecordingService extends Service {
|
||||
trackTripStatisticsUpdater = new TripStatisticsUpdater(tripStatistics.getStartTime());
|
||||
|
||||
long markerStartTime;
|
||||
Waypoint waypoint = myTracksProviderUtils.getLastStatisticsWaypoint(recordingTrackId);
|
||||
Waypoint waypoint = myTracksProviderUtils.getLastWaypoint(recordingTrackId, WaypointType.STATISTICS);
|
||||
if (waypoint != null && waypoint.getTripStatistics() != null) {
|
||||
markerStartTime = waypoint.getTripStatistics().getStopTime();
|
||||
} else {
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
#Tue Jul 17 10:23:25 PDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
@@ -17,7 +8,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
@@ -74,7 +64,6 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=1585
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent=1585|-1|1585
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
@@ -126,28 +128,28 @@ public interface MyTracksProviderUtils {
|
||||
|
||||
/**
|
||||
* Gets the first waypoint id for a track. The first waypoint is special as it
|
||||
* contains the stats for the current segment. Returns -1L if it doesn't
|
||||
* exist.
|
||||
* contains the stats for the track. Returns -1L if it doesn't exist.
|
||||
*
|
||||
* @param trackId the track id
|
||||
*/
|
||||
public long getFirstWaypointId(long trackId);
|
||||
|
||||
/**
|
||||
* Gets the last statistics waypoint for a track. Returns null if it doesn't exist.
|
||||
* Gets the last waypoint for a type. Returns null if it doesn't exist.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public Waypoint getLastStatisticsWaypoint(long trackId);
|
||||
public Waypoint getLastWaypoint(long trackId, WaypointType waypointType);
|
||||
|
||||
/**
|
||||
* Gets the next waypoint number. Returns -1 if not able to get the next
|
||||
* Gets the next waypoint number for a type. Returns -1 if not able to get the next
|
||||
* waypoint number.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param statistics true for statistics marker, false for waypoint marker
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public int getNextWaypointNumber(long trackId, boolean statistics);
|
||||
public int getNextWaypointNumber(long trackId, WaypointType waypointType);
|
||||
|
||||
/**
|
||||
* Gets a waypoint from a waypoint id. Returns null if not found.
|
||||
|
||||
+13
-12
@@ -17,6 +17,7 @@
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
@@ -350,7 +351,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
waypoint.setTrackId(cursor.getLong(trackIdIndex));
|
||||
}
|
||||
if (!cursor.isNull(typeIndex)) {
|
||||
waypoint.setType(cursor.getInt(typeIndex));
|
||||
waypoint.setType(WaypointType.values()[cursor.getInt(typeIndex)]);
|
||||
}
|
||||
if (!cursor.isNull(lengthIndex)) {
|
||||
waypoint.setLength(cursor.getFloat(lengthIndex));
|
||||
@@ -439,7 +440,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
@Override
|
||||
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator) {
|
||||
final Waypoint waypoint = getWaypoint(waypointId);
|
||||
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_STATISTICS
|
||||
if (waypoint != null && waypoint.getType() == WaypointType.STATISTICS
|
||||
&& descriptionGenerator != null) {
|
||||
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
|
||||
if (nextWaypoint == null) {
|
||||
@@ -479,15 +480,15 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Waypoint getLastStatisticsWaypoint(long trackId) {
|
||||
public Waypoint getLastWaypoint(long trackId, WaypointType waypointType) {
|
||||
if (trackId < 0) {
|
||||
return null;
|
||||
}
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "="
|
||||
+ Waypoint.TYPE_STATISTICS;
|
||||
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[] {
|
||||
Long.toString(trackId), Integer.toString(waypointType.ordinal()) };
|
||||
cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID + " DESC", 1);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return createWaypoint(cursor);
|
||||
@@ -501,7 +502,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextWaypointNumber(long trackId, boolean statistics) {
|
||||
public int getNextWaypointNumber(long trackId, WaypointType waypointType) {
|
||||
if (trackId < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -509,8 +510,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
try {
|
||||
String[] projection = { WaypointsColumns._ID };
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
int type = statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT;
|
||||
String[] selectionArgs = new String[] { Long.toString(trackId), Integer.toString(type) };
|
||||
String[] selectionArgs = new String[] {
|
||||
Long.toString(trackId), Integer.toString(waypointType.ordinal()) };
|
||||
cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, -1);
|
||||
if (cursor != null) {
|
||||
int count = cursor.getCount();
|
||||
@@ -518,7 +519,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
* For statistics markers, the first marker is for the track statistics,
|
||||
* so return the count as the next user visible number.
|
||||
*/
|
||||
return statistics ? count : count + 1;
|
||||
return waypointType == WaypointType.STATISTICS ? count : count + 1;
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
@@ -597,7 +598,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
values.put(WaypointsColumns.CATEGORY, waypoint.getCategory());
|
||||
values.put(WaypointsColumns.ICON, waypoint.getIcon());
|
||||
values.put(WaypointsColumns.TRACKID, waypoint.getTrackId());
|
||||
values.put(WaypointsColumns.TYPE, waypoint.getType());
|
||||
values.put(WaypointsColumns.TYPE, waypoint.getType().ordinal());
|
||||
values.put(WaypointsColumns.LENGTH, waypoint.getLength());
|
||||
values.put(WaypointsColumns.DURATION, waypoint.getDuration());
|
||||
values.put(WaypointsColumns.STARTID, waypoint.getStartId());
|
||||
@@ -644,7 +645,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
|
||||
+ WaypointsColumns.TYPE + "=" + Waypoint.TYPE_STATISTICS;
|
||||
+ WaypointsColumns.TYPE + "=" + WaypointType.STATISTICS.ordinal();
|
||||
String[] selectionArgs = new String[] {
|
||||
Long.toString(waypoint.getId()), Long.toString(waypoint.getTrackId()) };
|
||||
cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, 1);
|
||||
|
||||
@@ -30,8 +30,9 @@ import android.os.Parcelable;
|
||||
*/
|
||||
public final class Waypoint implements Parcelable {
|
||||
|
||||
public static final int TYPE_WAYPOINT = 0;
|
||||
public static final int TYPE_STATISTICS = 1;
|
||||
public static enum WaypointType {
|
||||
WAYPOINT, STATISTICS;
|
||||
}
|
||||
|
||||
private long id = -1L;
|
||||
private String name = "";
|
||||
@@ -39,7 +40,7 @@ public final class Waypoint implements Parcelable {
|
||||
private String category = "";
|
||||
private String icon = "";
|
||||
private long trackId = -1L;
|
||||
private int type = 0;
|
||||
private WaypointType type = WaypointType.WAYPOINT;
|
||||
private double length = 0.0;
|
||||
private long duration = 0;
|
||||
private long startId = -1L;
|
||||
@@ -50,7 +51,7 @@ public final class Waypoint implements Parcelable {
|
||||
public Waypoint() {}
|
||||
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId,
|
||||
int type, double length, long duration, long startId, long stopId, Location location,
|
||||
WaypointType type, double length, long duration, long startId, long stopId, Location location,
|
||||
TripStatistics tripStatistics) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -73,7 +74,7 @@ public final class Waypoint implements Parcelable {
|
||||
category = source.readString();
|
||||
icon = source.readString();
|
||||
trackId = source.readLong();
|
||||
type = source.readInt();
|
||||
type = WaypointType.values()[source.readInt()];
|
||||
length = source.readDouble();
|
||||
duration = source.readLong();
|
||||
startId = source.readLong();
|
||||
@@ -103,7 +104,7 @@ public final class Waypoint implements Parcelable {
|
||||
dest.writeString(category);
|
||||
dest.writeString(icon);
|
||||
dest.writeLong(trackId);
|
||||
dest.writeInt(type);
|
||||
dest.writeInt(type.ordinal());
|
||||
dest.writeDouble(length);
|
||||
dest.writeLong(duration);
|
||||
dest.writeLong(startId);
|
||||
@@ -178,11 +179,11 @@ public final class Waypoint implements Parcelable {
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
public void setType(WaypointType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -25,10 +27,6 @@ import android.os.Parcelable;
|
||||
*/
|
||||
public class WaypointCreationRequest implements Parcelable {
|
||||
|
||||
public static enum WaypointType {
|
||||
WAYPOINT, STATISTICS;
|
||||
}
|
||||
|
||||
private WaypointType type;
|
||||
// true if this marker contains the track statistics
|
||||
private boolean isTrackStatistics;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
@@ -16,7 +13,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
@@ -24,12 +21,15 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
@@ -38,21 +38,31 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warni
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
@@ -74,7 +84,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=1585
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent=1585|-1|1585
|
||||
|
||||
+17
-16
@@ -17,6 +17,7 @@ package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationFactory;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceTest.MockContext;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.testing.mocking.AndroidMock;
|
||||
@@ -365,7 +366,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
// Insert at first.
|
||||
Waypoint waypoint = new Waypoint();
|
||||
waypoint.setDescription(TEST_DESC);
|
||||
waypoint.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint.setType(WaypointType.STATISTICS);
|
||||
waypoint.setTripStatistics(statistics);
|
||||
|
||||
Location loc = new Location("test");
|
||||
@@ -442,7 +443,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
Waypoint waypoint1 = new Waypoint();
|
||||
waypoint1.setDescription(TEST_DESC);
|
||||
waypoint1.setTrackId(trackId);
|
||||
waypoint1.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint1.setType(WaypointType.STATISTICS);
|
||||
providerUtils.insertWaypoint(waypoint1);
|
||||
|
||||
// Delete
|
||||
@@ -491,13 +492,13 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
Waypoint waypoint1 = new Waypoint();
|
||||
waypoint1.setDescription(Long.toString(trackId));
|
||||
waypoint1.setTrackId(trackId);
|
||||
waypoint1.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint1.setType(WaypointType.STATISTICS);
|
||||
waypoint1.setTripStatistics(statistics);
|
||||
providerUtils.insertWaypoint(waypoint1);
|
||||
Waypoint waypoint2 = new Waypoint();
|
||||
waypoint2.setDescription(Long.toString(trackId));
|
||||
waypoint2.setTrackId(trackId);
|
||||
waypoint2.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint2.setType(WaypointType.STATISTICS);
|
||||
waypoint2.setTripStatistics(statistics);
|
||||
providerUtils.insertWaypoint(waypoint2);
|
||||
|
||||
@@ -541,7 +542,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the method {@link MyTracksProviderUtilsImpl#getNextWaypointNumber(long, boolean)}.
|
||||
* Tests the method {@link MyTracksProviderUtilsImpl#getNextWaypointNumber(long, WaypointType)}.
|
||||
*/
|
||||
public void testGetNextWaypointNumber() {
|
||||
long trackId = System.currentTimeMillis();
|
||||
@@ -549,29 +550,29 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
providerUtils.insertTrack(track);
|
||||
|
||||
Waypoint waypoint1 = new Waypoint();
|
||||
waypoint1.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint1.setType(WaypointType.STATISTICS);
|
||||
waypoint1.setTrackId(trackId);
|
||||
Waypoint waypoint2 = new Waypoint();
|
||||
waypoint2.setType(Waypoint.TYPE_WAYPOINT);
|
||||
waypoint2.setType(WaypointType.WAYPOINT);
|
||||
waypoint2.setTrackId(trackId);
|
||||
Waypoint waypoint3 = new Waypoint();
|
||||
waypoint3.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint3.setType(WaypointType.STATISTICS);
|
||||
waypoint3.setTrackId(trackId);
|
||||
Waypoint waypoint4 = new Waypoint();
|
||||
waypoint4.setType(Waypoint.TYPE_WAYPOINT);
|
||||
waypoint4.setType(WaypointType.WAYPOINT);
|
||||
waypoint4.setTrackId(trackId);
|
||||
providerUtils.insertWaypoint(waypoint1);
|
||||
providerUtils.insertWaypoint(waypoint2);
|
||||
providerUtils.insertWaypoint(waypoint3);
|
||||
providerUtils.insertWaypoint(waypoint4);
|
||||
|
||||
assertEquals(2, providerUtils.getNextWaypointNumber(trackId, true));
|
||||
assertEquals(3, providerUtils.getNextWaypointNumber(trackId, false));
|
||||
assertEquals(2, providerUtils.getNextWaypointNumber(trackId, WaypointType.STATISTICS));
|
||||
assertEquals(3, providerUtils.getNextWaypointNumber(trackId, WaypointType.WAYPOINT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the method
|
||||
* {@link MyTracksProviderUtils#getLastStatisticsWaypoint(long)}.
|
||||
* {@link MyTracksProviderUtils#getLastWaypoint(long, WaypointType)}.
|
||||
*/
|
||||
public void testGetLastStatisticsWaypoint() {
|
||||
long trackId = System.currentTimeMillis();
|
||||
@@ -580,21 +581,21 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
||||
|
||||
Waypoint waypoint1 = new Waypoint();
|
||||
waypoint1.setTrackId(trackId);
|
||||
waypoint1.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint1.setType(WaypointType.STATISTICS);
|
||||
waypoint1.setDescription("Desc1");
|
||||
Waypoint waypoint2 = new Waypoint();
|
||||
waypoint2.setTrackId(trackId);
|
||||
waypoint2.setType(Waypoint.TYPE_STATISTICS);
|
||||
waypoint2.setType(WaypointType.STATISTICS);
|
||||
waypoint2.setDescription("Desc2");
|
||||
Waypoint waypoint3 = new Waypoint();
|
||||
waypoint3.setTrackId(trackId);
|
||||
waypoint3.setType(Waypoint.TYPE_WAYPOINT);
|
||||
waypoint3.setType(WaypointType.WAYPOINT);
|
||||
waypoint3.setDescription("Desc3");
|
||||
providerUtils.insertWaypoint(waypoint1);
|
||||
providerUtils.insertWaypoint(waypoint2);
|
||||
providerUtils.insertWaypoint(waypoint3);
|
||||
|
||||
assertEquals("Desc2", providerUtils.getLastStatisticsWaypoint(trackId).getDescription());
|
||||
assertEquals("Desc2", providerUtils.getLastWaypoint(trackId, WaypointType.STATISTICS).getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
@@ -22,6 +22,8 @@ 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.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.WaypointsColumns;
|
||||
import com.google.android.apps.mytracks.testing.TestingProviderUtilsFactory;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.testing.mocking.AndroidMock;
|
||||
@@ -38,6 +40,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.SimpleTimeZone;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -69,13 +72,15 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
private static final String TRACK_TIME_3 = "2010-04-22T18:24:50.123";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT_0 = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'hh:mm:ss'Z'");
|
||||
"yyyy-MM-dd'T'hh:mm:ss'Z'", Locale.US);
|
||||
private static final SimpleDateFormat DATE_FORMAT_1 = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
|
||||
|
||||
static {
|
||||
// We can't omit the timezones in the test, otherwise it'll use the local
|
||||
// timezone and fail depending on where the test runner is.
|
||||
/*
|
||||
* We can't omit the timezones in the test, otherwise it'll use the local
|
||||
* timezone and fail depending on where the test runner is.
|
||||
*/
|
||||
SimpleTimeZone utc = new SimpleTimeZone(0, "UTC");
|
||||
DATE_FORMAT_0.setTimeZone(utc);
|
||||
DATE_FORMAT_1.setTimeZone(utc);
|
||||
@@ -134,11 +139,14 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
private static final long TRACK_POINT_ID_0 = 1;
|
||||
private static final long TRACK_POINT_ID_1 = 2;
|
||||
private static final long TRACK_POINT_ID_3 = 4;
|
||||
private static final long WAYPOINT_ID_0 = 1;
|
||||
|
||||
private static final Uri TRACK_ID_0_URI = ContentUris.appendId(
|
||||
TracksColumns.CONTENT_URI.buildUpon(), TRACK_ID_0).build();
|
||||
private static final Uri TRACK_ID_1_URI = ContentUris.appendId(
|
||||
TracksColumns.CONTENT_URI.buildUpon(), TRACK_ID_1).build();
|
||||
private static final Uri WAYPOINT_ID_O_URI = ContentUris.appendId(
|
||||
WaypointsColumns.CONTENT_URI.buildUpon(), WAYPOINT_ID_0).build();
|
||||
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
|
||||
@@ -171,24 +179,19 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_0_URI);
|
||||
|
||||
// A flush happens before getting the start point ID
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
LocationsMatcher.eqLoc(location0), eq(1), eq(TRACK_ID_0))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_0);
|
||||
expectFirstTrackPoint(location0, TRACK_ID_0, TRACK_POINT_ID_0);
|
||||
|
||||
// A flush happens at the end
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
LocationsMatcher.eqLoc(location1), eq(1), eq(TRACK_ID_0))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_1);
|
||||
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(track));
|
||||
|
||||
expectUpdateTrack(track, true, TRACK_ID_0);
|
||||
AndroidMock.replay(myTracksProviderUtils);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(VALID_ONE_TRACK_ONE_SEGMENT_GPX.getBytes());
|
||||
long[] trackIds = GpxImporter.importGPXFile(
|
||||
inputStream, myTracksProviderUtils, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
long[] trackIds = GpxImporter.importGPXFile(getContext(), inputStream, myTracksProviderUtils,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
assertEquals(1, trackIds.length);
|
||||
assertEquals(TRACK_ID_0, trackIds[0]);
|
||||
|
||||
@@ -209,23 +212,19 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_0_URI);
|
||||
// A flush happens before getting the start point ID
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
LocationsMatcher.eqLoc(location0), eq(1), eq(TRACK_ID_0))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_0);
|
||||
expectFirstTrackPoint(location0, TRACK_ID_0, TRACK_POINT_ID_0);
|
||||
|
||||
// A flush happens at the end
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
(Location[]) AndroidMock.anyObject(), eq(5), eq(TRACK_ID_0))).andStubReturn(5);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_3);
|
||||
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(track));
|
||||
|
||||
expectUpdateTrack(track, true, TRACK_ID_0);
|
||||
AndroidMock.replay(myTracksProviderUtils);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(VALID_ONE_TRACK_TWO_SEGMENTS_GPX.getBytes());
|
||||
long[] trackIds = GpxImporter.importGPXFile(
|
||||
inputStream, myTracksProviderUtils, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
long[] trackIds = GpxImporter.importGPXFile(getContext(), inputStream, myTracksProviderUtils,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
assertEquals(1, trackIds.length);
|
||||
assertEquals(TRACK_ID_0, trackIds[0]);
|
||||
|
||||
@@ -245,35 +244,31 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
* Tests one track with two segments, but no time in the track points.
|
||||
*/
|
||||
public void testOneTrackTwoSegmentsNoTime() throws Exception {
|
||||
Capture<Track> capturedTrack = new Capture<Track>();
|
||||
Capture<Track> track = new Capture<Track>();
|
||||
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_0_URI);
|
||||
// A flush happens before getting the start point ID
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
(Location[]) AndroidMock.anyObject(), eq(1), eq(TRACK_ID_0))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_0);
|
||||
expectFirstTrackPoint(null, TRACK_ID_0, TRACK_POINT_ID_0);
|
||||
|
||||
// A flush happens at the end
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
(Location[]) AndroidMock.anyObject(), eq(5), eq(TRACK_ID_0))).andStubReturn(5);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_3);
|
||||
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(capturedTrack));
|
||||
|
||||
expectUpdateTrack(track, true, TRACK_ID_0);
|
||||
AndroidMock.replay(myTracksProviderUtils);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(
|
||||
VALID_ONE_TRACK_TWO_SEGMENTS_NO_TIME_GPX.getBytes());
|
||||
long[] trackIds = GpxImporter.importGPXFile(
|
||||
inputStream, myTracksProviderUtils, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
long[] trackIds = GpxImporter.importGPXFile(getContext(), inputStream, myTracksProviderUtils,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
assertEquals(1, trackIds.length);
|
||||
assertEquals(TRACK_ID_0, trackIds[0]);
|
||||
|
||||
assertEquals(0, capturedTrack.getValue().getTripStatistics().getTotalTime());
|
||||
assertEquals(0, track.getValue().getTripStatistics().getTotalTime());
|
||||
|
||||
AndroidMock.verify(myTracksProviderUtils);
|
||||
verifyTrack(capturedTrack.getValue(), TRACK_NAME_0, TRACK_DESCRIPTION_0, -1L);
|
||||
verifyTrack(track.getValue(), TRACK_NAME_0, TRACK_DESCRIPTION_0, -1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,27 +283,19 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_0_URI);
|
||||
// A flush happens before getting the start point ID
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
LocationsMatcher.eqLoc(location0), eq(1), eq(TRACK_ID_0))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_0);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_0)).andReturn(TRACK_POINT_ID_0);
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(track0));
|
||||
expectFirstTrackPoint(location0, TRACK_ID_0, TRACK_POINT_ID_0);
|
||||
expectUpdateTrack(track0, false, TRACK_ID_0);
|
||||
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_1_URI);
|
||||
// A flush happens before getting the start point ID
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
LocationsMatcher.eqLoc(location1), eq(1), eq(TRACK_ID_1))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_1)).andReturn(TRACK_POINT_ID_1);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_1)).andReturn(TRACK_POINT_ID_1);
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(track1));
|
||||
expectFirstTrackPoint(location1, TRACK_ID_1, TRACK_POINT_ID_1);
|
||||
expectUpdateTrack(track1, true, TRACK_ID_1);
|
||||
|
||||
AndroidMock.replay(myTracksProviderUtils);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(VALID_TWO_TRACKS_GPX.getBytes());
|
||||
long[] trackIds = GpxImporter.importGPXFile(
|
||||
inputStream, myTracksProviderUtils, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
long[] trackIds = GpxImporter.importGPXFile(getContext(), inputStream, myTracksProviderUtils,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
assertEquals(2, trackIds.length);
|
||||
assertEquals(TRACK_ID_0, trackIds[0]);
|
||||
assertEquals(TRACK_ID_1, trackIds[1]);
|
||||
@@ -316,25 +303,6 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
AndroidMock.verify(myTracksProviderUtils);
|
||||
}
|
||||
|
||||
private Location createLocation(int index, long time) {
|
||||
Location location = new Location(LocationManager.GPS_PROVIDER);
|
||||
location.setLatitude(TRACK_LATITUDE + index);
|
||||
location.setLongitude(TRACK_LONGITUDE + index);
|
||||
location.setAltitude(TRACK_ELEVATION + index);
|
||||
location.setTime(time);
|
||||
return location;
|
||||
}
|
||||
|
||||
private void verifyTrack(Track track, String name, String description, long time) {
|
||||
assertEquals(name, track.getName());
|
||||
assertEquals(description, track.getDescription());
|
||||
if (time != -1L) {
|
||||
assertEquals(time, track.getTripStatistics().getStartTime());
|
||||
}
|
||||
assertNotSame(-1, track.getStartId());
|
||||
assertNotSame(-1, track.getStopId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test an invalid xml input.
|
||||
*/
|
||||
@@ -380,23 +348,78 @@ public class GpxImporterTest extends AndroidTestCase {
|
||||
private void testInvalidGpx(String xml) throws ParserConfigurationException, IOException {
|
||||
expect(myTracksProviderUtils.insertTrack((Track) AndroidMock.anyObject()))
|
||||
.andReturn(TRACK_ID_0_URI);
|
||||
|
||||
// For the following, use StubReturn since we don't care whether they are
|
||||
// invoked or not.
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
(Location[]) AndroidMock.anyObject(), AndroidMock.anyInt(), AndroidMock.anyLong()))
|
||||
.andStubReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(TRACK_ID_0)).andStubReturn(TRACK_POINT_ID_0);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(TRACK_ID_0)).andStubReturn(TRACK_POINT_ID_0);
|
||||
myTracksProviderUtils.deleteTrack(TRACK_ID_0);
|
||||
AndroidMock.replay(myTracksProviderUtils);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
|
||||
try {
|
||||
GpxImporter.importGPXFile(
|
||||
inputStream, myTracksProviderUtils, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
GpxImporter.importGPXFile(getContext(), inputStream, myTracksProviderUtils,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
} catch (SAXException e) {
|
||||
// expected
|
||||
}
|
||||
AndroidMock.verify(myTracksProviderUtils);
|
||||
}
|
||||
|
||||
private Location createLocation(int index, long time) {
|
||||
Location location = new Location(LocationManager.GPS_PROVIDER);
|
||||
location.setLatitude(TRACK_LATITUDE + index);
|
||||
location.setLongitude(TRACK_LONGITUDE + index);
|
||||
location.setAltitude(TRACK_ELEVATION + index);
|
||||
location.setTime(time);
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expects the first track point to be added.
|
||||
*
|
||||
* @param location the location
|
||||
* @param trackId the track id
|
||||
* @param trackPointId the track point id
|
||||
*/
|
||||
private void expectFirstTrackPoint(Location location, long trackId, long trackPointId) {
|
||||
expect(myTracksProviderUtils.bulkInsertTrackPoint(
|
||||
location != null ? LocationsMatcher.eqLoc(location) : (Location[]) AndroidMock.anyObject(),
|
||||
eq(1), eq(trackId))).andReturn(1);
|
||||
expect(myTracksProviderUtils.getFirstTrackPointId(trackId)).andReturn(trackPointId);
|
||||
expect(myTracksProviderUtils.getLastTrackPointId(trackId)).andReturn(trackPointId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expects the track to be updated.
|
||||
*
|
||||
* @param track the track
|
||||
* @param lastTrack true if it is the last track in the gpx
|
||||
* @param trackId the track id
|
||||
*/
|
||||
private void expectUpdateTrack(Capture<Track> track, boolean lastTrack, long trackId) {
|
||||
myTracksProviderUtils.updateTrack(AndroidMock.capture(track));
|
||||
expect(myTracksProviderUtils.insertWaypoint((Waypoint) AndroidMock.anyObject()))
|
||||
.andReturn(WAYPOINT_ID_O_URI);
|
||||
if (lastTrack) {
|
||||
// Return null to not add waypoints
|
||||
expect(myTracksProviderUtils.getTrack(trackId)).andReturn(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyTrack(Track track, String name, String description, long time) {
|
||||
assertEquals(name, track.getName());
|
||||
assertEquals(description, track.getDescription());
|
||||
if (time != -1L) {
|
||||
assertEquals(time, track.getTripStatistics().getStartTime());
|
||||
}
|
||||
assertNotSame(-1, track.getStartId());
|
||||
assertNotSame(-1, track.getStopId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround because of capture bug 2617107 in easymock:
|
||||
* http://sourceforge.net
|
||||
|
||||
@@ -61,12 +61,11 @@ public class KmlTrackWriterTest extends TrackFormatWriterTest {
|
||||
Element kmlTag = getChildElement(doc, "kml");
|
||||
Element docTag = getChildElement(kmlTag, "Document");
|
||||
assertEquals(TRACK_NAME, getChildTextValue(docTag, "name"));
|
||||
assertEquals(TRACK_DESCRIPTION, getChildTextValue(docTag, "description"));
|
||||
|
||||
// There are 3 placemarks - start, track, and end
|
||||
List<Element> placemarkTags = getChildElements(docTag, "Placemark", 3);
|
||||
assertTagIsPlacemark(
|
||||
placemarkTags.get(0), TRACK_NAME + " (Start)", TRACK_DESCRIPTION, location1);
|
||||
placemarkTags.get(0), TRACK_NAME + " (Start)", "", location1);
|
||||
assertTagIsPlacemark(
|
||||
placemarkTags.get(2), TRACK_NAME + " (End)", FULL_TRACK_DESCRIPTION, location4);
|
||||
|
||||
@@ -97,7 +96,9 @@ public class KmlTrackWriterTest extends TrackFormatWriterTest {
|
||||
private void assertTagIsPlacemark(
|
||||
Element tag, String name, String description, Location location) {
|
||||
assertEquals(name, getChildTextValue(tag, "name"));
|
||||
assertEquals(description, getChildTextValue(tag, "description"));
|
||||
if (description != null && !description.equals("")) {
|
||||
assertEquals(description, getChildTextValue(tag, "description"));
|
||||
}
|
||||
Element pointTag = getChildElement(tag, "Point");
|
||||
String expected = location.getLongitude() + "," + location.getLatitude() + ","
|
||||
+ location.getAltitude();
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ import com.google.android.apps.mytracks.content.MyTracksProvider;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
@@ -532,7 +533,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
Waypoint wpt = providerUtils.getWaypoint(2);
|
||||
assertEquals(getContext().getString(R.string.marker_statistics_icon_url), wpt.getIcon());
|
||||
assertEquals(getContext().getString(R.string.marker_split_name_format, 1), wpt.getName());
|
||||
assertEquals(Waypoint.TYPE_STATISTICS, wpt.getType());
|
||||
assertEquals(WaypointType.STATISTICS, wpt.getType());
|
||||
assertEquals(123L, wpt.getTrackId());
|
||||
assertEquals(0.0, wpt.getLength());
|
||||
assertNotNull(wpt.getLocation());
|
||||
@@ -564,7 +565,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
assertEquals(getContext().getString(R.string.marker_waypoint_icon_url),
|
||||
wpt.getIcon());
|
||||
assertEquals(getContext().getString(R.string.marker_name_format, 1), wpt.getName());
|
||||
assertEquals(Waypoint.TYPE_WAYPOINT, wpt.getType());
|
||||
assertEquals(WaypointType.WAYPOINT, wpt.getType());
|
||||
assertEquals(123L, wpt.getTrackId());
|
||||
assertEquals(0.0, wpt.getLength());
|
||||
assertNotNull(wpt.getLocation());
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
@@ -16,7 +8,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
@@ -74,7 +65,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=1585
|
||||
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent=1585|-1|1585
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>SignalStrengthSampler</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,292 +0,0 @@
|
||||
#Fri Oct 21 20:18:51 BRST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=100
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=2
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
@@ -1,4 +0,0 @@
|
||||
#Fri Oct 21 20:18:51 BRST 2011
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_MyTracks
|
||||
formatter_settings_version=12
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2010 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.apps.mytracks.signalstrength"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:icon="@drawable/icon"
|
||||
android:label="@string/app_name">
|
||||
<!-- Activity for configuring preferences -->
|
||||
<activity android:name=".SignalStrengthPreferences"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Receiver to know when recording starts/stops and act on the service accordingly -->
|
||||
<receiver android:name=".RecordingStateReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.apps.mytracks.TRACK_STARTED" />
|
||||
<action android:name="com.google.android.apps.mytracks.TRACK_STOPPED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Service which listens for signal strength and writes waypoints -->
|
||||
<service android:name=".SignalStrengthService"
|
||||
android:label="Signal Strength Sampling Service"
|
||||
android:icon="@drawable/icon"
|
||||
android:enabled="true" />
|
||||
</application>
|
||||
|
||||
<!-- Requirements -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="com.google.android.apps.mytracks.TRACK_NOTIFICATIONS" />
|
||||
<uses-permission android:name="com.google.android.apps.mytracks.WRITE_TRACK_DATA" />
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.telephony.gsm" android:required="false"/>
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<supports-screens android:xlargeScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true"
|
||||
android:anyDensity="true" />
|
||||
</manifest>
|
||||
@@ -1,34 +0,0 @@
|
||||
-optimizationpasses 5
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-verbose
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
proguard.config=proguard.cfg
|
||||
# Project target.
|
||||
target=android-15
|
||||
android.library.reference.1=../MyTracksLib
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2010 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<!-- Task frequency -->
|
||||
<string-array name="task_period_options">
|
||||
<item>As often as possible</item>
|
||||
<item>1 min</item>
|
||||
<item>2 min</item>
|
||||
<item>5 min</item>
|
||||
<item>10 min</item>
|
||||
<item>15 min</item>
|
||||
<item>30 min</item>
|
||||
<item>60 min</item>
|
||||
</string-array>
|
||||
|
||||
<!-- DO NOT TRANSLATE -->
|
||||
<string-array name="task_period_values">
|
||||
<item>-1</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>5</item>
|
||||
<item>10</item>
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2010 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Signal strength sampler for My Tracks</string>
|
||||
|
||||
<string name="settings_sampling">Sampling settings</string>
|
||||
<string name="settings_auto_start">Automatic start</string>
|
||||
<string name="settings_auto_start_summary_on">Automatically start inserting signal strength waypoints whenever My Tracks starts recording a track.</string>
|
||||
<string name="settings_auto_start_summary_off">You will need to manually start signal sampling using the controls below.</string>
|
||||
<string name="settings_auto_stop">Automatic stop</string>
|
||||
<string name="settings_auto_stop_summary_on">Automatically stop inserting signal strength waypoints whenever My Tracks stops recording a track.</string>
|
||||
<string name="settings_auto_stop_summary_off">You will need to manually stop signal sampling using the controls below.</string>
|
||||
<string name="settings_min_signal_sampling_period">Min. sampling period</string>
|
||||
<string name="settings_min_signal_sampling_period_summary">Minimum time between two recordings of the phone\'s signal strength</string>
|
||||
|
||||
<string name="settings_control">Sampling control</string>
|
||||
<string name="settings_control_start">Start sampling</string>
|
||||
<string name="settings_control_start_summary">Starts sampling signal strength immediately, if My Tracks is recording. Sampling will stop once My Tracks stops recording.</string>
|
||||
<string name="settings_control_stop">Stop sampling</string>
|
||||
<string name="settings_control_stop_summary">Stops sampling signal strength if sampling is currently active.</string>
|
||||
|
||||
<string name="started_sampling">Started sampling cell signal strength.</string>
|
||||
<string name="stopped_sampling">Stopped sampling cell signal strength.</string>
|
||||
<string name="unknown">-</string>
|
||||
|
||||
<!-- Signal Strength -->
|
||||
<string name="error_rate"> Error Rate: %1$d</string>
|
||||
<string name="signal_to_noise_ratio"> Signal to Noise Ratio: %1$d</string>
|
||||
<string name="ecio"> Ec/lo: %1$.1f dB</string>
|
||||
<string name="gsm_strength">GSM Strength: %1$d</string>
|
||||
<string name="cdma_strength">CDMA Strength: %1$d dBm</string>
|
||||
<string name="evdo_strength">EVDO Strength: %1$d dBm</string>
|
||||
|
||||
<!-- Non-translatable strings -->
|
||||
<string name="settings_auto_start_key">autoStartSampling</string>
|
||||
<string name="settings_auto_stop_key">autoStopSampling</string>
|
||||
<string name="settings_min_signal_sampling_period_key">signalSamplingFrequency</string>
|
||||
<string name="settings_control_start_key">startSamplingControl</string>
|
||||
<string name="settings_control_stop_key">stopSamplingControl</string>
|
||||
</resources>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2010 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/settings_sampling">
|
||||
<CheckBoxPreference android:key="@string/settings_auto_start_key"
|
||||
android:title="@string/settings_auto_start"
|
||||
android:summaryOn="@string/settings_auto_start_summary_on"
|
||||
android:summaryOff="@string/settings_auto_start_summary_off"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference android:key="@string/settings_auto_stop_key"
|
||||
android:title="@string/settings_auto_stop"
|
||||
android:summaryOn="@string/settings_auto_stop_summary_on"
|
||||
android:summaryOff="@string/settings_auto_stop_summary_off"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/settings_min_signal_sampling_period_key"
|
||||
android:title="@string/settings_min_signal_sampling_period"
|
||||
android:summary="@string/settings_min_signal_sampling_period_summary"
|
||||
android:entries="@array/task_period_options"
|
||||
android:entryValues="@array/task_period_values"
|
||||
android:defaultValue="-1" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_control">
|
||||
<Preference android:key="@string/settings_control_start_key"
|
||||
android:title="@string/settings_control_start"
|
||||
android:summary="@string/settings_control_start_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<Preference android:key="@string/settings_control_stop_key"
|
||||
android:title="@string/settings_control_stop"
|
||||
android:summary="@string/settings_control_stop_summary"
|
||||
android:persistent="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.*;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Broadcast listener which gets notified when we start or stop recording a track.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class RecordingStateReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context ctx, Intent intent) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
|
||||
String action = intent.getAction();
|
||||
if (ctx.getString(R.string.track_started_broadcast_action).equals(action)) {
|
||||
boolean autoStart = preferences.getBoolean(
|
||||
ctx.getString(R.string.settings_auto_start_key), false);
|
||||
if (!autoStart) {
|
||||
Log.d(TAG, "Not auto-starting signal sampling");
|
||||
return;
|
||||
}
|
||||
|
||||
startService(ctx);
|
||||
} else if (ctx.getString(R.string.track_stopped_broadcast_action).equals(action)) {
|
||||
boolean autoStop = preferences.getBoolean(
|
||||
ctx.getString(R.string.settings_auto_stop_key), true);
|
||||
if (!autoStop) {
|
||||
Log.d(TAG, "Not auto-stopping signal sampling");
|
||||
return;
|
||||
}
|
||||
|
||||
stopService(ctx);
|
||||
} else {
|
||||
Log.e(TAG, "Unknown action received: " + action);
|
||||
}
|
||||
}
|
||||
|
||||
// @VisibleForTesting
|
||||
protected void stopService(Context ctx) {
|
||||
SignalStrengthService.stopService(ctx);
|
||||
}
|
||||
|
||||
// @VisibleForTesting
|
||||
protected void startService(Context ctx) {
|
||||
SignalStrengthService.startService(ctx);
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
/**
|
||||
* Constants for the signal sampler.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class SignalStrengthConstants {
|
||||
public static final String START_SAMPLING =
|
||||
"com.google.android.apps.mytracks.signalstrength.START";
|
||||
public static final String STOP_SAMPLING =
|
||||
"com.google.android.apps.mytracks.signalstrength.STOP";
|
||||
|
||||
public static final int ANDROID_API_LEVEL = Integer.parseInt(
|
||||
Build.VERSION.SDK);
|
||||
|
||||
public static final String TAG = "SignalStrengthSampler";
|
||||
|
||||
private SignalStrengthConstants() {}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
/**
|
||||
* Interface for the service that reads signal strength.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public interface SignalStrengthListener {
|
||||
/**
|
||||
* Interface for getting notified about a new sampled signal strength.
|
||||
*/
|
||||
public interface SignalStrengthCallback {
|
||||
void onSignalStrengthSampled(
|
||||
String description,
|
||||
String icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts listening to signal strength.
|
||||
*/
|
||||
void register();
|
||||
|
||||
/**
|
||||
* Stops listening to signal strength.
|
||||
*/
|
||||
void unregister();
|
||||
}
|
||||
-224
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.TAG;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.telephony.CellLocation;
|
||||
import android.telephony.NeighboringCellInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A class to monitor the network signal strength.
|
||||
*
|
||||
* TODO: i18n
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class SignalStrengthListenerCupcake extends PhoneStateListener
|
||||
implements SignalStrengthListener {
|
||||
private static final Uri APN_URI = Uri.parse("content://telephony/carriers");
|
||||
|
||||
private final Context context;
|
||||
private final SignalStrengthCallback callback;
|
||||
|
||||
private TelephonyManager manager;
|
||||
private int signalStrength = -1;
|
||||
|
||||
public SignalStrengthListenerCupcake(Context context, SignalStrengthCallback callback) {
|
||||
this.context = context;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (manager == null) {
|
||||
Log.e(TAG, "Cannot get telephony manager.");
|
||||
} else {
|
||||
manager.listen(this, getListenEvents());
|
||||
}
|
||||
}
|
||||
|
||||
protected int getListenEvents() {
|
||||
return PhoneStateListener.LISTEN_SIGNAL_STRENGTH;
|
||||
}
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
@Override
|
||||
public void onSignalStrengthChanged(int signalStrength) {
|
||||
Log.d(TAG, "Signal Strength: " + signalStrength);
|
||||
this.signalStrength = signalStrength;
|
||||
|
||||
notifySignalSampled();
|
||||
}
|
||||
|
||||
protected void notifySignalSampled() {
|
||||
int networkType = manager.getNetworkType();
|
||||
callback.onSignalStrengthSampled(getDescription(), getIcon(networkType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a human readable description for the network type.
|
||||
*
|
||||
* @param type The integer constant for the network type
|
||||
* @return A human readable description of the network type
|
||||
*/
|
||||
protected String getTypeAsString(int type) {
|
||||
switch (type) {
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
return "EDGE";
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
return "GPRS";
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
return "UMTS";
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a description for the current signal strength.
|
||||
*
|
||||
* @return A human readable description of the network state
|
||||
*/
|
||||
private String getDescription() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getStrengthAsString());
|
||||
|
||||
sb.append("Network Type: ");
|
||||
sb.append(getTypeAsString(manager.getNetworkType()));
|
||||
sb.append('\n');
|
||||
|
||||
sb.append("Operator: ");
|
||||
sb.append(manager.getNetworkOperatorName());
|
||||
sb.append(" / ");
|
||||
sb.append(manager.getNetworkOperator());
|
||||
sb.append('\n');
|
||||
|
||||
sb.append("Roaming: ");
|
||||
sb.append(manager.isNetworkRoaming());
|
||||
sb.append('\n');
|
||||
|
||||
appendCurrentApns(sb);
|
||||
|
||||
List<NeighboringCellInfo> infos = manager.getNeighboringCellInfo();
|
||||
Log.i(TAG, "Found " + infos.size() + " cells.");
|
||||
if (infos.size() > 0) {
|
||||
sb.append("Neighbors: ");
|
||||
for (NeighboringCellInfo info : infos) {
|
||||
sb.append(info.toString());
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append('\n');
|
||||
}
|
||||
|
||||
CellLocation cell = manager.getCellLocation();
|
||||
if (cell != null) {
|
||||
sb.append("Cell: ");
|
||||
sb.append(cell.toString());
|
||||
sb.append('\n');
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void appendCurrentApns(StringBuilder output) {
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
|
||||
Cursor cursor = contentResolver.query(
|
||||
APN_URI, new String[] { "name", "apn" }, "current=1", null, null);
|
||||
|
||||
if (cursor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String name = null;
|
||||
String apn = null;
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
int nameIdx = cursor.getColumnIndex("name");
|
||||
int apnIdx = cursor.getColumnIndex("apn");
|
||||
if (apnIdx < 0 || nameIdx < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name = cursor.getString(nameIdx);
|
||||
apn = cursor.getString(apnIdx);
|
||||
output.append("APN: ");
|
||||
if (name != null) {
|
||||
output.append(name);
|
||||
}
|
||||
if (apn != null) {
|
||||
output.append(" (");
|
||||
output.append(apn);
|
||||
output.append(")\n");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url for the waypoint icon for the current network type.
|
||||
*
|
||||
* @param type The network type
|
||||
* @return A url to a image to use as the waypoint icon
|
||||
*/
|
||||
protected String getIcon(int type) {
|
||||
switch (type) {
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/green.png";
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/blue.png";
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/red.png";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (manager != null) {
|
||||
manager.listen(this, PhoneStateListener.LISTEN_NONE);
|
||||
manager = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getStrengthAsString() {
|
||||
return "Strength: " + signalStrength + "\n";
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public SignalStrengthCallback getSignalStrengthCallback() {
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
-158
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* A class to monitor the network signal strength.
|
||||
*
|
||||
* TODO: i18n
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class SignalStrengthListenerEclair extends SignalStrengthListenerCupcake {
|
||||
|
||||
private SignalStrength signalStrength = null;
|
||||
|
||||
public SignalStrengthListenerEclair(Context ctx, SignalStrengthCallback callback) {
|
||||
super(ctx, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getListenEvents() {
|
||||
return PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
|
||||
}
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
@Override
|
||||
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
|
||||
Log.d(TAG, "Signal Strength Modern: " + signalStrength);
|
||||
this.signalStrength = signalStrength;
|
||||
notifySignalSampled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a human readable description for the network type.
|
||||
*
|
||||
* @param type The integer constant for the network type
|
||||
* @return A human readable description of the network type
|
||||
*/
|
||||
@Override
|
||||
protected String getTypeAsString(int type) {
|
||||
switch (type) {
|
||||
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
||||
return "1xRTT";
|
||||
case TelephonyManager.NETWORK_TYPE_CDMA:
|
||||
return "CDMA";
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
return "EDGE";
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
||||
return "EVDO 0";
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
||||
return "EVDO A";
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
return "GPRS";
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
return "HSDPA";
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
return "HSPA";
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
return "HSUPA";
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
return "UMTS";
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url for the waypoint icon for the current network type.
|
||||
*
|
||||
* @param type The network type
|
||||
* @return A url to a image to use as the waypoint icon
|
||||
*/
|
||||
@Override
|
||||
protected String getIcon(int type) {
|
||||
switch (type) {
|
||||
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
||||
case TelephonyManager.NETWORK_TYPE_CDMA:
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/green.png";
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/blue.png";
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "http://maps.google.com/mapfiles/ms/micons/red.png";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStrengthAsString() {
|
||||
if (signalStrength == null) {
|
||||
return "Strength: " + getContext().getString(R.string.unknown) + "\n";
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (signalStrength.isGsm()) {
|
||||
appendSignal(signalStrength.getGsmSignalStrength(),
|
||||
R.string.gsm_strength,
|
||||
sb);
|
||||
maybeAppendSignal(signalStrength.getGsmBitErrorRate(),
|
||||
R.string.error_rate,
|
||||
sb);
|
||||
} else {
|
||||
appendSignal(signalStrength.getCdmaDbm(), R.string.cdma_strength, sb);
|
||||
appendSignal(signalStrength.getCdmaEcio() / 10.0, R.string.ecio, sb);
|
||||
appendSignal(signalStrength.getEvdoDbm(), R.string.evdo_strength, sb);
|
||||
appendSignal(signalStrength.getEvdoEcio() / 10.0, R.string.ecio, sb);
|
||||
appendSignal(signalStrength.getEvdoSnr(),
|
||||
R.string.signal_to_noise_ratio,
|
||||
sb);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void maybeAppendSignal(
|
||||
int signal, int signalFormat, StringBuffer sb) {
|
||||
if (signal > 0) {
|
||||
sb.append(getContext().getString(signalFormat, signal));
|
||||
}
|
||||
}
|
||||
|
||||
private void appendSignal(int signal, int signalFormat, StringBuffer sb) {
|
||||
sb.append(getContext().getString(signalFormat, signal));
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
private void appendSignal(double signal, int signalFormat, StringBuffer sb) {
|
||||
sb.append(getContext().getString(signalFormat, signal));
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.*;
|
||||
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Factory for producing a proper {@link SignalStrengthListenerCupcake} according to the
|
||||
* current API level.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class SignalStrengthListenerFactory {
|
||||
|
||||
public SignalStrengthListener create(Context context, SignalStrengthCallback callback) {
|
||||
if (hasModernSignalStrength()) {
|
||||
Log.d(TAG, "TrackRecordingService using modern signal strength api.");
|
||||
return new SignalStrengthListenerEclair(context, callback);
|
||||
} else {
|
||||
Log.w(TAG, "TrackRecordingService using legacy signal strength api.");
|
||||
return new SignalStrengthListenerCupcake(context, callback);
|
||||
}
|
||||
}
|
||||
|
||||
// @VisibleForTesting
|
||||
protected boolean hasModernSignalStrength() {
|
||||
return ANDROID_API_LEVEL >= 7;
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
/**
|
||||
* Main signal strength sampler activity, which displays preferences.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class SignalStrengthPreferences extends PreferenceActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
// Attach service control funciontality
|
||||
findPreference(getString(R.string.settings_control_start_key))
|
||||
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SignalStrengthService.startService(SignalStrengthPreferences.this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.settings_control_stop_key))
|
||||
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SignalStrengthService.stopService(SignalStrengthPreferences.this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Check that my tracks is installed - if not, give a warning and
|
||||
// offer to go to the android market.
|
||||
}
|
||||
}
|
||||
-256
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength;
|
||||
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.START_SAMPLING;
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.STOP_SAMPLING;
|
||||
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.TAG;
|
||||
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Serivce which actually reads signal strength and sends it to My Tracks.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class SignalStrengthService extends Service
|
||||
implements ServiceConnection, SignalStrengthCallback, OnSharedPreferenceChangeListener {
|
||||
|
||||
private ComponentName mytracksServiceComponent;
|
||||
private SharedPreferences preferences;
|
||||
private SignalStrengthListenerFactory signalListenerFactory;
|
||||
private SignalStrengthListener signalListener;
|
||||
private ITrackRecordingService mytracksService;
|
||||
private long lastSamplingTime;
|
||||
private long samplingPeriod;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
mytracksServiceComponent = new ComponentName(
|
||||
getString(R.string.mytracks_service_package),
|
||||
getString(R.string.mytracks_service_class));
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
signalListenerFactory = new SignalStrengthListenerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
handleCommand(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
handleCommand(intent);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void handleCommand(Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (START_SAMPLING.equals(action)) {
|
||||
startSampling();
|
||||
} else {
|
||||
stopSampling();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSampling() {
|
||||
// TODO: Start foreground
|
||||
|
||||
if (!isMytracksRunning()) {
|
||||
Log.w(TAG, "My Tracks not running!");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Starting sampling");
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(mytracksServiceComponent);
|
||||
if (!bindService(intent, SignalStrengthService.this, 0)) {
|
||||
Log.e(TAG, "Couldn't bind to service.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMytracksRunning() {
|
||||
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||
List<RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
|
||||
for (RunningServiceInfo serviceInfo : services) {
|
||||
if (serviceInfo.pid != 0 &&
|
||||
serviceInfo.service.equals(mytracksServiceComponent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
synchronized (this) {
|
||||
mytracksService = ITrackRecordingService.Stub.asInterface(service);
|
||||
|
||||
Log.d(TAG, "Bound to My Tracks");
|
||||
|
||||
boolean recording = false;
|
||||
try {
|
||||
recording = mytracksService.isRecording();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to talk to my tracks", e);
|
||||
}
|
||||
if (!recording) {
|
||||
Log.w(TAG, "My Tracks is not recording, bailing");
|
||||
stopSampling();
|
||||
return;
|
||||
}
|
||||
|
||||
// We're ready to send waypoints, so register for signal sampling
|
||||
signalListener = signalListenerFactory.create(this, this);
|
||||
signalListener.register();
|
||||
|
||||
// Register for preference changes
|
||||
samplingPeriod = Long.parseLong(preferences.getString(
|
||||
getString(R.string.settings_min_signal_sampling_period_key), "-1"));
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
// Tell the user we've started.
|
||||
Toast.makeText(this, R.string.started_sampling, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignalStrengthSampled(String description, String icon) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - lastSamplingTime < samplingPeriod * 60 * 1000) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
long waypointId;
|
||||
synchronized (this) {
|
||||
if (mytracksService == null) {
|
||||
Log.d(TAG, "No my tracks service to send to");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a waypoint.
|
||||
WaypointCreationRequest request =
|
||||
new WaypointCreationRequest(WaypointCreationRequest.WaypointType.MARKER,
|
||||
"Signal Strength", description, icon);
|
||||
waypointId = mytracksService.insertWaypoint(request);
|
||||
}
|
||||
|
||||
if (waypointId >= 0) {
|
||||
Log.d(TAG, "Added signal marker");
|
||||
lastSamplingTime = now;
|
||||
} else {
|
||||
Log.e(TAG, "Cannot insert waypoint marker?");
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Cannot talk to my tracks service", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopSampling() {
|
||||
Log.d(TAG, "Stopping sampling");
|
||||
|
||||
synchronized (this) {
|
||||
// Unregister from preference change updates
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
// Unregister from receiving signal updates
|
||||
if (signalListener != null) {
|
||||
signalListener.unregister();
|
||||
signalListener = null;
|
||||
}
|
||||
|
||||
// Unbind from My Tracks
|
||||
if (mytracksService != null) {
|
||||
unbindService(this);
|
||||
mytracksService = null;
|
||||
}
|
||||
|
||||
// Reset the last sampling time
|
||||
lastSamplingTime = 0;
|
||||
|
||||
// Tell the user we've stopped
|
||||
Toast.makeText(this, R.string.stopped_sampling, Toast.LENGTH_SHORT).show();
|
||||
|
||||
// Stop
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.i(TAG, "Disconnected from My Tracks");
|
||||
synchronized (this) {
|
||||
mytracksService = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
stopSampling();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(
|
||||
SharedPreferences sharedPreferences, String key) {
|
||||
if (getString(R.string.settings_min_signal_sampling_period_key).equals(key)) {
|
||||
samplingPeriod = Long.parseLong(sharedPreferences.getString(key, "-1"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void startService(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, SignalStrengthService.class);
|
||||
intent.setAction(START_SAMPLING);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
public static void stopService(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, SignalStrengthService.class);
|
||||
intent.setAction(STOP_SAMPLING);
|
||||
context.startService(intent);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SignalStrengthSampler"/>
|
||||
<classpathentry kind="lib" path="libs/AndroidMockGenerator.jar"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>SignalStrengthSamplerTest</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>SignalStrengthSampler</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,292 +0,0 @@
|
||||
#Fri Oct 21 20:18:56 BRST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=48
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=100
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=2
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
@@ -1,4 +0,0 @@
|
||||
#Fri Oct 21 20:18:56 BRST 2011
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_MyTracks
|
||||
formatter_settings_version=12
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.apps.mytracks.signalstrength.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:label="Signal Strenght Sampler Test">
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<instrumentation android:targetPackage="com.google.android.apps.mytracks.signalstrength"
|
||||
android:name="android.test.InstrumentationTestRunner" />
|
||||
</manifest>
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,11 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-15
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength.test;
|
||||
|
||||
import com.google.android.apps.mytracks.signalstrength.R;
|
||||
import com.google.android.apps.mytracks.signalstrength.RecordingStateReceiver;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.RenamingDelegatingContext;
|
||||
|
||||
/**
|
||||
* Tests for {@link RecordingStateReceiver}.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class RecordingStateReceiverTest extends AndroidTestCase {
|
||||
|
||||
private RecordingStateReceiver receiver;
|
||||
private RenamingDelegatingContext context;
|
||||
private SharedPreferences preferences;
|
||||
private int serviceStopCalls;
|
||||
private int serviceStartCalls;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
context = new RenamingDelegatingContext(getContext(), "test.");
|
||||
setContext(context);
|
||||
|
||||
receiver = new RecordingStateReceiver() {
|
||||
@Override
|
||||
protected void stopService(Context ctx) {
|
||||
serviceStopCalls++;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startService(Context ctx) {
|
||||
serviceStartCalls++;
|
||||
}
|
||||
};
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
preferences
|
||||
.edit()
|
||||
.putBoolean(context.getString(R.string.settings_auto_start_key), true)
|
||||
.putBoolean(context.getString(R.string.settings_auto_stop_key), true)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void testOnReceive_start() {
|
||||
receiver.onReceive(context,
|
||||
new Intent(context.getString(R.string.track_started_broadcast_action)));
|
||||
assertServiceCalls(1, 0);
|
||||
}
|
||||
|
||||
public void testOnReceive_stop() {
|
||||
receiver.onReceive(context,
|
||||
new Intent(context.getString(R.string.track_stopped_broadcast_action)));
|
||||
assertServiceCalls(0, 1);
|
||||
}
|
||||
|
||||
public void testOnReceive_noAutoStart() {
|
||||
preferences
|
||||
.edit()
|
||||
.putBoolean(context.getString(R.string.settings_auto_start_key), false)
|
||||
.commit();
|
||||
receiver.onReceive(context,
|
||||
new Intent(context.getString(R.string.track_started_broadcast_action)));
|
||||
assertServiceCalls(0, 0);
|
||||
}
|
||||
|
||||
public void testOnReceive_noAutoStop() {
|
||||
preferences
|
||||
.edit()
|
||||
.putBoolean(context.getString(R.string.settings_auto_stop_key), false)
|
||||
.commit();
|
||||
receiver.onReceive(context,
|
||||
new Intent(context.getString(R.string.track_stopped_broadcast_action)));
|
||||
assertServiceCalls(0, 0);
|
||||
}
|
||||
|
||||
public void testOnReceive_other() {
|
||||
receiver.onReceive(context, new Intent("bla"));
|
||||
assertServiceCalls(0, 0);
|
||||
}
|
||||
|
||||
private void assertServiceCalls(int startCalls, int stopCalls) {
|
||||
assertEquals(startCalls, serviceStartCalls);
|
||||
assertEquals(stopCalls, serviceStopCalls);
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.signalstrength.test;
|
||||
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener;
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback;
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListenerCupcake;
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListenerEclair;
|
||||
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListenerFactory;
|
||||
import com.google.android.testing.mocking.AndroidMock;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
/**
|
||||
* Tests for {@link SignalStrengthListenerFactory}.
|
||||
* These tests require Eclair+ (API level 7) to run.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class SignalStrengthListenerFactoryTest extends AndroidTestCase {
|
||||
private boolean hasModernSignalStrength;
|
||||
private TestableSignalStrengthListenerFactory factory;
|
||||
private SignalStrengthCallback callback;
|
||||
|
||||
private class TestableSignalStrengthListenerFactory extends SignalStrengthListenerFactory {
|
||||
@Override
|
||||
protected boolean hasModernSignalStrength() {
|
||||
return hasModernSignalStrength;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
factory = new TestableSignalStrengthListenerFactory();
|
||||
callback = AndroidMock.createMock(SignalStrengthCallback.class);
|
||||
}
|
||||
|
||||
public void testCreate_eclair() {
|
||||
hasModernSignalStrength = true;
|
||||
|
||||
SignalStrengthListener listener = factory.create(getContext(), callback);
|
||||
assertTrue(listener.getClass().getName(),
|
||||
listener instanceof SignalStrengthListenerEclair);
|
||||
}
|
||||
|
||||
public void testCreate_legacy() {
|
||||
hasModernSignalStrength = false;
|
||||
|
||||
SignalStrengthListener listener = factory.create(getContext(), callback);
|
||||
assertTrue(listener.getClass().getName(),
|
||||
listener instanceof SignalStrengthListenerCupcake);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user