Add option to display position always in center

This commit is contained in:
vshcherb 2014-04-28 02:05:27 +02:00
parent 71625c67cc
commit 76df14c588
4 changed files with 18 additions and 38 deletions

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="always_center_position_on_map">Display position always in center</string>
<string name="voice_pref_title">Voice</string> <string name="voice_pref_title">Voice</string>
<string name="misc_pref_title">Miscallenious</string> <string name="misc_pref_title">Miscallenious</string>
<string name="localization_pref_title">Localization</string> <string name="localization_pref_title">Localization</string>
@ -721,8 +722,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="map_widget_renderer">Map style</string> <string name="map_widget_renderer">Map style</string>
<string name="live_monitoring_mode_off">Start\n online tracking</string> <string name="live_monitoring_mode_off">Start\n online tracking</string>
<string name="live_monitoring_mode_on">Stop\n online tracking</string> <string name="live_monitoring_mode_on">Stop\n online tracking</string>
<string name="position_on_map_descr">Choose location of position marker on the map</string>
<string name="position_on_map">Position marker</string>
<string name="layer_map_appearance">Configure screen</string> <string name="layer_map_appearance">Configure screen</string>
<string name="show_lanes">Show lanes</string> <string name="show_lanes">Show lanes</string>
<string name="avoid_unpaved">Avoid unpaved roads</string> <string name="avoid_unpaved">Avoid unpaved roads</string>

View file

@ -866,12 +866,7 @@ public class OsmandSettings {
// 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 int CENTER_CONSTANT = 0; public static final int CENTER_CONSTANT = 0;
public static final int BOTTOM_CONSTANT = 1; public static final int BOTTOM_CONSTANT = 1;
public final CommonPreference<Integer> POSITION_ON_MAP = new IntPreference("position_on_map", CENTER_CONSTANT).makeProfile(); public final CommonPreference<Boolean> CENTER_POSITION_ON_MAP = new BooleanPreference("center_position_on_map", false).makeProfile();
{
POSITION_ON_MAP.setModeDefaultValue(ApplicationMode.CAR, BOTTOM_CONSTANT);
POSITION_ON_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, BOTTOM_CONSTANT);
POSITION_ON_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, CENTER_CONSTANT);
}
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Integer> MAX_LEVEL_TO_DOWNLOAD_TILE = new IntPreference("max_level_download_tile", 18).makeProfile().cache(); public final OsmandPreference<Integer> MAX_LEVEL_TO_DOWNLOAD_TILE = new IntPreference("max_level_download_tile", 18).makeProfile().cache();

View file

@ -138,8 +138,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_COMPASS || routePlanningMode) { if (settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_COMPASS || routePlanningMode) {
mapView.setRotate(0); mapView.setRotate(0);
} }
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && !routePlanningMode ? OsmandSettings.BOTTOM_CONSTANT mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING
: OsmandSettings.CENTER_CONSTANT); && !routePlanningMode
&& !settings.CENTER_POSITION_ON_MAP.get() ?
OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT);
} }
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation()); registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
} }

View file

@ -72,34 +72,18 @@ public class AppearanceWidgetsFactory {
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
} }
}); });
final MapWidgetRegistry.MapWidgetRegInfo centerPosition = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker,
if (POSITION_ON_THE_MAP) { R.string.always_center_position_on_map,
final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP; "centerPosition", view.getSettings().CENTER_POSITION_ON_MAP);
final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget( centerPosition.setStateChangeListener(new Runnable() {
R.drawable.widget_position_marker, R.string.position_on_map, "position_on_map", posPref); @Override
posMap.setStateChangeListener(new Runnable() { public void run() {
@Override view.getSettings().CENTER_POSITION_ON_MAP.set(!view.getSettings().CENTER_POSITION_ON_MAP.get());
public void run() { map.updateApplicationModeSettings();
String[] entries = new String[] { map.getString(R.string.position_on_map_center), view.refreshMap(true);
map.getString(R.string.position_on_map_bottom) }; mapInfoLayer.recreateControls();
final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, }
OsmandSettings.BOTTOM_CONSTANT }; });
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
int i = Arrays.binarySearch(vals, posPref.get());
b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
posPref.set(vals[which]);
map.updateApplicationModeSettings();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
}
} }
final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, map.getString(R.string.map_widget_renderer), final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, map.getString(R.string.map_widget_renderer),