Add setting driving region and link it to metric constants by default. Remove setting left hand driving

This commit is contained in:
Victor Shcherb 2013-08-05 00:29:56 +02:00
parent 669fbd5ac3
commit be3d150b48
6 changed files with 53 additions and 8 deletions

View file

@ -10,6 +10,10 @@
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="driving_region_japan">Japan</string>
<string name="driving_region_us">United States</string>
<string name="driving_region_europe_asia">Europe &amp; Asia</string>
<string name="driving_region_uk">UK, India, Australia &amp; Others</string>
<string name="osmodroid_mode_on">Stop OsMoDroid</string> <string name="osmodroid_mode_on">Stop OsMoDroid</string>
<string name="osmodroid_mode_off">Start OsMoDroid</string> <string name="osmodroid_mode_off">Start OsMoDroid</string>
<string name="announce_gpx_waypoints">Announce GPX waypoints</string> <string name="announce_gpx_waypoints">Announce GPX waypoints</string>

View file

@ -562,10 +562,19 @@ public class OsmandSettings {
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new EnumIntPreference<ApplicationMode>( public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new EnumIntPreference<ApplicationMode>(
"default_application_mode", ApplicationMode.DEFAULT, ApplicationMode.values()).makeGlobal(); "default_application_mode", ApplicationMode.DEFAULT, ApplicationMode.values()).makeGlobal();
public final OsmandPreference<DrivingRegion> DRIVING_REGION = new EnumIntPreference<DrivingRegion>(
"default_driving_region", DrivingRegion.EUROPE_ASIA, DrivingRegion.values()).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often // cache of metrics constants as they are used very often
public final OsmandPreference<MetricsConstants> METRIC_SYSTEM = new EnumIntPreference<MetricsConstants>( public final OsmandPreference<MetricsConstants> METRIC_SYSTEM = new EnumIntPreference<MetricsConstants>(
"default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()).makeGlobal().cache(); "default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()){
protected MetricsConstants getDefaultValue() {
return DRIVING_REGION.get().defMetrics;
};
}.makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often // cache of metrics constants as they are used very often
@ -656,8 +665,6 @@ public class OsmandSettings {
SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.BICYCLE, true); SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.BICYCLE, true);
} }
public final CommonPreference<Boolean> LEFT_SIDE_NAVIGATION = new BooleanPreference("left_side_navigation", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$ public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$
@ -1501,4 +1508,31 @@ public class OsmandSettings {
} }
/**
* Class represents specific for driving region
* Signs, leftHandDriving
*/
public enum DrivingRegion {
EUROPE_ASIA(R.string.driving_region_europe_asia, MetricsConstants.KILOMETERS_AND_METERS, false, false),
US_CANADA(R.string.driving_region_us, MetricsConstants.MILES_AND_FOOTS, false, true),
UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_FOOTS, true, false),
JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true, false)
;
public final boolean leftHandDriving;
public final boolean americanSigns;
public final MetricsConstants defMetrics;
public final int name;
DrivingRegion(int name, MetricsConstants def, boolean leftHandDriving, boolean americanSigns) {
this.name = name;
defMetrics = def;
this.leftHandDriving = leftHandDriving;
this.americanSigns = americanSigns;
}
}
} }

View file

@ -9,6 +9,7 @@ import net.osmand.access.AccessibleToast;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext; import net.osmand.plus.ClientContext;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
@ -116,7 +117,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr)); screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen); registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen);
registerBooleanPreference(settings.LEFT_SIDE_NAVIGATION, screen);
// List preferences // List preferences
@ -132,7 +132,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
settings.OSMAND_THEME, screen, settings.OSMAND_THEME, screen,
new String[] { "Dark", "Light", "Dark ActionBar" }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME, new String[] { "Dark", "Light", "Dark ActionBar" }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME,
OsmandSettings.OSMAND_LIGHT_THEME, OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME }); OsmandSettings.OSMAND_LIGHT_THEME, OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME });
MetricsConstants[] mvls = new MetricsConstants[] {MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.MILES_AND_FOOTS, MetricsConstants.MILES_AND_YARDS}; //MetricsConstants.values(); DrivingRegion[] drs = DrivingRegion.values();
entries = new String[drs.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = getString(drs[i].name);
}
registerListPreference(settings.DRIVING_REGION, screen, entries, drs);
MetricsConstants[] mvls = MetricsConstants.values();
entries = new String[mvls.length]; entries = new String[mvls.length];
for(int i=0; i<entries.length; i++){ for(int i=0; i<entries.length; i++){
entries[i] = mvls[i].toHumanString(getMyApplication()); entries[i] = mvls[i].toHumanString(getMyApplication());

View file

@ -79,7 +79,7 @@ public class RouteProvider {
DataTileManager<WptPt> wpt; DataTileManager<WptPt> wpt;
public GPXRouteParams(GPXFile file, boolean reverse, boolean announceWaypoints, OsmandSettings settings){ public GPXRouteParams(GPXFile file, boolean reverse, boolean announceWaypoints, OsmandSettings settings){
prepareEverything(file, reverse, announceWaypoints, settings.LEFT_SIDE_NAVIGATION.get()); prepareEverything(file, reverse, announceWaypoints, settings.DRIVING_REGION.get().leftHandDriving);
} }
public void setStartPoint(Location startPoint) { public void setStartPoint(Location startPoint) {

View file

@ -745,7 +745,7 @@ public class RoutingHelper {
params.intermediates = intermediates; params.intermediates = intermediates;
params.gpxRoute = gpxRoute; params.gpxRoute = gpxRoute;
params.previousToRecalculate = previousRoute; params.previousToRecalculate = previousRoute;
params.leftSide = settings.LEFT_SIDE_NAVIGATION.get(); params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
params.preciseRouting = settings.PRECISE_ROUTING_MODE.getModeValue(mode); params.preciseRouting = settings.PRECISE_ROUTING_MODE.getModeValue(mode);
params.optimal = settings.OPTIMAL_ROUTE_MODE.getModeValue(mode); params.optimal = settings.OPTIMAL_ROUTE_MODE.getModeValue(mode);
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode); params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);

View file

@ -62,7 +62,7 @@ public class RouteInfoWidgetsFactory {
if (makeUturnWhenPossible) { if (makeUturnWhenPossible) {
visible = true; visible = true;
turnImminent = 0; turnImminent = 0;
turnType = TurnType.valueOf(TurnType.TU, settings.LEFT_SIDE_NAVIGATION.get()); turnType = TurnType.valueOf(TurnType.TU, settings.DRIVING_REGION.get().leftHandDriving);
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform); TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
invalidate(); invalidate();
} else { } else {