Search in sources :

Example 11 with MapContextMenu

use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.

the class MapControlsLayer method getPointDescriptionForTarget.

private PointDescription getPointDescriptionForTarget(LatLon latLon) {
    final MapContextMenu menu = mapActivity.getContextMenu();
    PointDescription pointDescription;
    if (menu.isActive() && latLon.equals(menu.getLatLon())) {
        pointDescription = menu.getPointDescriptionForTarget();
    } else {
        pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
    }
    return pointDescription;
}
Also used : PointDescription(net.osmand.data.PointDescription) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Example 12 with MapContextMenu

use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.

the class MapControlsLayer method navigateButton.

public void navigateButton() {
    if (!OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
        ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION);
    } else {
        final MapContextMenu menu = mapActivity.getContextMenu();
        final LatLon latLon = menu.getLatLon();
        final PointDescription pointDescription = menu.getPointDescriptionForTarget();
        menu.hide();
        final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
        RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
        if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
            DirectionsDialogs.addWaypointDialogAndLaunchMap(mapActivity, latLon.getLatitude(), latLon.getLongitude(), pointDescription);
        } else if (targets.getIntermediatePoints().isEmpty()) {
            startRoutePlanningWithDestination(latLon, pointDescription, targets);
            menu.close();
        } else {
            AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
            bld.setTitle(R.string.new_directions_point_dialog);
            final int[] defaultVls = new int[] { 0 };
            bld.setSingleChoiceItems(new String[] { mapActivity.getString(R.string.clear_intermediate_points), mapActivity.getString(R.string.keep_intermediate_points) }, 0, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    defaultVls[0] = which;
                }
            });
            bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (defaultVls[0] == 0) {
                        targets.removeAllWayPoints(false, true);
                        targets.navigateToPoint(latLon, true, -1, pointDescription);
                        mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
                        menu.close();
                    } else {
                        targets.navigateToPoint(latLon, true, -1, pointDescription);
                        mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
                        menu.close();
                    }
                }
            });
            bld.setNegativeButton(R.string.shared_string_cancel, null);
            bld.show();
        }
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LatLon(net.osmand.data.LatLon) DialogInterface(android.content.DialogInterface) PointDescription(net.osmand.data.PointDescription) OnClickListener(android.view.View.OnClickListener) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 13 with MapContextMenu

use of net.osmand.plus.mapcontextmenu.MapContextMenu in project Osmand by osmandapp.

the class AddGpxPointBottomSheetHelper method onDismiss.

@Override
public void onDismiss() {
    MapContextMenu contextMenu = mapActivity.getContextMenu();
    if (contextMenu.isVisible() && contextMenu.isClosable()) {
        contextMenu.close();
    }
    openTrackActivity();
}
Also used : 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