Try eliminate position settings

This commit is contained in:
Victor Shcherb 2012-08-31 23:52:44 +02:00
parent 5e6fc19588
commit 574609ec5d
2 changed files with 28 additions and 23 deletions

View file

@ -1075,7 +1075,9 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
mapView.setRotate(0);
}
routingHelper.setAppMode(settings.getApplicationMode());
mapView.setMapPosition(settings.POSITION_ON_MAP.get());
// mapView.setMapPosition(settings.POSITION_ON_MAP.get());
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING ? OsmandSettings.BOTTOM_CONSTANT :
OsmandSettings.CENTER_CONSTANT);
registerUnregisterSensor(getLastKnownLocation(), false);
mapLayers.getMapInfoLayer().recreateControls();
mapLayers.updateLayers(mapView);
@ -1097,6 +1099,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
} else if(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING){
resId = R.string.rotate_map_bearing_opt;
}
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING ? OsmandSettings.BOTTOM_CONSTANT :
OsmandSettings.CENTER_CONSTANT);
AccessibleToast.makeText(this, getString(resId), Toast.LENGTH_SHORT).show();
mapView.refreshMap();

View file

@ -118,28 +118,29 @@ public class OsmandExtraSettings extends OsmandPlugin {
}
});
final CommonPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
"position_on_map", textSizePref);
posMap.setStateChangeListener(new Runnable() {
@Override
public void run() {
String[] entries = new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) };
final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
Builder b = new AlertDialog.Builder(view.getContext());
int i = Arrays.binarySearch(vals, posPref.get());
b.setSingleChoiceItems(entries, i, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
posPref.set(vals[which]);
activity.updateApplicationModeSettings();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
// FIXME delete strings from this code
// final CommonPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
// final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
// "position_on_map", textSizePref);
// posMap.setStateChangeListener(new Runnable() {
// @Override
// public void run() {
// String[] entries = new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) };
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
// Builder b = new AlertDialog.Builder(view.getContext());
// int i = Arrays.binarySearch(vals, posPref.get());
// b.setSingleChoiceItems(entries, i, new OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// posPref.set(vals[which]);
// activity.updateApplicationModeSettings();
// view.refreshMap(true);
// dialog.dismiss();
// }
// });
// b.show();
// }
// });
}
@Override