@@ -0,0 +1,2199 @@
+package cgeo.geocaching.sensors;%0A%0Aimport cgeo.geocaching.utils.Log;%0Aimport cgeo.geocaching.utils.RxUtils.LooperCallbacks;%0A%0Aimport rx.Observable;%0A%0Aimport android.content.Context;%0Aimport android.hardware.Sensor;%0Aimport android.hardware.SensorEvent;%0Aimport android.hardware.SensorEventListener;%0Aimport android.hardware.SensorManager;%0A%0Apublic class RotationProvider extends LooperCallbacks%3CFloat%3E implements SensorEventListener %7B%0A%0A    private final SensorManager sensorManager;%0A    private final Sensor rotationSensor;%0A    private final float%5B%5D rotationMatrix = new float%5B16%5D;%0A    private final float%5B%5D orientation = new float%5B4%5D;%0A%0A    protected RotationProvider(final Context context) %7B%0A        sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);%0A        rotationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);%0A        if (rotationSensor != null) %7B%0A            Log.d(%22RotationProvider: sensor found%22);%0A        %7D else %7B%0A            Log.w(%22RotationProvider: no rotation sensor on this device%22);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onSensorChanged(final SensorEvent event) %7B%0A        SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values);%0A        SensorManager.getOrientation(rotationMatrix, orientation);%0A        subscriber.onNext((float) (orientation%5B0%5D * 180 / Math.PI));%0A    %7D%0A%0A    @Override%0A    public void onAccuracyChanged(final Sensor sensor, final int accuracy) %7B%0A    %7D%0A%0A    @Override%0A    public void onStart() %7B%0A        if (rotationSensor != null) %7B%0A            Log.d(%22RotationProvider: starting the rotation provider%22);%0A            sensorManager.registerListener(this, rotationSensor, SensorManager.SENSOR_DELAY_NORMAL);%0A        %7D else %7B%0A            subscriber.onError(new RuntimeException(%22rotation sensor is absent on this device%22));%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onStop() %7B%0A        if (rotationSensor != null) %7B%0A            Log.d(%22RotationProvider: stopping the rotation provider%22);%0A            sensorManager.unregisterListener(this);%0A        %7D%0A    %7D%0A%0A    public static Observable%3CFloat%3E create(final Context context) %7B%0A        return Observable.create(new RotationProvider(context));%0A    %7D%0A%0A%7D%0A

Add rotation sensor provider