use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.
the class MapQuickActionLayer method enterMovingMode.
private void enterMovingMode(RotatedTileBox tileBox) {
previousMapPosition = view.getMapPosition();
view.setMapPosition(OsmandSettings.MIDDLE_BOTTOM_CONSTANT);
MapContextMenu menu = mapActivity.getContextMenu();
LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon();
boolean isFollowPoint = isFolowPoint(tileBox, menu);
menu.updateMapCenter(null);
menu.close();
RotatedTileBox rb = new RotatedTileBox(tileBox);
if (!isFollowPoint && previousMapPosition != OsmandSettings.BOTTOM_CONSTANT)
rb.setCenterLocation(0.5f, 0.3f);
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
view.setLatLon(lat, lon);
inMovingMarkerMode = true;
mark(View.INVISIBLE, R.id.map_ruler_layout, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
wasCollapseButtonVisible = true;
collapseButton.setVisibility(View.INVISIBLE);
} else {
wasCollapseButtonVisible = false;
}
view.refreshMap();
}
use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.
the class TransportRouteController method showMenuAndRoute.
private void showMenuAndRoute(LatLon latLon, boolean centerMarker) {
MapContextMenu menu = getMapActivity().getContextMenu();
if (centerMarker) {
menu.setCenterMarker(true);
}
menu.show(latLon, getPointDescription(), transportRoute);
}
use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.
the class TransportRouteController method addPlainMenuItems.
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon);
List<TransportStop> stops = transportRoute.route.getForwardStops();
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
int currentStop = getCurrentStop();
int defaultIcon = transportRoute.type == null ? R.drawable.mx_route_bus_ref : transportRoute.type.getResourceId();
int startPosition = 0;
if (!transportRoute.showWholeRoute) {
startPosition = (currentStop == -1 ? 0 : currentStop);
if (currentStop > 0) {
addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.shared_string_show), getMapActivity().getString(R.string.route_stops_before, currentStop), false, false, new OnClickListener() {
@Override
public void onClick(View arg0) {
MapContextMenu menu = getMapActivity().getContextMenu();
menu.showOrUpdate(latLon, getPointDescription(), transportRoute);
}
});
}
}
for (int i = startPosition; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
if (TextUtils.isEmpty(name)) {
name = getStopType();
}
addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon, null, name, false, false, new OnClickListener() {
@Override
public void onClick(View arg0) {
showTransportStop(stop);
/*
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
getMapActivity().getString(R.string.transport_Stop), name);
LatLon stopLocation = stop.getLocation();
getMapActivity().getMyApplication().getSettings()
.setMapLocationToShow(stopLocation.getLatitude(), stopLocation.getLongitude(),
15, pd, false, transportRoute);
MapActivity.launchMapActivityMoveToTop(getMapActivity());
*/
}
});
}
}
use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.
the class WptPtEditorFragment method save.
@Override
protected void save(final boolean needDismiss) {
String name = Algorithms.isEmpty(getNameTextValue()) ? null : getNameTextValue();
String category = Algorithms.isEmpty(getCategoryTextValue()) ? null : getCategoryTextValue();
String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue();
if (editor.isNew()) {
doAddWpt(name, category, description);
} else {
doUpdateWpt(name, category, description);
}
getMapActivity().refreshMap();
if (needDismiss) {
dismiss(false);
}
MapContextMenu menu = getMapActivity().getContextMenu();
if (menu.getLatLon() != null) {
LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
if (menu.getLatLon().equals(latLon)) {
menu.update(latLon, wpt.getPointDescription(getMapActivity()), wpt);
}
}
saved = true;
}
use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.
the class FavoritePointEditorFragment method doSave.
private void doSave(FavouritePoint favorite, String name, String category, String description, boolean needDismiss) {
if (editor.isNew()) {
doAddFavorite(name, category, description);
} else {
helper.editFavouriteName(favorite, name, category, description);
}
getMapActivity().refreshMap();
if (needDismiss) {
dismiss(false);
}
MapContextMenu menu = getMapActivity().getContextMenu();
LatLon latLon = new LatLon(favorite.getLatitude(), favorite.getLongitude());
if (menu.getLatLon() != null && menu.getLatLon().equals(latLon)) {
menu.update(latLon, favorite.getPointDescription(), favorite);
}
}
Aggregations