From c1365ddd114f35a04bdc5b98a5fea253901b4c20 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 1 Sep 2017 18:57:36 +0300 Subject: [PATCH 1/3] Add setting for speed --- OsmAnd/res/values/strings.xml | 2 + OsmAnd/res/xml/navigation_settings.xml | 133 +++++++++++------- .../src/net/osmand/plus/OsmandSettings.java | 3 + .../SettingsNavigationActivity.java | 2 + .../plus/base/MapViewTrackingUtilities.java | 25 +++- 5 files changed, 110 insertions(+), 55 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f37e4d2c66..723210c7c8 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Speed for map to direction of movement + Specify speed when map should rotate to direction of movement instead of compass Move all to history Build route Show direction diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml index 5463abb74c..e612541541 100644 --- a/OsmAnd/res/xml/navigation_settings.xml +++ b/OsmAnd/res/xml/navigation_settings.xml @@ -1,55 +1,92 @@ - + - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 8dcec70c60..e5d75dfccc 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -855,6 +855,9 @@ public class OsmandSettings { public final OsmandPreference SPEED_LIMIT_EXCEED = new FloatPreference("speed_limit_exceed", 5f).makeProfile(); + public final OsmandPreference SWITCH_TO_MAP_DIRECTION = + new FloatPreference("speed_for_map_to_direction_of_movement", 5f).makeProfile(); + // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference USE_TRACKBALL_FOR_MOVEMENTS = new BooleanPreference("use_trackball_for_movements", true).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index eda15c2989..631977c461 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -202,12 +202,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h); } registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm); + registerListPreference(settings.SWITCH_TO_MAP_DIRECTION, screen, speedNames, speedLimitsKm); } else { String[] speedNames = new String[speedLimitsKm.length]; for (int i =0; i 1) { mapView.setRotate(-val); } @@ -201,13 +203,17 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc zoom = autozoom(location); } int currentMapRotation = settings.ROTATE_MAP.get(); + float speedForDirectionOfMovement = settings.SWITCH_TO_MAP_DIRECTION.get(); + boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement); boolean smallSpeedForCompass = isSmallSpeedForCompass(location); boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location); // boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get(); showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null && tb.containsLatLon(location.getLatitude(), location.getLongitude())); if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) { - if (location.hasBearing() && !smallSpeedForCompass) { + if (smallSpeedForDirectionOfMovement) { + showViewAngle = routePlanningMode; + } else if (location.hasBearing() && !smallSpeedForCompass) { // special case when bearing equals to zero (we don't change anything) if (location.getBearing() != 0f) { rotation = -location.getBearing(); @@ -216,7 +222,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc } else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) { showViewAngle = routePlanningMode; // disable compass rotation in that mode } - registerUnregisterSensor(location); + registerUnregisterSensor(location, smallSpeedForDirectionOfMovement); if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation && settings.WAKE_ON_VOICE_INT.get() == 0) { mapView.getAnimatedDraggingThread().startMoving( @@ -233,7 +239,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc } else if(location != null) { showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null && tb.containsLatLon(location.getLatitude(), location.getLongitude())); - registerUnregisterSensor(location); + registerUnregisterSensor(location, false); } RoutingHelper routingHelper = app.getRoutingHelper(); followingMode = routingHelper.isFollowingMode(); @@ -252,6 +258,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc } } + public static boolean isSmallSpeedForDirectionOfMovement(Location location, float speedToDirectionOfMovement) { + return !location.hasSpeed() || location.getSpeed() < speedToDirectionOfMovement; + } + public static boolean isSmallSpeedForCompass(Location location) { return !location.hasSpeed() || location.getSpeed() < 0.5; } @@ -285,14 +295,15 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc && !settings.CENTER_POSITION_ON_MAP.get() ? OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT); } - registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation()); + registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation(), false); } - private void registerUnregisterSensor(net.osmand.Location location) { + private void registerUnregisterSensor(net.osmand.Location location, boolean smallSpeedForDirectionOfMovement) { int currentMapRotation = settings.ROTATE_MAP.get(); boolean registerCompassListener = ((showViewAngle || contextMenu != null) && location != null) - || (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode); + || (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode) + || (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING && smallSpeedForDirectionOfMovement); // show point view only if gps enabled if(sensorRegistered != registerCompassListener) { app.getLocationProvider().registerOrUnregisterCompassListener(registerCompassListener); From d64627da07c2a1e165d41b03af47c4570a2952ab Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 4 Sep 2017 10:00:33 +0300 Subject: [PATCH 2/3] Make preference disabled by default --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index e5d75dfccc..cdbf3d0ca2 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -856,7 +856,7 @@ public class OsmandSettings { new FloatPreference("speed_limit_exceed", 5f).makeProfile(); public final OsmandPreference SWITCH_TO_MAP_DIRECTION = - new FloatPreference("speed_for_map_to_direction_of_movement", 5f).makeProfile(); + new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference USE_TRACKBALL_FOR_MOVEMENTS = From 4ba50ff806a4f9f907951148945bf028af2610ae Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 7 Sep 2017 18:51:04 +0300 Subject: [PATCH 3/3] Rename setting --- OsmAnd/res/values/strings.xml | 4 ++-- OsmAnd/res/xml/navigation_settings.xml | 4 ++-- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- .../osmand/plus/activities/SettingsNavigationActivity.java | 4 ++-- OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index fc287e5aef..73a65c3ff7 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,8 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - Speed for map to direction of movement - Specify speed when map should rotate to direction of movement instead of compass + Map orientation change in accordance with speed + Use built in compass instead of direction of movement to determine map orientation at low speed Move all to history Build route Show direction diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml index e612541541..47eefe9ade 100644 --- a/OsmAnd/res/xml/navigation_settings.xml +++ b/OsmAnd/res/xml/navigation_settings.xml @@ -63,8 +63,8 @@ android:title="@string/speed_limit_exceed"/> + android:summary="@string/map_orientation_change_in_accordance_with_speed_descr" + android:title="@string/map_orientation_change_in_accordance_with_speed"/> diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index af670182bb..29a0d165b5 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -855,7 +855,7 @@ public class OsmandSettings { public final OsmandPreference SPEED_LIMIT_EXCEED = new FloatPreference("speed_limit_exceed", 5f).makeProfile(); - public final OsmandPreference SWITCH_TO_MAP_DIRECTION = + public final OsmandPreference SWITCH_MAP_DIRECTION_TO_COMPASS = new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile(); // this value string is synchronized with settings_pref.xml preference name diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 631977c461..7978fe9b15 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -202,14 +202,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h); } registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm); - registerListPreference(settings.SWITCH_TO_MAP_DIRECTION, screen, speedNames, speedLimitsKm); + registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm); } else { String[] speedNames = new String[speedLimitsKm.length]; for (int i =0; i 1) { @@ -203,7 +203,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc zoom = autozoom(location); } int currentMapRotation = settings.ROTATE_MAP.get(); - float speedForDirectionOfMovement = settings.SWITCH_TO_MAP_DIRECTION.get(); + float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get(); boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement); boolean smallSpeedForCompass = isSmallSpeedForCompass(location); boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location);