diff options
Diffstat (limited to 'main/src/cgeo/geocaching/sensors/GeoData.java')
| -rw-r--r-- | main/src/cgeo/geocaching/sensors/GeoData.java | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/main/src/cgeo/geocaching/sensors/GeoData.java b/main/src/cgeo/geocaching/sensors/GeoData.java index c0b3974..1291d3c 100644 --- a/main/src/cgeo/geocaching/sensors/GeoData.java +++ b/main/src/cgeo/geocaching/sensors/GeoData.java @@ -6,18 +6,14 @@ import cgeo.geocaching.geopoint.Geopoint; import android.location.Location; import android.location.LocationManager; -class GeoData extends Location implements IGeoData { - private final boolean gpsEnabled; - private final int satellitesVisible; - private final int satellitesFixed; - private final boolean pseudoLocation; +public class GeoData extends Location implements IGeoData { - GeoData(final Location location, final boolean gpsEnabled, final int satellitesVisible, final int satellitesFixed, final boolean pseudoLocation) { + public static final String INITIAL_PROVIDER = "initial"; + public static final String FUSED_PROVIDER = "fused"; + public static final String LOW_POWER_PROVIDER = "low-power"; + + public GeoData(final Location location) { super(location); - this.gpsEnabled = gpsEnabled; - this.satellitesVisible = satellitesVisible; - this.satellitesFixed = satellitesFixed; - this.pseudoLocation = pseudoLocation; } @Override @@ -32,6 +28,13 @@ class GeoData extends Location implements IGeoData { if (provider.equals(LocationManager.NETWORK_PROVIDER)) { return LocationProviderType.NETWORK; } + // LocationManager.FUSED_PROVIDER constant is not available at API level 9 + if (provider.equals(FUSED_PROVIDER)) { + return LocationProviderType.FUSED; + } + if (provider.equals(LOW_POWER_PROVIDER)) { + return LocationProviderType.LOW_POWER; + } return LocationProviderType.LAST; } @@ -45,23 +48,13 @@ class GeoData extends Location implements IGeoData { return new Geopoint(this); } - @Override - public boolean getGpsEnabled() { - return gpsEnabled; - } - - @Override - public int getSatellitesVisible() { - return satellitesVisible; - } - - @Override - public int getSatellitesFixed() { - return satellitesFixed; - } - - @Override - public boolean isPseudoLocation() { - return pseudoLocation; + // Some devices will not have the last position available (for example the emulator). In this case, + // rather than waiting forever for a position update which might never come, we emulate it by placing + // the user arbitrarly at Paris Notre-Dame, one of the most visited free tourist attractions in the world. + public static GeoData dummyLocation() { + final Location location = new Location(INITIAL_PROVIDER); + location.setLatitude(48.85308); + location.setLongitude(2.34962); + return new GeoData(location); } } |
