Updated speed limit exceed.
This commit is contained in:
parent
bf288499e7
commit
c7d6543197
3 changed files with 37 additions and 38 deletions
|
@ -675,12 +675,9 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Float> ARRIVAL_DISTANCE_FACTOR =
|
||||
new FloatPreference("arrival_distance_factor", 1f).makeProfile();
|
||||
|
||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED_KM =
|
||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
||||
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
||||
|
||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED_MILE =
|
||||
new FloatPreference("speed_limit_exceed", 3f).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();
|
||||
|
|
|
@ -33,6 +33,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
private Preference speakAlarms;
|
||||
private ListPreference routerServicePreference;
|
||||
private ListPreference autoZoomMapPreference;
|
||||
private ListPreference speedLimitExceed;
|
||||
|
||||
|
||||
private List<RoutingParameter> avoidParameters = new ArrayList<RoutingParameter>();
|
||||
|
@ -111,30 +112,33 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
};
|
||||
registerListPreference(settings.ARRIVAL_DISTANCE_FACTOR, screen, arrivalNames, arrivalValues);
|
||||
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
if (mode.isDerivedRoutingFrom(ApplicationMode.CAR)){
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS){
|
||||
Float[] speedLimits = new Float[] {5f, 7f, 10f, 15f, 20f};
|
||||
|
||||
String[] speedNames = new String[] {
|
||||
Float[] speedLimits = new Float[]{5f, 7f, 10f, 15f, 20f};
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
String[] speedNames = new String[]{
|
||||
speedLimits[0] + " " + getString(R.string.km_h),
|
||||
speedLimits[1] + " " + getString(R.string.km_h),
|
||||
speedLimits[2] + " " + getString(R.string.km_h),
|
||||
speedLimits[3] + " " + getString(R.string.km_h),
|
||||
speedLimits[4] + " " + getString(R.string.km_h)};
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_KM, screen, speedNames, speedLimits);
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimits);
|
||||
} else {
|
||||
Float[] speedLimits = new Float[] {3f, 5f, 7f, 10f, 15f};
|
||||
String[] speedNames = new String[] {
|
||||
speedLimits[0] + " " + getString(R.string.mile_per_hour),
|
||||
speedLimits[1] + " " + getString(R.string.mile_per_hour),
|
||||
speedLimits[2] + " " + getString(R.string.mile_per_hour),
|
||||
speedLimits[3] + " " + getString(R.string.mile_per_hour),
|
||||
speedLimits[4] + " " + getString(R.string.mile_per_hour)};
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_MILE, screen, speedNames, speedLimits);
|
||||
String[] speedNames = new String[]{
|
||||
3f + " " + getString(R.string.mile_per_hour),
|
||||
5f + " " + getString(R.string.mile_per_hour),
|
||||
7f + " " + getString(R.string.mile_per_hour),
|
||||
10f + " " + getString(R.string.mile_per_hour),
|
||||
15f + " " + getString(R.string.mile_per_hour)};
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimits);
|
||||
}
|
||||
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
speedLimitExceed = (ListPreference) category.findPreference("speed_limit_exceed");
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
if (!mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
category.removePreference(speedLimitExceed);
|
||||
}
|
||||
|
||||
|
||||
profileDialog();
|
||||
}
|
||||
|
||||
|
@ -200,6 +204,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
cat.addPreference(basePref);
|
||||
}
|
||||
}
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
if (mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
category.addPreference(speedLimitExceed);
|
||||
} else {
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
category.removePreference(speedLimitExceed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,12 +157,7 @@ public class WaypointHelper {
|
|||
public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) {
|
||||
Location lastProjection = app.getRoutingHelper().getLastProjection();
|
||||
float mxspeed = route.getCurrentMaxSpeed();
|
||||
float delta;
|
||||
if (app.getSettings().METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS){
|
||||
delta = app.getSettings().SPEED_LIMIT_EXCEED_KM.get();
|
||||
} else {
|
||||
delta = app.getSettings().SPEED_LIMIT_EXCEED_KM.get() * 1.6f;
|
||||
}
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, lastProjection, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm();
|
||||
|
@ -252,12 +247,7 @@ public class WaypointHelper {
|
|||
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc,
|
||||
MetricsConstants mc, boolean showCameras) {
|
||||
float mxspeed = ro.getMaximumSpeed();
|
||||
float delta;
|
||||
if (app.getSettings().METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS){
|
||||
delta = app.getSettings().SPEED_LIMIT_EXCEED_KM.get();
|
||||
} else {
|
||||
delta = app.getSettings().SPEED_LIMIT_EXCEED_MILE.get() * 1.6f;
|
||||
}
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm();
|
||||
|
|
Loading…
Reference in a new issue