From 3061750eb78e94e3bd530e185d3e9dc86a03af42 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 23 Jul 2012 20:12:14 +0200 Subject: [PATCH] Add settings for show limits --- OsmAnd/res/values/strings.xml | 9 +++++++++ OsmAnd/res/xml/settings_pref.xml | 6 ++++++ .../src/net/osmand/plus/OsmandSettings.java | 9 +++++++++ .../plus/activities/SettingsActivity.java | 19 +++++++++++-------- .../net/osmand/plus/views/MapInfoLayer.java | 17 +++++++++++++---- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 38987e5315..99be02c1af 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,15 @@ 1. 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 --> + Show speed cameras (may be forbidden in some countries) + Show speed limits and traffic bumps + Avoid toll roads for route calculation + Show speed cameras + Show speed limits + Avoid toll roads + Changes in 0.8.2 : + \n\t* Improved Routing + Previous navigation was unfinished. Continue following it? (%1$s seconds) Route will be recalculated when location will be found Hours diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index fed811d545..993ecac76c 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -25,6 +25,12 @@ + + + diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index ae9adcb192..340736e410 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -559,7 +559,16 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile(); + + // this value string is synchronized with settings_pref.xml preference name + public final OsmandPreference SHOW_CAMERAS = new BooleanPreference("show_cameras", true).makeGlobal().cache(); + + // this value string is synchronized with settings_pref.xml preference name + public final OsmandPreference SHOW_SPEED_LIMITS = new BooleanPreference("show_speed_limits", true).makeGlobal().cache(); + // this value string is synchronized with settings_pref.xml preference name + public final OsmandPreference AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeGlobal().cache(); + // this value string is synchronized with settings_pref.xml preference name public final CommonPreference SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5).makeProfile(); { diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 3c68d02b36..77910f8433 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -258,15 +258,18 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference // bidForFixHelper.generatePreferenceList(screen, getString(R.string.support_new_features), this); OsmandPlugin.onSettingsActivityCreate(this, screen); - registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE,screen); - registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES,screen); - registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP,screen); - registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE,screen); - registerBooleanPreference(osmandSettings.USE_COMPASS_IN_NAVIGATION,screen); - registerBooleanPreference(osmandSettings.LEFT_SIDE_NAVIGATION,screen); + registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE, screen); + registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES, screen); + registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP, screen); + registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE, screen); + registerBooleanPreference(osmandSettings.USE_COMPASS_IN_NAVIGATION, screen); + registerBooleanPreference(osmandSettings.LEFT_SIDE_NAVIGATION, screen); + + registerBooleanPreference(osmandSettings.SHOW_CAMERAS, screen); + registerBooleanPreference(osmandSettings.SHOW_SPEED_LIMITS, screen); + registerBooleanPreference(osmandSettings.AVOID_TOLL_ROADS, screen); - - registerBooleanPreference(osmandSettings.SHOW_ALTITUDE_INFO,screen); + registerBooleanPreference(osmandSettings.SHOW_ALTITUDE_INFO, screen); CheckBoxPreference nativeCheckbox = registerBooleanPreference(osmandSettings.NATIVE_RENDERING,screen); //disable the checkbox if the library cannot be used diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index d4e0d9f95f..dcc5dde86f 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -6,6 +6,7 @@ import java.util.Arrays; import net.osmand.Algoritms; import net.osmand.OsmAndFormatter; import net.osmand.osm.LatLon; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.routing.AlarmInfo; @@ -628,12 +629,15 @@ public class MapInfoLayer extends OsmandMapLayer { ptext.setAntiAlias(true); ptext.setTextAlign(Align.CENTER); + final OsmandSettings settings = view.getSettings(); final MapInfoControl alarm = new MapInfoControl(map) { private String text = ""; @Override public boolean updateInfo() { - boolean visible = false; - if (routeLayer != null && routingHelper.isFollowingMode()) { + boolean limits = settings.SHOW_SPEED_LIMITS.get(); + boolean cams = settings.SHOW_CAMERAS.get(); + boolean visible = limits || cams; + if (visible && routeLayer != null && routingHelper.isFollowingMode()) { AlarmInfo alarm = routingHelper.getMostImportantAlarm(view.getSettings().METRIC_SYSTEM.get()); if(alarm != null) { if(alarm.getType() == AlarmInfo.SPEED_LIMIT) { @@ -651,6 +655,11 @@ public class MapInfoLayer extends OsmandMapLayer { // text = "STOP"; } visible = text.length() > 0; + if(alarm.getType() == AlarmInfo.SPEED_CAMERA) { + visible = cams; + } else { + visible = limits; + } } } updateVisibility(visible); @@ -789,10 +798,10 @@ public class MapInfoLayer extends OsmandMapLayer { @Override protected void onDraw(Canvas canvas) { - ShadowText.draw(getText().toString(), canvas, topText.getWidth() / 2, topText.getHeight(), topText.getPaint()); + ShadowText.draw(getText().toString(), canvas, topText.getWidth() / 2, topText.getHeight() - 4 * scaleCoefficient, topText.getPaint()); } }; - topText.setGravity(Gravity.CENTER); + topText.getPaint().setTextAlign(Align.CENTER); topText.setTextColor(Color.BLACK); statusBar.addView(topText, params);