Search in sources :

Example 1 with MapContextMenu

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();
}
Also used : LatLon(net.osmand.data.LatLon) RotatedTileBox(net.osmand.data.RotatedTileBox) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) ImageView(android.widget.ImageView) View(android.view.View) TapTargetView(com.getkeepsafe.taptargetview.TapTargetView)

Example 2 with MapContextMenu

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);
}
Also used : MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Example 3 with MapContextMenu

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());
							*/
            }
        });
    }
}
Also used : OnClickListener(android.view.View.OnClickListener) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) TransportStop(net.osmand.data.TransportStop) View(android.view.View)

Example 4 with MapContextMenu

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;
}
Also used : LatLon(net.osmand.data.LatLon) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Example 5 with MapContextMenu

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);
    }
}
Also used : LatLon(net.osmand.data.LatLon) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Aggregations

MapContextMenu (net.osmand.plus.mapcontextmenu.MapContextMenu)13 LatLon (net.osmand.data.LatLon)8 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 PointDescription (net.osmand.data.PointDescription)2 RoutingHelper (net.osmand.plus.routing.RoutingHelper)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 ImageView (android.widget.ImageView)1 TapTargetView (com.getkeepsafe.taptargetview.TapTargetView)1 RotatedTileBox (net.osmand.data.RotatedTileBox)1 TransportStop (net.osmand.data.TransportStop)1 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)1 MapActivity (net.osmand.plus.activities.MapActivity)1 MapMultiSelectionMenu (net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu)1