diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml
index a2e7dfff48..af38b5d697 100644
--- a/OsmAnd/res/xml/navigation_settings.xml
+++ b/OsmAnd/res/xml/navigation_settings.xml
@@ -15,7 +15,5 @@
-
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 9cfcea8a47..415d6cdf19 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -831,12 +831,12 @@ public class OsmandSettings {
new IntPreference("map_screen_orientation", -1/*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
- public final CommonPreference SHOW_VIEW_ANGLE = new BooleanPreference("show_view_angle", false).makeProfile().cache();
- {
- SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.CAR, false);
- SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.BICYCLE, true);
- SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
- }
+// public final CommonPreference SHOW_VIEW_ANGLE = new BooleanPreference("show_view_angle", false).makeProfile().cache();
+// {
+// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.CAR, false);
+// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.BICYCLE, true);
+// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
+// }
// this value string is synchronized with settings_pref.xml preference name
// seconds to auto_follow
@@ -1544,12 +1544,6 @@ public class OsmandSettings {
};
}.makeGlobal();
- // this value string is synchronized with settings_pref.xml preference name
- //public final OsmandPreference USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
- public final CommonPreference USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
- {
- USE_COMPASS_IN_NAVIGATION.setModeDefaultValue(ApplicationMode.CAR, false);
- }
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference RENDERER = new StringPreference("renderer", RendererRegistry.DEFAULT_RENDER) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
index cc1087ebd4..e9555abcff 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
@@ -136,7 +136,7 @@ public class MapActivityLayers {
transportInfoLayer = new TransportInfoLayer(TransportRouteHelper.getInstance());
mapView.addLayer(transportInfoLayer, 5.5f);
// 6. point location layer
- locationLayer = new PointLocationLayer();
+ locationLayer = new PointLocationLayer(activity.getMapViewTrackingUtilities());
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(activity);
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index c5e4f7bb73..7a896f4d50 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -64,7 +64,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
- registerBooleanPreference(settings.USE_COMPASS_IN_NAVIGATION, screen);
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
entries = new String[intValues.length];
diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
index b1db7009b6..66b0dddf27 100644
--- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
@@ -27,7 +27,6 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
private long lastTimeAutoZooming = 0;
- private long lastTimeSensorMapRotation = 0;
private boolean sensorRegistered = false;
private OsmandMapTileView mapView;
private OsmandSettings settings;
@@ -36,6 +35,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
private boolean isMapLinkedToLocation = false;
private boolean followingMode;
private boolean routePlanningMode;
+ private boolean showViewAngle = false;
public MapViewTrackingUtilities(OsmandApplication app){
this.app = app;
@@ -75,7 +75,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) {
mapView.setRotate(-val);
}
- } else if (settings.SHOW_VIEW_ANGLE.get()) {
+ } else if (showViewAngle) {
mapView.refreshMap();
}
}
@@ -83,37 +83,27 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
@Override
public void updateLocation(Location location) {
+ showViewAngle = false;
if (mapView != null) {
if (isMapLinkedToLocation() && location != null) {
if (settings.AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE) {
autozoom(location);
}
int currentMapRotation = settings.ROTATE_MAP.get();
- boolean enableCompass = false;
+ boolean smallSpeed = !location.hasSpeed() || location.getSpeed() < 0.5;
+ // boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
+ showViewAngle = (!location.hasBearing() || smallSpeed);
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
- boolean smallSpeed = !location.hasSpeed() || location.getSpeed() < 0.5;
- boolean fMode = app.getRoutingHelper().isFollowingMode();
- // boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
- enableCompass = (!location.hasBearing() || smallSpeed)
- && fMode && settings.USE_COMPASS_IN_NAVIGATION.get();
if (location.hasBearing() && !smallSpeed) {
// special case when bearing equals to zero (we don't change anything)
if (location.getBearing() != 0f) {
mapView.setRotate(-location.getBearing());
}
- } else if (enableCompass) {
- long now = System.currentTimeMillis();
- OsmAndLocationProvider provider = app.getLocationProvider();
- Float lastSensorRotation = provider.getHeading();
- if (lastSensorRotation != null && Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -lastSensorRotation)) > 15) {
- if (now - lastTimeSensorMapRotation > 3500) {
- lastTimeSensorMapRotation = now;
- mapView.setRotate(-lastSensorRotation);
- }
- }
}
+ } else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
+ showViewAngle = routePlanningMode; // disable compass rotation in that mode
}
- registerUnregisterSensor(location, enableCompass);
+ registerUnregisterSensor(location);
mapView.setLatLon(location.getLatitude(), location.getLongitude());
}
RoutingHelper routingHelper = app.getRoutingHelper();
@@ -127,6 +117,11 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
+ public boolean isShowViewAngle() {
+
+ return showViewAngle;
+ }
+
public void switchToRoutePlanningMode() {
RoutingHelper routingHelper = app.getRoutingHelper();
@@ -146,13 +141,12 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && !routePlanningMode ? OsmandSettings.BOTTOM_CONSTANT
: OsmandSettings.CENTER_CONSTANT);
}
- registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation(), false);
+ registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
}
- private void registerUnregisterSensor(net.osmand.Location location, boolean overruleRegister) {
- boolean currentShowingAngle = settings.SHOW_VIEW_ANGLE.get();
+ private void registerUnregisterSensor(net.osmand.Location location) {
int currentMapRotation = settings.ROTATE_MAP.get();
- boolean registerCompassListener = overruleRegister || (currentShowingAngle && location != null)
+ boolean registerCompassListener = (showViewAngle && location != null)
|| (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode);
// show point view only if gps enabled
if(sensorRegistered != registerCompassListener) {
@@ -313,4 +307,5 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
public void routeWasCancelled() {
}
+
}
diff --git a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java
index ecb6e29ee2..9cc3b03095 100644
--- a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java
@@ -6,6 +6,7 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.R;
+import net.osmand.plus.base.MapViewTrackingUtilities;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -28,7 +29,12 @@ public class PointLocationLayer extends OsmandMapLayer {
private Bitmap bearingIcon;
private Bitmap locationIcon;
private OsmAndLocationProvider locationProvider;
+ private MapViewTrackingUtilities mapViewTrackingUtilities;
private boolean nm;
+
+ public PointLocationLayer(MapViewTrackingUtilities mv) {
+ this.mapViewTrackingUtilities = mv;
+ }
private void initUI() {
locationPaint = new Paint();
@@ -53,7 +59,6 @@ public class PointLocationLayer extends OsmandMapLayer {
checkAppMode(view.getSettings().getApplicationMode());
locationProvider = view.getApplication().getLocationProvider();
-
}
@Override
@@ -65,7 +70,7 @@ public class PointLocationLayer extends OsmandMapLayer {
private RectF getHeadingRect(int locationX, int locationY){
- int rad = Math.min(3 * view.getWidth() / 8, 3 * view.getHeight() / 8);
+ int rad = (int) (view.getDensity() * 25);
return new RectF(locationX - rad, locationY - rad, locationX + rad, locationY + rad);
}
@@ -102,10 +107,9 @@ public class PointLocationLayer extends OsmandMapLayer {
locationPaint);
}
Float heading = locationProvider.getHeading();
- if (heading != null && view.getSettings().SHOW_VIEW_ANGLE.get()) {
+ if (heading != null && mapViewTrackingUtilities.isShowViewAngle()) {
canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE, true, headingPaint);
}
-
if (isBearing) {
float bearing = lastKnownLocation.getBearing();
canvas.rotate(bearing - 90, locationX, locationY);
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java
index bda72e48d6..e38624ed1d 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java
@@ -32,15 +32,15 @@ public class AppearanceWidgetsFactory {
final OsmandMapTileView view = map.getMapView();
- final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
- "viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
- displayViewDirections.setStateChangeListener(new Runnable() {
- @Override
- public void run() {
- view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
- map.getMapViewTrackingUtilities().updateSettings();
- }
- });
+// final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
+// "viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
+// displayViewDirections.setStateChangeListener(new Runnable() {
+// @Override
+// public void run() {
+// view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
+// map.getMapViewTrackingUtilities().updateSettings();
+// }
+// });
if (EXTRA_SETTINGS) {
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,