Add setting for speed
This commit is contained in:
parent
c064bfdf7e
commit
c1365ddd11
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="speed_for_map_to_direction_of_movement">Speed for map to direction of movement</string>
|
||||||
|
<string name="speed_for_map_to_direction_of_movement_descr">Specify speed when map should rotate to direction of movement instead of compass</string>
|
||||||
<string name="move_all_to_history">Move all to history</string>
|
<string name="move_all_to_history">Move all to history</string>
|
||||||
<string name="build_route">Build route</string>
|
<string name="build_route">Build route</string>
|
||||||
<string name="show_direction">Show direction</string>
|
<string name="show_direction">Show direction</string>
|
||||||
|
|
|
@ -1,45 +1,77 @@
|
||||||
<?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"
|
||||||
|
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>
|
||||||
|
|
||||||
<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
|
||||||
|
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
|
<ListPreference
|
||||||
android:key="keep_informing"
|
android:key="keep_informing"
|
||||||
android:title="@string/keep_informing"
|
android:summary="@string/keep_informing_descr"
|
||||||
android:summary="@string/keep_informing_descr" />
|
android:title="@string/keep_informing"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="arrival_distance_factor"
|
android:key="arrival_distance_factor"
|
||||||
android:title="@string/arrival_distance"
|
android:summary="@string/arrival_distance_descr"
|
||||||
android:summary="@string/arrival_distance_descr" />
|
android:title="@string/arrival_distance"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="default_speed_system"
|
android:key="default_speed_system"
|
||||||
android:title="@string/default_speed_system"
|
android:summary="@string/default_speed_system_descr"
|
||||||
android:summary="@string/default_speed_system_descr" />
|
android:title="@string/default_speed_system"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="speed_limit_exceed"
|
android:key="speed_limit_exceed"
|
||||||
android:title="@string/speed_limit_exceed"
|
android:summary="@string/speed_limit_exceed_message"
|
||||||
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/speed_for_map_to_direction_of_movement_descr"
|
||||||
|
android:title="@string/speed_for_map_to_direction_of_movement"/>
|
||||||
<!--
|
<!--
|
||||||
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
||||||
-->
|
-->
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="wake_on_voice_int"
|
android:key="wake_on_voice_int"
|
||||||
android:title="@string/wake_on_voice"
|
android:summary="@string/wake_on_voice_descr"
|
||||||
android:summary="@string/wake_on_voice_descr" />
|
android:title="@string/wake_on_voice"/>
|
||||||
<!--
|
<!--
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="delay_to_start_navigation"
|
android:key="delay_to_start_navigation"
|
||||||
|
@ -48,8 +80,13 @@
|
||||||
-->
|
-->
|
||||||
</PreferenceCategory>
|
</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"
|
||||||
|
android:title="@string/voice_pref_title">
|
||||||
|
<ListPreference
|
||||||
|
android:key="voice_provider"
|
||||||
|
android:summary="@string/voice_provider_descr"
|
||||||
|
android:title="@string/voice_provider"/>
|
||||||
</PreferenceCategory>
|
</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_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
|
// 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_TO_MAP_DIRECTION, 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_TO_MAP_DIRECTION, 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_TO_MAP_DIRECTION.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_TO_MAP_DIRECTION.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