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).
|
||||
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="marker_moved_to_history">Marker moved to History</string>
|
||||
<string name="marker_moved_to_active">Marker moved to Active</string>
|
||||
|
|
|
@ -1,55 +1,92 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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">
|
||||
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode"
|
||||
android:key="fast_route_mode" />
|
||||
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/>
|
||||
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="routing_preferences"
|
||||
android:title="@string/routing_preferences_descr">
|
||||
<CheckBoxPreference
|
||||
android:key="fast_route_mode"
|
||||
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">
|
||||
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr" />
|
||||
<Preference android:key="auto_zoom_map_on_off" android:title="@string/auto_zoom_map"
|
||||
android:summary="@string/auto_zoom_map_descr" />
|
||||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" />
|
||||
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
||||
<Preference android:title="@string/speak_title" android:summary="@string/speak_descr" android:key="speak_routing_alarms"/>
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:title="@string/keep_informing"
|
||||
android:summary="@string/keep_informing_descr" />
|
||||
<ListPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:title="@string/arrival_distance"
|
||||
android:summary="@string/arrival_distance_descr" />
|
||||
<ListPreference
|
||||
android:key="default_speed_system"
|
||||
android:title="@string/default_speed_system"
|
||||
android:summary="@string/default_speed_system_descr" />
|
||||
<ListPreference
|
||||
android:key="speed_limit_exceed"
|
||||
android:title="@string/speed_limit_exceed"
|
||||
android:summary="@string/speed_limit_exceed_message"/>
|
||||
<!--
|
||||
<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:title="@string/wake_on_voice"
|
||||
android:summary="@string/wake_on_voice_descr" />
|
||||
<!--
|
||||
<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:key="guidance_preferences"
|
||||
android:title="@string/guidance_preferences_descr">
|
||||
<ListPreference
|
||||
android:key="auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"
|
||||
android:title="@string/choose_auto_follow_route"/>
|
||||
<Preference
|
||||
android:key="auto_zoom_map_on_off"
|
||||
android:summary="@string/auto_zoom_map_descr"
|
||||
android:title="@string/auto_zoom_map"/>
|
||||
<CheckBoxPreference
|
||||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road"/>
|
||||
<Preference
|
||||
android:key="show_routing_alarms"
|
||||
android:summary="@string/show_warnings_descr"
|
||||
android:title="@string/show_warnings_title"/>
|
||||
<Preference
|
||||
android:key="speak_routing_alarms"
|
||||
android:summary="@string/speak_descr"
|
||||
android:title="@string/speak_title"/>
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:summary="@string/keep_informing_descr"
|
||||
android:title="@string/keep_informing"/>
|
||||
<ListPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:summary="@string/arrival_distance_descr"
|
||||
android:title="@string/arrival_distance"/>
|
||||
<ListPreference
|
||||
android:key="default_speed_system"
|
||||
android:summary="@string/default_speed_system_descr"
|
||||
android:title="@string/default_speed_system"/>
|
||||
<ListPreference
|
||||
android:key="speed_limit_exceed"
|
||||
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">
|
||||
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="voice"
|
||||
android:title="@string/voice_pref_title">
|
||||
<ListPreference
|
||||
android:key="voice_provider"
|
||||
android:summary="@string/voice_provider_descr"
|
||||
android:title="@string/voice_provider"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -855,6 +855,9 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
||||
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
|
||||
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
|
||||
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);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, 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<speedNames.length;i++){
|
||||
speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
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");
|
||||
|
|
|
@ -123,7 +123,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
public void updateCompassValue(float val) {
|
||||
heading = val;
|
||||
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) {
|
||||
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_MAP_DIRECTION_TO_COMPASS.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);
|
||||
|
|
Loading…
Reference in a new issue