Merge pull request #914 from Bars107/master
Added setting to set speed limit
This commit is contained in:
commit
222e7c1aae
9 changed files with 60 additions and 11 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="speed_limit_exceed">Speed limit exceed value.</string>
|
||||
<string name ="speed_limit_exceed_message">Select speed limit exceed value on which you will get voice announcement.</string>
|
||||
<string name="fav_point_emoticons_message">We changed your favorite point name to %1$s because it is not possible to save string with emoticons to file.</string>
|
||||
<string name="print_route">Print route</string>
|
||||
<string name="test_native_render">Test native render</string>
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
android:key="arrival_distance_factor"
|
||||
android:title="@string/arrival_distance"
|
||||
android:summary="@string/arrival_distance_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" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -675,6 +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 =
|
||||
new FloatPreference("speed_limit_exceed", 5f).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();
|
||||
|
|
|
@ -213,6 +213,8 @@ public class MapActivity extends AccessibleActivity {
|
|||
((FrameLayout)mapView.getParent()).addView(lockView);
|
||||
}
|
||||
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
|
||||
|
||||
mapActions.createOptionsMenuAsDrawer(false);
|
||||
}
|
||||
|
||||
public void addLockView(FrameLayout lockView) {
|
||||
|
@ -466,7 +468,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||
mapActions.openOptionsMenuAsList();
|
||||
mapActions.createOptionsMenuAsDrawer(true);
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
||||
|
|
|
@ -723,12 +723,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public void openOptionsMenuAsDrawer(){
|
||||
public void createOptionsMenuAsDrawer(boolean show){
|
||||
final ContextMenuAdapter cm = createOptionsMenu();
|
||||
final DrawerLayout mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||
final ListView mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
ListAdapter listAdapter ;
|
||||
ListAdapter listAdapter;
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
|
||||
listAdapter =
|
||||
cm.createListAdapter(mapActivity, R.layout.list_menu_item, getMyApplication().getSettings().isLightContentMenu());
|
||||
|
@ -755,7 +755,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
});
|
||||
|
||||
mDrawerLayout.openDrawer(mDrawerList);
|
||||
if (show){
|
||||
mDrawerLayout.openDrawer(mDrawerList);
|
||||
}
|
||||
}
|
||||
|
||||
public AlertDialog openOptionsMenuAsList() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -32,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>();
|
||||
|
@ -109,7 +111,32 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
getString(R.string.arrival_distance_factor_at_last)
|
||||
};
|
||||
registerListPreference(settings.ARRIVAL_DISTANCE_FACTOR, screen, arrivalNames, arrivalValues);
|
||||
|
||||
|
||||
//array size should be equal!
|
||||
Float[] speedLimitsKm = new Float[]{5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsMiles = new Float[]{3f, 5f, 7f, 10f, 15f};
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
String[] speedNames = new String[speedLimitsKm.length];
|
||||
for (int i =0; i<speedLimitsKm.length;i++){
|
||||
speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED, 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);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -175,6 +202,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,7 +157,8 @@ public class WaypointHelper {
|
|||
public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) {
|
||||
Location lastProjection = app.getRoutingHelper().getLastProjection();
|
||||
float mxspeed = route.getCurrentMaxSpeed();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, lastProjection);
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, lastProjection, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm();
|
||||
}
|
||||
|
@ -246,7 +247,8 @@ public class WaypointHelper {
|
|||
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc,
|
||||
MetricsConstants mc, boolean showCameras) {
|
||||
float mxspeed = ro.getMaximumSpeed();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc);
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get();
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc, delta);
|
||||
if (speedAlarm != null) {
|
||||
getVoiceRouter().announceSpeedAlarm();
|
||||
return speedAlarm;
|
||||
|
@ -275,10 +277,9 @@ public class WaypointHelper {
|
|||
}
|
||||
|
||||
|
||||
private static AlarmInfo createSpeedAlarm(MetricsConstants mc, float mxspeed, Location loc) {
|
||||
private static AlarmInfo createSpeedAlarm(MetricsConstants mc, float mxspeed, Location loc, float delta) {
|
||||
AlarmInfo speedAlarm = null;
|
||||
if (mxspeed != 0 && loc != null && loc.hasSpeed() && mxspeed != RouteDataObject.NONE_MAX_SPEED) {
|
||||
float delta = 5f / 3.6f;
|
||||
if (loc.getSpeed() > mxspeed + delta) {
|
||||
int speed;
|
||||
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MapMenuControls extends MapControls {
|
|||
// double lat = activity.getMapView().getLatitude();
|
||||
// double lon = activity.getMapView().getLongitude();
|
||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
mapActivity.getMapActions().createOptionsMenuAsDrawer(true);
|
||||
notifyClicked();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SmallMapMenuControls extends MapControls {
|
|||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
mapActivity.getMapActions().createOptionsMenuAsDrawer(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue