Fix kmh / mph nav parameters
This commit is contained in:
parent
61b6e6077c
commit
81bf4ea094
6 changed files with 52 additions and 59 deletions
|
@ -165,33 +165,34 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
registerListPreference(settings.ARRIVAL_DISTANCE_FACTOR, screen, arrivalNames, arrivalValues);
|
||||
|
||||
|
||||
//array size must be equal!
|
||||
Float[] speedLimitsKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
//array size must be equal!
|
||||
Float[] speedLimitsKmhPos = new Float[]{0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsMphPos = new Float[]{0f, 3f, 5f, 7f, 10f, 15f};
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
Float[] speedLimitsKm = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsKmPos = new Float[]{0f, 5f, 7f, 10f, 15f, 20f};
|
||||
String[] speedNames = new String[speedLimitsKm.length];
|
||||
String[] speedNamesPos = new String[speedLimitsKmPos.length];
|
||||
for (int i = 0; i < speedLimitsKm.length; i++) {
|
||||
speedNames[i] = speedLimitsKm[i].intValue() + " " + getString(R.string.km_h);
|
||||
String[] speedNames = new String[speedLimitsKmh.length];
|
||||
String[] speedNamesPos = new String[speedLimitsKmhPos.length];
|
||||
for (int i = 0; i < speedLimitsKmh.length; i++) {
|
||||
speedNames[i] = speedLimitsKmh[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
for (int i = 0; i < speedLimitsKmPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsKmPos[i].intValue() + " " + getString(R.string.km_h);
|
||||
for (int i = 0; i < speedLimitsKmhPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsKmhPos[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNamesPos, speedLimitsKmPos);
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_KMH, screen, speedNames, speedLimitsKmh);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH, screen, speedNamesPos, speedLimitsKmhPos);
|
||||
} else {
|
||||
Float[] speedLimitsMiles = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
Float[] speedLimitsMilesPos = new Float[]{0f, 3f, 5f, 7f, 10f, 15f};
|
||||
|
||||
String[] speedNames = new String[speedLimitsMiles.length];
|
||||
String[] speedNames = new String[speedLimitsMph.length];
|
||||
String[] speedNamesPos = new String[speedLimitsMphPos.length];
|
||||
for (int i = 0; i < speedNames.length; i++) {
|
||||
speedNames[i] = speedLimitsMiles[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
speedNames[i] = speedLimitsMph[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
String[] speedNamesPos = new String[speedLimitsMilesPos.length];
|
||||
for (int i = 0; i < speedNamesPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsMiles[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
speedNamesPos[i] = speedLimitsMphPos[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsMiles);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNamesPos, speedLimitsMilesPos);
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_KMH, screen, speedNames, speedLimitsKmh);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH, screen, speedNamesPos, speedLimitsKmhPos);
|
||||
}
|
||||
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
|
|
|
@ -128,7 +128,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
headingChanged = Math.abs(MapUtils.degreesDiff(prevHeading, heading)) > 1.0;
|
||||
}
|
||||
if (mapView != null) {
|
||||
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get()/3.6f;
|
||||
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH.get()/3.6f;
|
||||
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 &&
|
||||
myLocation != null && isSmallSpeedForDirectionOfMovement(myLocation, speedForDirectionOfMovement);
|
||||
if ((settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_COMPASS || (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && smallSpeedForDirectionOfMovement)) && !routePlanningMode) {
|
||||
|
@ -187,7 +187,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
zoom = autozoom(tb, location);
|
||||
}
|
||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get()/3.6f;
|
||||
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH.get()/3.6f;
|
||||
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0
|
||||
&& isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement);
|
||||
boolean smallSpeedForCompass = isSmallSpeedForCompass(location);
|
||||
|
|
|
@ -196,7 +196,7 @@ public class WaypointHelper {
|
|||
public AlarmInfo getMostImportantAlarm(OsmandSettings.SpeedConstants sc, boolean showCameras) {
|
||||
Location lastProjection = app.getRoutingHelper().getLastProjection();
|
||||
float mxspeed = route.getCurrentMaxSpeed();
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f;
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f;
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, lastProjection, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), lastProjection.getSpeed());
|
||||
|
@ -293,7 +293,7 @@ public class WaypointHelper {
|
|||
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, MetricsConstants mc,
|
||||
OsmandSettings.SpeedConstants sc, boolean showCameras) {
|
||||
float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc));
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f;
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f;
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, loc, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), loc.getSpeed());
|
||||
|
|
|
@ -1790,7 +1790,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Float> ARRIVAL_DISTANCE_FACTOR =
|
||||
new FloatPreference("arrival_distance_factor", 1f).makeProfile();
|
||||
|
||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED_KMH =
|
||||
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
||||
|
||||
public final CommonPreference<Float> DEFAULT_SPEED = new FloatPreference("default_speed", 10f).makeProfile().cache();
|
||||
|
@ -1873,7 +1873,7 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<Integer> APP_MODE_ORDER = new IntPreference("app_mode_order", 0).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
|
||||
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS_KMH =
|
||||
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
|
|
@ -74,28 +74,24 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
private void setupMapDirectionToCompassPref() {
|
||||
String[] entries;
|
||||
Float[] entryValues;
|
||||
//array size must be equal!
|
||||
Float[] valuesKmh = new Float[]{0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] valuesMph = new Float[]{0f, 3f, 5f, 7f, 10f, 15f};
|
||||
String[] names;
|
||||
if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
entryValues = new Float[] {0f, 5f, 7f, 10f, 15f, 20f};
|
||||
entries = new String[entryValues.length];
|
||||
|
||||
for (int i = 0; i < entryValues.length; i++) {
|
||||
entries[i] = entryValues[i].intValue() + " " + getString(R.string.km_h);
|
||||
names = new String[valuesKmh.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = valuesKmh[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
} else {
|
||||
Float[] speedLimitsMiles = new Float[] {-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
entryValues = new Float[] {0f, 3f, 5f, 7f, 10f, 15f};
|
||||
entries = new String[entryValues.length];
|
||||
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = speedLimitsMiles[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
names = new String[valuesMph.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = valuesMph[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
}
|
||||
|
||||
ListPreferenceEx switchMapDirectionToCompass = (ListPreferenceEx) findPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS.getId());
|
||||
switchMapDirectionToCompass.setEntries(entries);
|
||||
switchMapDirectionToCompass.setEntryValues(entryValues);
|
||||
ListPreferenceEx switchMapDirectionToCompass = (ListPreferenceEx) findPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH.getId());
|
||||
switchMapDirectionToCompass.setEntries(names);
|
||||
switchMapDirectionToCompass.setEntryValues(valuesKmh);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -103,28 +103,24 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr
|
|||
}
|
||||
|
||||
private void setupSpeedLimitExceedPref() {
|
||||
Float[] speedLimitValues;
|
||||
String[] speedLimitNames;
|
||||
|
||||
//array size must be equal!
|
||||
Float[] valuesKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] valuesMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
String[] names;
|
||||
if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
speedLimitValues = new Float[] {-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
speedLimitNames = new String[speedLimitValues.length];
|
||||
|
||||
for (int i = 0; i < speedLimitValues.length; i++) {
|
||||
speedLimitNames[i] = speedLimitValues[i].intValue() + " " + getString(R.string.km_h);
|
||||
names = new String[valuesKmh.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = valuesKmh[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
} else {
|
||||
speedLimitValues = new Float[] {-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
speedLimitNames = new String[speedLimitValues.length];
|
||||
|
||||
for (int i = 0; i < speedLimitNames.length; i++) {
|
||||
speedLimitNames[i] = speedLimitValues[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
names = new String[valuesMph.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = valuesMph[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
}
|
||||
|
||||
ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.SPEED_LIMIT_EXCEED.getId());
|
||||
voiceProvider.setEntries(speedLimitNames);
|
||||
voiceProvider.setEntryValues(speedLimitValues);
|
||||
ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.SPEED_LIMIT_EXCEED_KMH.getId());
|
||||
voiceProvider.setEntries(names);
|
||||
voiceProvider.setEntryValues(valuesKmh);
|
||||
}
|
||||
|
||||
private void setupKeepInformingPref() {
|
||||
|
|
Loading…
Reference in a new issue