Add option to display position always in center
This commit is contained in:
parent
71625c67cc
commit
76df14c588
4 changed files with 18 additions and 38 deletions
|
@ -9,6 +9,7 @@
|
|||
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="always_center_position_on_map">Display position always in center</string>
|
||||
<string name="voice_pref_title">Voice</string>
|
||||
<string name="misc_pref_title">Miscallenious</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="live_monitoring_mode_off">Start\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="show_lanes">Show lanes</string>
|
||||
<string name="avoid_unpaved">Avoid unpaved roads</string>
|
||||
|
|
|
@ -866,12 +866,7 @@ public class OsmandSettings {
|
|||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public static final int CENTER_CONSTANT = 0;
|
||||
public static final int BOTTOM_CONSTANT = 1;
|
||||
public final CommonPreference<Integer> POSITION_ON_MAP = new IntPreference("position_on_map", CENTER_CONSTANT).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);
|
||||
}
|
||||
public final CommonPreference<Boolean> CENTER_POSITION_ON_MAP = new BooleanPreference("center_position_on_map", false).makeProfile();
|
||||
|
||||
// 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();
|
||||
|
|
|
@ -138,8 +138,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
if (settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_COMPASS || routePlanningMode) {
|
||||
mapView.setRotate(0);
|
||||
}
|
||||
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && !routePlanningMode ? OsmandSettings.BOTTOM_CONSTANT
|
||||
: OsmandSettings.CENTER_CONSTANT);
|
||||
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING
|
||||
&& !routePlanningMode
|
||||
&& !settings.CENTER_POSITION_ON_MAP.get() ?
|
||||
OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT);
|
||||
}
|
||||
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
|
||||
}
|
||||
|
|
|
@ -72,34 +72,18 @@ public class AppearanceWidgetsFactory {
|
|||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
});
|
||||
|
||||
if (POSITION_ON_THE_MAP) {
|
||||
final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
|
||||
final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget(
|
||||
R.drawable.widget_position_marker, R.string.position_on_map, "position_on_map", posPref);
|
||||
posMap.setStateChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String[] entries = new String[] { map.getString(R.string.position_on_map_center),
|
||||
map.getString(R.string.position_on_map_bottom) };
|
||||
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 centerPosition = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker,
|
||||
R.string.always_center_position_on_map,
|
||||
"centerPosition", view.getSettings().CENTER_POSITION_ON_MAP);
|
||||
centerPosition.setStateChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.getSettings().CENTER_POSITION_ON_MAP.set(!view.getSettings().CENTER_POSITION_ON_MAP.get());
|
||||
map.updateApplicationModeSettings();
|
||||
view.refreshMap(true);
|
||||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, map.getString(R.string.map_widget_renderer),
|
||||
|
|
Loading…
Reference in a new issue