use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class SearchPOIActivity method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
final OsmandSettings settings = app.getSettings();
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get());
PointDescription name = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
int z = Math.max(16, settings.getLastKnownMapZoom());
LatLon location = amenity.getLocation();
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, name, true, // $NON-NLS-1$
amenity);
MapActivity.launchMapActivityMoveToTop(this);
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class TrackActivity method addNewGpxData.
public void addNewGpxData(NewGpxData.ActionType actionType, TrkSegment segment) {
GPXFile gpxFile = getGpx();
QuadRect rect = getRect();
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
WptPt pointToShow = gpxFile != null ? gpxFile.findPointToShow() : null;
if (pointToShow != null) {
LatLon location = new LatLon(pointToShow.getLatitude(), pointToShow.getLongitude());
final OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_line)), false, newGpxData);
MapActivity.launchMapActivityMoveToTop(this);
}
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class SearchHistoryFragment method selectModel.
private void selectModel(final HistoryEntry model) {
PointDescription name = model.getName();
OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings();
LatLon location = new LatLon(model.getLat(), model.getLon());
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), name, true, // $NON-NLS-1$
model);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class BottomSheetDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
OsmandSettings settings = getMyApplication().getSettings();
int themeId = settings.isLightContent() ? R.style.OsmandLightTheme_BottomSheet : R.style.OsmandDarkTheme_BottomSheet;
BottomSheetDialog dialog = new BottomSheetDialog(getContext(), themeId);
dialog.setCanceledOnTouchOutside(true);
Window window = dialog.getWindow();
if (!settings.DO_NOT_USE_ANIMATIONS.get() && window != null) {
window.getAttributes().windowAnimations = R.style.Animations_PopUpMenu_Bottom;
}
return dialog;
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class MapActivityLayers method selectMapLayer.
public void selectMapLayer(final OsmandMapTileView mapView, final ContextMenuItem it, final ArrayAdapter<ContextMenuItem> adapter) {
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
Toast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
return;
}
final OsmandSettings settings = getApplication().getSettings();
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<>();
final String layerOsmVector = "LAYER_OSM_VECTOR";
final String layerInstallMore = "LAYER_INSTALL_MORE";
final String layerEditInstall = "LAYER_EDIT";
entriesMap.put(layerOsmVector, getString(R.string.vector_data));
entriesMap.putAll(settings.getTileSourceEntries());
entriesMap.put(layerInstallMore, getString(R.string.install_more));
entriesMap.put(layerEditInstall, getString(R.string.maps_define_edit));
final List<Entry<String, String>> entriesMapList = new ArrayList<>(entriesMap.entrySet());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();
int selectedItem = -1;
if (!settings.MAP_ONLINE_DATA.get()) {
selectedItem = 0;
} else {
Entry<String, String> selectedEntry = null;
for (Entry<String, String> entry : entriesMap.entrySet()) {
if (entry.getKey().equals(selectedTileSourceKey)) {
selectedEntry = entry;
break;
}
}
if (selectedEntry != null) {
selectedItem = 0;
entriesMapList.remove(selectedEntry);
entriesMapList.add(0, selectedEntry);
}
}
final String[] items = new String[entriesMapList.size()];
int i = 0;
for (Entry<String, String> entry : entriesMapList) {
items[i++] = entry.getValue();
}
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String layerKey = entriesMapList.get(which).getKey();
switch(layerKey) {
case layerOsmVector:
settings.MAP_ONLINE_DATA.set(false);
updateMapSource(mapView, null);
it.setDescription(null);
adapter.notifyDataSetChanged();
break;
case layerEditInstall:
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {
@Override
public boolean publish(TileSourceTemplate object) {
settings.MAP_TILE_SOURCES.set(object.getName());
settings.MAP_ONLINE_DATA.set(true);
if (it != null) {
it.setDescription(object.getName());
}
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
return true;
}
@Override
public boolean isCancelled() {
return false;
}
});
break;
case layerInstallMore:
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
TileSourceTemplate template = null;
int count = 0;
@Override
public boolean publish(TileSourceTemplate object) {
if (object == null) {
if (count == 1) {
settings.MAP_TILE_SOURCES.set(template.getName());
settings.MAP_ONLINE_DATA.set(true);
it.setDescription(template.getName());
adapter.notifyDataSetChanged();
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
} else {
selectMapLayer(mapView, it, adapter);
}
} else {
count++;
template = object;
}
return false;
}
@Override
public boolean isCancelled() {
return false;
}
});
break;
default:
settings.MAP_TILE_SOURCES.set(layerKey);
settings.MAP_ONLINE_DATA.set(true);
it.setDescription(layerKey);
adapter.notifyDataSetChanged();
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
break;
}
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.shared_string_dismiss, null);
builder.show();
}
Aggregations