Merge pull request #4384 from osmandapp/sensors_innacuracy
Add setting for speed
This commit is contained in:
commit
00db29c727
5 changed files with 110 additions and 55 deletions
|
@ -9,6 +9,8 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="map_orientation_change_in_accordance_with_speed">Map orientation change in accordance with speed</string>
|
||||||
|
<string name="map_orientation_change_in_accordance_with_speed_descr">Use built in compass instead of direction of movement to determine map orientation at low speed</string>
|
||||||
<string name="all_markers_moved_to_history">All markers moved to History</string>
|
<string name="all_markers_moved_to_history">All markers moved to History</string>
|
||||||
<string name="marker_moved_to_history">Marker moved to History</string>
|
<string name="marker_moved_to_history">Marker moved to History</string>
|
||||||
<string name="marker_moved_to_active">Marker moved to Active</string>
|
<string name="marker_moved_to_active">Marker moved to Active</string>
|
||||||
|
|
|
@ -1,55 +1,92 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr" />
|
<ListPreference
|
||||||
|
android:key="router_service"
|
||||||
|
android:summary="@string/router_service_descr"
|
||||||
|
android:title="@string/router_service"/>
|
||||||
|
|
||||||
<PreferenceCategory android:key="routing_preferences" android:title="@string/routing_preferences_descr">
|
<PreferenceCategory
|
||||||
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode"
|
android:key="routing_preferences"
|
||||||
android:key="fast_route_mode" />
|
android:title="@string/routing_preferences_descr">
|
||||||
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/>
|
<CheckBoxPreference
|
||||||
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/>
|
android:key="fast_route_mode"
|
||||||
</PreferenceCategory>
|
android:summary="@string/fast_route_mode_descr"
|
||||||
|
android:title="@string/fast_route_mode"/>
|
||||||
|
<Preference
|
||||||
|
android:key="avoid_in_routing"
|
||||||
|
android:summary="@string/avoid_in_routing_descr"
|
||||||
|
android:title="@string/avoid_in_routing_title"/>
|
||||||
|
<Preference
|
||||||
|
android:key="prefer_in_routing"
|
||||||
|
android:summary="@string/prefer_in_routing_descr"
|
||||||
|
android:title="@string/prefer_in_routing_title"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
|
<PreferenceCategory
|
||||||
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
|
android:key="guidance_preferences"
|
||||||
android:summary="@string/choose_auto_follow_route_descr" />
|
android:title="@string/guidance_preferences_descr">
|
||||||
<Preference android:key="auto_zoom_map_on_off" android:title="@string/auto_zoom_map"
|
<ListPreference
|
||||||
android:summary="@string/auto_zoom_map_descr" />
|
android:key="auto_follow_route"
|
||||||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" />
|
android:summary="@string/choose_auto_follow_route_descr"
|
||||||
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
android:title="@string/choose_auto_follow_route"/>
|
||||||
<Preference android:title="@string/speak_title" android:summary="@string/speak_descr" android:key="speak_routing_alarms"/>
|
<Preference
|
||||||
<ListPreference
|
android:key="auto_zoom_map_on_off"
|
||||||
android:key="keep_informing"
|
android:summary="@string/auto_zoom_map_descr"
|
||||||
android:title="@string/keep_informing"
|
android:title="@string/auto_zoom_map"/>
|
||||||
android:summary="@string/keep_informing_descr" />
|
<CheckBoxPreference
|
||||||
<ListPreference
|
android:key="snap_to_road"
|
||||||
android:key="arrival_distance_factor"
|
android:summary="@string/snap_to_road_descr"
|
||||||
android:title="@string/arrival_distance"
|
android:title="@string/snap_to_road"/>
|
||||||
android:summary="@string/arrival_distance_descr" />
|
<Preference
|
||||||
<ListPreference
|
android:key="show_routing_alarms"
|
||||||
android:key="default_speed_system"
|
android:summary="@string/show_warnings_descr"
|
||||||
android:title="@string/default_speed_system"
|
android:title="@string/show_warnings_title"/>
|
||||||
android:summary="@string/default_speed_system_descr" />
|
<Preference
|
||||||
<ListPreference
|
android:key="speak_routing_alarms"
|
||||||
android:key="speed_limit_exceed"
|
android:summary="@string/speak_descr"
|
||||||
android:title="@string/speed_limit_exceed"
|
android:title="@string/speak_title"/>
|
||||||
android:summary="@string/speed_limit_exceed_message"/>
|
<ListPreference
|
||||||
<!--
|
android:key="keep_informing"
|
||||||
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
android:summary="@string/keep_informing_descr"
|
||||||
-->
|
android:title="@string/keep_informing"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="wake_on_voice_int"
|
android:key="arrival_distance_factor"
|
||||||
android:title="@string/wake_on_voice"
|
android:summary="@string/arrival_distance_descr"
|
||||||
android:summary="@string/wake_on_voice_descr" />
|
android:title="@string/arrival_distance"/>
|
||||||
<!--
|
<ListPreference
|
||||||
<ListPreference
|
android:key="default_speed_system"
|
||||||
android:key="delay_to_start_navigation"
|
android:summary="@string/default_speed_system_descr"
|
||||||
android:title="@string/delay_to_start_navigation"
|
android:title="@string/default_speed_system"/>
|
||||||
android:summary="@string/delay_to_start_navigation_descr" />
|
<ListPreference
|
||||||
-->
|
android:key="speed_limit_exceed"
|
||||||
</PreferenceCategory>
|
android:summary="@string/speed_limit_exceed_message"
|
||||||
|
android:title="@string/speed_limit_exceed"/>
|
||||||
|
<ListPreference
|
||||||
|
android:key="speed_for_map_to_direction_of_movement"
|
||||||
|
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
|
||||||
|
android:title="@string/map_orientation_change_in_accordance_with_speed"/>
|
||||||
|
<!--
|
||||||
|
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
||||||
|
-->
|
||||||
|
<ListPreference
|
||||||
|
android:key="wake_on_voice_int"
|
||||||
|
android:summary="@string/wake_on_voice_descr"
|
||||||
|
android:title="@string/wake_on_voice"/>
|
||||||
|
<!--
|
||||||
|
<ListPreference
|
||||||
|
android:key="delay_to_start_navigation"
|
||||||
|
android:title="@string/delay_to_start_navigation"
|
||||||
|
android:summary="@string/delay_to_start_navigation_descr" />
|
||||||
|
-->
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/voice_pref_title" android:key="voice">
|
<PreferenceCategory
|
||||||
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
|
android:key="voice"
|
||||||
</PreferenceCategory>
|
android:title="@string/voice_pref_title">
|
||||||
|
<ListPreference
|
||||||
|
android:key="voice_provider"
|
||||||
|
android:summary="@string/voice_provider_descr"
|
||||||
|
android:title="@string/voice_provider"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -855,6 +855,9 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
||||||
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
||||||
|
|
||||||
|
public final OsmandPreference<Float> 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
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
|
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
|
||||||
new BooleanPreference("use_trackball_for_movements", true).makeGlobal();
|
new BooleanPreference("use_trackball_for_movements", true).makeGlobal();
|
||||||
|
|
|
@ -202,12 +202,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h);
|
speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h);
|
||||||
}
|
}
|
||||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
|
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
|
||||||
|
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
|
||||||
} else {
|
} else {
|
||||||
String[] speedNames = new String[speedLimitsKm.length];
|
String[] speedNames = new String[speedLimitsKm.length];
|
||||||
for (int i =0; i<speedNames.length;i++){
|
for (int i =0; i<speedNames.length;i++){
|
||||||
speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour);
|
speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour);
|
||||||
}
|
}
|
||||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
|
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
|
||||||
|
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||||
|
|
|
@ -123,7 +123,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
public void updateCompassValue(float val) {
|
public void updateCompassValue(float val) {
|
||||||
heading = val;
|
heading = val;
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode) {
|
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get();
|
||||||
|
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && getMyLocation() != null && isSmallSpeedForDirectionOfMovement(getMyLocation(), speedForDirectionOfMovement);
|
||||||
|
if ((settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_COMPASS || (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && smallSpeedForDirectionOfMovement)) && !routePlanningMode) {
|
||||||
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) {
|
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) {
|
||||||
mapView.setRotate(-val);
|
mapView.setRotate(-val);
|
||||||
}
|
}
|
||||||
|
@ -201,13 +203,17 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
zoom = autozoom(location);
|
zoom = autozoom(location);
|
||||||
}
|
}
|
||||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||||
|
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get();
|
||||||
|
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement);
|
||||||
boolean smallSpeedForCompass = isSmallSpeedForCompass(location);
|
boolean smallSpeedForCompass = isSmallSpeedForCompass(location);
|
||||||
boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location);
|
boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location);
|
||||||
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
|
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
|
||||||
showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null &&
|
showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null &&
|
||||||
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
||||||
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
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)
|
// special case when bearing equals to zero (we don't change anything)
|
||||||
if (location.getBearing() != 0f) {
|
if (location.getBearing() != 0f) {
|
||||||
rotation = -location.getBearing();
|
rotation = -location.getBearing();
|
||||||
|
@ -216,7 +222,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
} else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
|
} else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
|
||||||
showViewAngle = routePlanningMode; // disable compass rotation in that mode
|
showViewAngle = routePlanningMode; // disable compass rotation in that mode
|
||||||
}
|
}
|
||||||
registerUnregisterSensor(location);
|
registerUnregisterSensor(location, smallSpeedForDirectionOfMovement);
|
||||||
if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation &&
|
if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation &&
|
||||||
settings.WAKE_ON_VOICE_INT.get() == 0) {
|
settings.WAKE_ON_VOICE_INT.get() == 0) {
|
||||||
mapView.getAnimatedDraggingThread().startMoving(
|
mapView.getAnimatedDraggingThread().startMoving(
|
||||||
|
@ -233,7 +239,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
} else if(location != null) {
|
} else if(location != null) {
|
||||||
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null &&
|
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null &&
|
||||||
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
||||||
registerUnregisterSensor(location);
|
registerUnregisterSensor(location, false);
|
||||||
}
|
}
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
followingMode = routingHelper.isFollowingMode();
|
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) {
|
public static boolean isSmallSpeedForCompass(Location location) {
|
||||||
return !location.hasSpeed() || location.getSpeed() < 0.5;
|
return !location.hasSpeed() || location.getSpeed() < 0.5;
|
||||||
}
|
}
|
||||||
|
@ -285,14 +295,15 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
&& !settings.CENTER_POSITION_ON_MAP.get() ?
|
&& !settings.CENTER_POSITION_ON_MAP.get() ?
|
||||||
OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT);
|
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();
|
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||||
boolean registerCompassListener = ((showViewAngle || contextMenu != null) && location != null)
|
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
|
// show point view only if gps enabled
|
||||||
if(sensorRegistered != registerCompassListener) {
|
if(sensorRegistered != registerCompassListener) {
|
||||||
app.getLocationProvider().registerOrUnregisterCompassListener(registerCompassListener);
|
app.getLocationProvider().registerOrUnregisterCompassListener(registerCompassListener);
|
||||||
|
|
Loading…
Reference in a new issue