forked from upstream-mirrors/OpenTracks
Minor cleanup.
This commit is contained in:
@@ -26,17 +26,6 @@ public abstract class Constants {
|
||||
* Should be used by all log statements
|
||||
*/
|
||||
public static final String TAG = "MyTracks";
|
||||
|
||||
/**
|
||||
* Name of the gps location provider:
|
||||
*/
|
||||
public static final String GPS_PROVIDER = "gps";
|
||||
|
||||
/** Maximum age of a GPS location to be considered current. */
|
||||
public static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute
|
||||
|
||||
/** Maximum age of a network location to be considered current. */
|
||||
public static final long MAX_NETWORK_AGE_MS = 1000 * 60 * 10; // 10 minutes
|
||||
|
||||
/**
|
||||
* Name of the top-level directory inside the SD card where our files will
|
||||
@@ -180,6 +169,12 @@ public abstract class Constants {
|
||||
*/
|
||||
public static final double MAX_ACCELERATION = 0.02;
|
||||
|
||||
/** Maximum age of a GPS location to be considered current. */
|
||||
public static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute
|
||||
|
||||
/** Maximum age of a network location to be considered current. */
|
||||
public static final long MAX_NETWORK_AGE_MS = 1000 * 60 * 10; // 10 minutes
|
||||
|
||||
/**
|
||||
* The type of account that we can use for gdata uploads.
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
@@ -504,7 +505,7 @@ public class MapActivity extends com.google.android.maps.MapActivity
|
||||
|
||||
@Override
|
||||
public void onCurrentLocationChanged(Location location) {
|
||||
if (!location.getProvider().equals(Constants.GPS_PROVIDER)) {
|
||||
if (!location.getProvider().equals(LocationManager.GPS_PROVIDER)) {
|
||||
Log.d(TAG,
|
||||
"MapActivity: Network location update received (provider '" + location.getProvider() + "'.");
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class TrackDataHub {
|
||||
|
||||
/** Set of internal listeners which are already registered. */
|
||||
private final Set<ListenerDataType> registeredInternalListeners =
|
||||
EnumSet.noneOf(ListenerDataType.class);
|
||||
EnumSet.noneOf(ListenerDataType.class);
|
||||
|
||||
/** Map of external listener to its registration details. */
|
||||
private final Map<TrackDataListener, ListenerRegistration> registeredListeners =
|
||||
@@ -298,10 +298,6 @@ public class TrackDataHub {
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param ctx
|
||||
* @param preferences
|
||||
* @param providerUtils
|
||||
*/
|
||||
public TrackDataHub(Context ctx, SharedPreferences preferences,
|
||||
MyTracksProviderUtils providerUtils) {
|
||||
@@ -310,12 +306,8 @@ public class TrackDataHub {
|
||||
|
||||
/**
|
||||
* Injection constructor.
|
||||
*
|
||||
* @param ctx
|
||||
* @param dataSources
|
||||
* @param preferences
|
||||
* @param providerUtils
|
||||
*/
|
||||
// @VisibleForTesting
|
||||
TrackDataHub(Context ctx, TrackDataSources dataSources, SharedPreferences preferences,
|
||||
MyTracksProviderUtils providerUtils) {
|
||||
this.context = ctx;
|
||||
|
||||
@@ -104,9 +104,9 @@ class TrackDataSourcesImpl implements TrackDataSources {
|
||||
@Override
|
||||
public void requestLocationUpdates(LocationListener listener) {
|
||||
// Check if the provider exists.
|
||||
LocationProvider gpsProvider = locationManager.getProvider(Constants.GPS_PROVIDER);
|
||||
LocationProvider gpsProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
|
||||
if (gpsProvider == null) {
|
||||
listener.onProviderDisabled(Constants.GPS_PROVIDER);
|
||||
listener.onProviderDisabled(LocationManager.GPS_PROVIDER);
|
||||
locationManager.removeUpdates(listener);
|
||||
return;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class TrackDataSourcesImpl implements TrackDataSources {
|
||||
// TODO: Let's look at more advanced algorithms to determine the best
|
||||
// current location.
|
||||
|
||||
Location loc = locationManager.getLastKnownLocation(Constants.GPS_PROVIDER);
|
||||
Location loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
final long now = System.currentTimeMillis();
|
||||
if (loc == null || loc.getTime() < now - MAX_LOCATION_AGE_MS) {
|
||||
// We don't have a recent GPS fix, just use cell towers if available
|
||||
|
||||
@@ -387,7 +387,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
try {
|
||||
long desiredInterval = locationListenerPolicy.getDesiredPollingInterval();
|
||||
locationManager.requestLocationUpdates(
|
||||
Constants.GPS_PROVIDER, desiredInterval,
|
||||
LocationManager.GPS_PROVIDER, desiredInterval,
|
||||
locationListenerPolicy.getMinDistance(),
|
||||
// , 0 /* minDistance, get all updates to properly time pauses */
|
||||
TrackRecordingService.this);
|
||||
@@ -597,7 +597,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
if (startNewSegment) {
|
||||
// Insert a separator point to indicate start of new track:
|
||||
Log.d(TAG, "Inserting a separator.");
|
||||
Location separator = new Location(Constants.GPS_PROVIDER);
|
||||
Location separator = new Location(LocationManager.GPS_PROVIDER);
|
||||
separator.setLongitude(0);
|
||||
separator.setLatitude(100);
|
||||
separator.setTime(lastRecordedLocation.getTime());
|
||||
|
||||
Reference in New Issue
Block a user