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;
}
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();
}
}
}
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();
}
Aggregations