aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/AboutActivity.java2
-rw-r--r--main/src/cgeo/geocaching/CompassActivity.java2
-rw-r--r--main/src/cgeo/geocaching/sensors/Sensors.java16
3 files changed, 9 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/AboutActivity.java b/main/src/cgeo/geocaching/AboutActivity.java
index d7d60d2..ceafc31 100644
--- a/main/src/cgeo/geocaching/AboutActivity.java
+++ b/main/src/cgeo/geocaching/AboutActivity.java
@@ -266,7 +266,7 @@ public class AboutActivity extends AbstractViewPagerActivity<AboutActivity.Page>
}
body
.append("\nLow power mode: ").append(Settings.useLowPowerMode() ? "active" : "inactive")
- .append("\nMagnetic field sensor: ").append(presence(Sensors.getInstance().hasMagneticFieldSensor()))
+ .append("\nCompass capabilities: ").append(Sensors.getInstance().hasCompassCapabilities() ? "yes" : "no")
.append("\nRotation sensor: ").append(presence(RotationProvider.hasRotationSensor(context)))
.append("\nGeomagnetic rotation sensor: ").append(presence(RotationProvider.hasGeomagneticRotationSensor(context)))
.append("\nOrientation sensor: ").append(presence(OrientationProvider.hasOrientationSensor(context)))
diff --git a/main/src/cgeo/geocaching/CompassActivity.java b/main/src/cgeo/geocaching/CompassActivity.java
index 8b0fc73..27dbb4a 100644
--- a/main/src/cgeo/geocaching/CompassActivity.java
+++ b/main/src/cgeo/geocaching/CompassActivity.java
@@ -139,7 +139,7 @@ public class CompassActivity extends AbstractActionBarActivity {
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.compass_activity_options, menu);
- menu.findItem(R.id.menu_compass_sensor).setVisible(Sensors.getInstance().hasMagneticFieldSensor());
+ menu.findItem(R.id.menu_compass_sensor).setVisible(Sensors.getInstance().hasCompassCapabilities());
if (cache != null) {
LoggingUI.addMenuItems(this, menu, cache);
}
diff --git a/main/src/cgeo/geocaching/sensors/Sensors.java b/main/src/cgeo/geocaching/sensors/Sensors.java
index 498ec0e..80ed175 100644
--- a/main/src/cgeo/geocaching/sensors/Sensors.java
+++ b/main/src/cgeo/geocaching/sensors/Sensors.java
@@ -15,8 +15,6 @@ import rx.functions.Action1;
import rx.functions.Func1;
import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.SensorManager;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -29,7 +27,7 @@ public class Sensors {
@NonNull private volatile GeoData currentGeo = GeoData.DUMMY_LOCATION;
private volatile float currentDirection = 0.0f;
private volatile boolean hasValidLocation = false;
- private final boolean hasMagneticFieldSensor;
+ private final boolean hasCompassCapabilities;
private final CgeoApplication app = CgeoApplication.getInstance();
private static class InstanceHolder {
@@ -53,8 +51,8 @@ public class Sensors {
private Sensors() {
gpsStatusObservable = GpsStatusProvider.create(app).replay(1).refCount();
- final SensorManager sensorManager = (SensorManager) app.getSystemService(Context.SENSOR_SERVICE);
- hasMagneticFieldSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null;
+ final Context context = CgeoApplication.getInstance().getApplicationContext();
+ hasCompassCapabilities = RotationProvider.hasRotationSensor(context) || OrientationProvider.hasOrientationSensor(context);
}
public static final Sensors getInstance() {
@@ -84,8 +82,8 @@ public class Sensors {
public void setupDirectionObservable(final boolean useLowPower) {
// If we have no magnetic sensor, there is no point in trying to setup any, we will always get the direction from the GPS.
- if (!hasMagneticFieldSensor) {
- Log.i("No magnetic field sensor, using only the GPS for the orientation");
+ if (!hasCompassCapabilities) {
+ Log.i("No compass capabilities, using only the GPS for the orientation");
directionObservable = RxUtils.rememberLast(geoDataObservableLowPower.map(GPS_TO_DIRECTION).doOnNext(onNextrememberDirectionAction), 0f);
return;
}
@@ -153,8 +151,8 @@ public class Sensors {
return currentDirection;
}
- public boolean hasMagneticFieldSensor() {
- return hasMagneticFieldSensor;
+ public boolean hasCompassCapabilities() {
+ return hasCompassCapabilities;
}
}