From 8c921c72a68259d8fc5c08308df90f37fe67c215 Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 13 Nov 2019 11:56:04 +0200 Subject: [PATCH] Fix #7259 --- .../osmand/aidlapi/OsmAndCustomizationConstants.java | 1 + .../osmand/plus/activities/MapActivityActions.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java b/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java index a863364318..a8c0aebb1e 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java @@ -76,6 +76,7 @@ public interface OsmAndCustomizationConstants { String MAP_CONTEXT_MENU_CHANGE_MARKER_POSITION = MAP_CONTEXT_MENU_ACTIONS + "change_m_position"; String MAP_CONTEXT_MENU_MARK_AS_PARKING_LOC = MAP_CONTEXT_MENU_ACTIONS + "mark_as_parking"; String MAP_CONTEXT_MENU_MEASURE_DISTANCE = MAP_CONTEXT_MENU_ACTIONS + "measure_distance"; + String MAP_CONTEXT_MENU_AVOID_ROAD = MAP_CONTEXT_MENU_ACTIONS + "avoid_road"; String MAP_CONTEXT_MENU_EDIT_GPX_WP = MAP_CONTEXT_MENU_ACTIONS + "edit_gpx_waypoint"; String MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT = MAP_CONTEXT_MENU_ACTIONS + "add_gpx_waypoint"; String MAP_CONTEXT_MENU_UPDATE_MAP = MAP_CONTEXT_MENU_ACTIONS + "update_map"; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index a752646aa8..463fe6a259 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -99,6 +99,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SEARCH_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_TRAVEL_GUIDES_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT; +import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_AVOID_ROAD; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_DIRECTIONS_FROM_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_EDIT_GPX_WP; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MEASURE_DISTANCE; @@ -126,6 +127,7 @@ public class MapActivityActions implements DialogProvider { public static final int EDIT_GPX_WAYPOINT_ITEM_ORDER = 9000; public static final int ADD_GPX_WAYPOINT_ITEM_ORDER = 9000; public static final int MEASURE_DISTANCE_ITEM_ORDER = 13000; + public static final int AVOID_ROAD_ITEM_ORDER = 14000; private static final int DIALOG_ADD_FAVORITE = 100; private static final int DIALOG_REPLACE_FAVORITE = 101; @@ -390,6 +392,13 @@ public class MapActivityActions implements DialogProvider { .setOrder(MEASURE_DISTANCE_ITEM_ORDER) .createItem()); + adapter.addItem(itemBuilder + .setTitleId(R.string.avoid_road, mapActivity) + .setId(MAP_CONTEXT_MENU_AVOID_ROAD) + .setIcon(R.drawable.ic_action_alert) + .setOrder(AVOID_ROAD_ITEM_ORDER) + .createItem()); + adapter.sortItemsByOrder(); final ArrayAdapter listAdapter = @@ -417,6 +426,8 @@ public class MapActivityActions implements DialogProvider { } else if (standardId == R.string.measurement_tool) { mapActivity.getContextMenu().close(); MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude)); + } else if (standardId == R.string.avoid_road) { + getMyApplication().getAvoidSpecificRoads().addImpassableRoad(mapActivity, new LatLon(latitude, longitude), true, false); } } });