From 5c2e8fe866ea6fd20563f2f7ff6e94b3b81527d3 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 12 Jan 2021 02:36:46 +0200 Subject: [PATCH 1/4] Use "ic_action_street_name" for "Copy address"; Show POI Name in line (and distance) - wikipedia as well; Don't show for public transport. --- .../src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 9 ++++++--- .../plus/mapcontextmenu/builders/AmenityMenuBuilder.java | 3 ++- .../builders/TransportStopMenuBuilder.java | 1 + .../net/osmand/plus/mapcontextmenu/other/ShareMenu.java | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index d11d27d34c..f6a80885b5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -357,9 +357,10 @@ public class MenuBuilder { } protected void buildNearestPoiRow(View view) { - buildNearestRow(view, nearestPoi, processNearestPoi(), - nearestPoi.isEmpty() ? 0 : AmenityMenuController.getRightIconId(nearestPoi.get(0)), - app.getString(R.string.speak_poi)); + if (amenity != null) { + buildNearestRow(view, nearestPoi, processNearestPoi(), AmenityMenuController.getRightIconId(amenity), + app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")"); + } } protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { @@ -1164,6 +1165,8 @@ public class MenuBuilder { if (Algorithms.isBlank(name)) { name = AmenityMenuController.getTypeStr(poi); } + float dist = (float) MapUtils.getDistance(latLon, poi.getLocation()); + name += " (" + OsmAndFormatter.getFormattedDistance(dist, app) + ")"; button.setText(name); button.setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index c0db653e3e..1a107eb61b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -678,7 +678,8 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestPoi() && nearestPoi.size() > 0) { AmenityInfoRow poiInfo = new AmenityInfoRow( - "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.speak_poi) + " (" + nearestPoi.size() + ")", true, + "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, + app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", true, getCollapsableView(view.getContext(), true, nearestPoi), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, poiInfo); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/TransportStopMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/TransportStopMenuBuilder.java index daf43689d2..52e370108c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/TransportStopMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/TransportStopMenuBuilder.java @@ -23,6 +23,7 @@ public class TransportStopMenuBuilder extends MenuBuilder { AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, amenity); builder.setLatLon(getLatLon()); builder.setLight(light); + builder.setShowNearestPoi(false); builder.buildInternal(view); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java index aba6ca8277..f688212204 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java @@ -36,7 +36,7 @@ public class ShareMenu extends BaseMenuController { public enum ShareItem { MESSAGE(R.drawable.ic_action_message, R.string.shared_string_send), CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy), - ADDRESS(R.drawable.ic_action_copy, R.string.copy_address), + ADDRESS(R.drawable.ic_action_street_name, R.string.copy_address), NAME(R.drawable.ic_action_copy, R.string.copy_location_name), COORDINATES(R.drawable.ic_action_copy, R.string.copy_coordinates), GEO(R.drawable.ic_world_globe_dark, R.string.share_geo), From c457f8859dc95621b4174aead82d5bb9af1f8194 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 12 Jan 2021 10:51:39 +0200 Subject: [PATCH 2/4] recovering deleted code (for show POI Name in line) after merge --- .../mapcontextmenu/builders/AmenityMenuBuilder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 0d097eabfb..e27bdfcc50 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -684,18 +684,18 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestWiki() && nearestWiki.size() > 0) { AmenityInfoRow wikiInfo = new AmenityInfoRow( - "nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", - null, true, - getCollapsableView(view.getContext(), true, nearestWiki), + "nearest_wiki", R.drawable.ic_plugin_wikipedia, null, + app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", + null, true, getCollapsableView(view.getContext(), true, nearestWiki), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, wikiInfo); } if (processNearestPoi() && nearestPoi.size() > 0) { AmenityInfoRow poiInfo = new AmenityInfoRow( - "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.speak_poi) + " (" + nearestPoi.size() + ")", - null, true, - getCollapsableView(view.getContext(), true, nearestPoi), + "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, + app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", + null, true, getCollapsableView(view.getContext(), true, nearestPoi), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, poiInfo); } From f2dce5a073f4ad4c83e134712516f411566b913f Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 13 Jan 2021 11:01:51 +0200 Subject: [PATCH 3/4] "Show on map" as last button - wikipedia as well, show on map open map UI + search bar with category name (already implemented) / Hide POI (if already visible) --- .../plus/mapcontextmenu/MenuBuilder.java | 73 ++++++++++++++++--- .../builders/AmenityMenuBuilder.java | 8 +- .../builders/FavouritePointMenuBuilder.java | 4 +- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index f6a80885b5..64f2e0668d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -66,8 +66,10 @@ import net.osmand.plus.openplacereviews.AddPhotosBottomSheetDialogFragment; import net.osmand.plus.openplacereviews.OPRConstants; import net.osmand.plus.openplacereviews.OprStartFragment; import net.osmand.plus.osmedit.opr.OpenDBAPI; +import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RenderingIcons; +import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchToolbarController; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.views.layers.TransportStopsLayer; @@ -117,6 +119,9 @@ public class MenuBuilder { private boolean showOnlinePhotos = true; protected List nearestWiki = new ArrayList<>(); protected List nearestPoi = new ArrayList<>(); + protected final String keyWiki = "nearest_wiki"; + protected final String keyPoi = "nearest_poi"; + private PoiUIFilter poiFilter; private List menuPlugins = new ArrayList<>(); @Nullable private CardsRowBuilder onlinePhotoCardsRow; @@ -353,20 +358,20 @@ public class MenuBuilder { protected void buildNearestWikiRow(View view) { buildNearestRow(view, nearestWiki, processNearestWiki(), - R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around)); + R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around), keyWiki); } protected void buildNearestPoiRow(View view) { if (amenity != null) { buildNearestRow(view, nearestPoi, processNearestPoi(), AmenityMenuController.getRightIconId(amenity), - app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")"); + app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", keyPoi); } } - protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { + protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text, String amenityKey) { if (process && nearestAmenities.size() > 0) { buildRow(view, iconId, null, text + " (" + nearestAmenities.size() + ")", 0, true, - getCollapsableView(view.getContext(), true, nearestAmenities), false, 0, false, null, false); + getCollapsableView(view.getContext(), true, nearestAmenities, amenityKey), false, 0, false, null, false); } } @@ -1156,7 +1161,7 @@ public class MenuBuilder { return new CollapsableView(textView, this, collapsed); } - protected CollapsableView getCollapsableView(Context context, boolean collapsed, List nearestAmenities) { + protected CollapsableView getCollapsableView(Context context, boolean collapsed, List nearestAmenities, final String amenityKey) { LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true); for (final Amenity poi : nearestAmenities) { @@ -1180,6 +1185,54 @@ public class MenuBuilder { view.addView(button); } + final PoiUIFilter filter; + if (amenityKey.equals(keyPoi)) { + filter = poiFilter; + } else if (amenityKey.equals(keyWiki)) { + filter = app.getPoiFilters().getTopWikiPoiFilter(); + } else { + filter = null; + } + if (filter != null) { + TextViewEx buttonShowAll = buildButtonInCollapsableView(context, false, false); + buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map)); + buttonShowAll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final PoiFiltersHelper ph = app.getPoiFilters(); + ph.clearSelectedPoiFilters(); + ph.addSelectedPoiFilter(filter); + final QuickSearchToolbarController controller = new QuickSearchToolbarController(); + controller.setTitle(filter.getName()); + controller.setOnBackButtonClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mapActivity.showQuickSearch(filter); + } + }); + controller.setOnTitleClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mapActivity.showQuickSearch(filter); + } + }); + controller.setOnCloseButtonClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ph.clearSelectedPoiFilters(); + mapActivity.hideTopToolbar(controller); + mapActivity.refreshMap(); + } + }); + mapContextMenu.hideMenues(); + mapActivity.showTopToolbar(controller); + mapActivity.refreshMap(); + } + }); + + view.addView(buttonShowAll); + } + return new CollapsableView(view, this, collapsed); } @@ -1248,9 +1301,9 @@ public class MenuBuilder { if (showNearestPoi && latLon != null && amenity != null) { PoiCategory pc = amenity.getType(); PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType()); - PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName()); - if (filter != null) { - nearestPoi = getSortedAmenities(filter, latLon); + poiFilter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName()); + if (poiFilter != null) { + nearestPoi = getSortedAmenities(poiFilter, latLon); return true; } } @@ -1276,8 +1329,8 @@ public class MenuBuilder { return nearestAmenities; } - private List getAmenities(QuadRect rect, PoiUIFilter wikiPoiFilter) { - return wikiPoiFilter.searchAmenities(rect.top, rect.left, + private List getAmenities(QuadRect rect, PoiUIFilter filter) { + return filter.searchAmenities(rect.top, rect.left, rect.bottom, rect.right, -1, null); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index e27bdfcc50..8b0d02546a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -684,18 +684,18 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestWiki() && nearestWiki.size() > 0) { AmenityInfoRow wikiInfo = new AmenityInfoRow( - "nearest_wiki", R.drawable.ic_plugin_wikipedia, null, + keyWiki, R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", - null, true, getCollapsableView(view.getContext(), true, nearestWiki), + null, true, getCollapsableView(view.getContext(), true, nearestWiki, keyWiki), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, wikiInfo); } if (processNearestPoi() && nearestPoi.size() > 0) { AmenityInfoRow poiInfo = new AmenityInfoRow( - "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, + keyPoi, AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", - null, true, getCollapsableView(view.getContext(), true, nearestPoi), + null, true, getCollapsableView(view.getContext(), true, nearestPoi, keyPoi), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, poiInfo); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java index 03110c8b32..ca404569b1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java @@ -59,9 +59,9 @@ public class FavouritePointMenuBuilder extends MenuBuilder { } @Override - protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { + protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text, String amenityKey) { if (originObject == null || !(originObject instanceof Amenity)) { - super.buildNearestRow(view, nearestAmenities, process, iconId, text); + super.buildNearestRow(view, nearestAmenities, process, iconId, text, amenityKey); } } From 410f01d21ec11157fb9b39a2091f93db19cfae86 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sat, 16 Jan 2021 17:05:45 +0200 Subject: [PATCH 4/4] Minor fixes --- .../plus/mapcontextmenu/MenuBuilder.java | 127 ++++++++++-------- .../builders/AmenityMenuBuilder.java | 8 +- 2 files changed, 72 insertions(+), 63 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 64f2e0668d..41a7abbf27 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -102,6 +102,8 @@ public class MenuBuilder { public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; protected static final String[] arrowChars = new String[] {"=>", " - "}; + protected final String NEAREST_WIKI_KEY = "nearest_wiki_key"; + protected final String NEAREST_POI_KEY = "nearest_poi_key"; protected MapActivity mapActivity; protected MapContextMenu mapContextMenu; @@ -119,9 +121,6 @@ public class MenuBuilder { private boolean showOnlinePhotos = true; protected List nearestWiki = new ArrayList<>(); protected List nearestPoi = new ArrayList<>(); - protected final String keyWiki = "nearest_wiki"; - protected final String keyPoi = "nearest_poi"; - private PoiUIFilter poiFilter; private List menuPlugins = new ArrayList<>(); @Nullable private CardsRowBuilder onlinePhotoCardsRow; @@ -358,13 +357,13 @@ public class MenuBuilder { protected void buildNearestWikiRow(View view) { buildNearestRow(view, nearestWiki, processNearestWiki(), - R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around), keyWiki); + R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around), NEAREST_WIKI_KEY); } protected void buildNearestPoiRow(View view) { if (amenity != null) { buildNearestRow(view, nearestPoi, processNearestPoi(), AmenityMenuController.getRightIconId(amenity), - app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", keyPoi); + app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", NEAREST_POI_KEY); } } @@ -1161,8 +1160,8 @@ public class MenuBuilder { return new CollapsableView(textView, this, collapsed); } - protected CollapsableView getCollapsableView(Context context, boolean collapsed, List nearestAmenities, final String amenityKey) { - LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true); + protected CollapsableView getCollapsableView(Context context, boolean collapsed, List nearestAmenities, String nearestPoiType) { + LinearLayout view = buildCollapsableContentView(context, collapsed, true); for (final Amenity poi : nearestAmenities) { TextViewEx button = buildButtonInCollapsableView(context, false, false); @@ -1184,58 +1183,52 @@ public class MenuBuilder { }); view.addView(button); } - - final PoiUIFilter filter; - if (amenityKey.equals(keyPoi)) { - filter = poiFilter; - } else if (amenityKey.equals(keyWiki)) { - filter = app.getPoiFilters().getTopWikiPoiFilter(); - } else { - filter = null; - } + PoiUIFilter filter = getPoiFilterForType(nearestPoiType); if (filter != null) { - TextViewEx buttonShowAll = buildButtonInCollapsableView(context, false, false); - buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map)); - buttonShowAll.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final PoiFiltersHelper ph = app.getPoiFilters(); - ph.clearSelectedPoiFilters(); - ph.addSelectedPoiFilter(filter); - final QuickSearchToolbarController controller = new QuickSearchToolbarController(); - controller.setTitle(filter.getName()); - controller.setOnBackButtonClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - mapActivity.showQuickSearch(filter); - } - }); - controller.setOnTitleClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - mapActivity.showQuickSearch(filter); - } - }); - controller.setOnCloseButtonClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - ph.clearSelectedPoiFilters(); - mapActivity.hideTopToolbar(controller); - mapActivity.refreshMap(); - } - }); - mapContextMenu.hideMenues(); - mapActivity.showTopToolbar(controller); - mapActivity.refreshMap(); - } - }); - - view.addView(buttonShowAll); + view.addView(createShowAllButton(context, filter)); } - return new CollapsableView(view, this, collapsed); } + private View createShowAllButton(Context context, final PoiUIFilter filter) { + TextViewEx buttonShowAll = buildButtonInCollapsableView(context, false, false); + buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map)); + buttonShowAll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final PoiFiltersHelper poiFiltersHelper = app.getPoiFilters(); + poiFiltersHelper.clearSelectedPoiFilters(); + poiFiltersHelper.addSelectedPoiFilter(filter); + final QuickSearchToolbarController controller = new QuickSearchToolbarController(); + controller.setTitle(filter.getName()); + controller.setOnBackButtonClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mapContextMenu.show(); + } + }); + controller.setOnTitleClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mapActivity.showQuickSearch(filter); + } + }); + controller.setOnCloseButtonClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + poiFiltersHelper.clearSelectedPoiFilters(); + mapActivity.hideTopToolbar(controller); + mapActivity.refreshMap(); + } + }); + mapContextMenu.hideMenues(); + mapActivity.showTopToolbar(controller); + mapActivity.refreshMap(); + } + }); + return buttonShowAll; + } + protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) { final LinearLayout view = new LinearLayout(context); view.setOrientation(LinearLayout.VERTICAL); @@ -1299,17 +1292,33 @@ public class MenuBuilder { protected boolean processNearestPoi() { if (showNearestPoi && latLon != null && amenity != null) { - PoiCategory pc = amenity.getType(); - PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType()); - poiFilter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName()); - if (poiFilter != null) { - nearestPoi = getSortedAmenities(poiFilter, latLon); + PoiUIFilter filter = getPoiFilterForAmenity(amenity); + if (filter != null) { + nearestPoi = getSortedAmenities(filter, latLon); return true; } } return false; } + private PoiUIFilter getPoiFilterForType(String nearestPoiType) { + if (NEAREST_POI_KEY.equals(nearestPoiType)) { + return getPoiFilterForAmenity(amenity); + } else if (NEAREST_WIKI_KEY.equals(nearestPoiType)) { + return app.getPoiFilters().getTopWikiPoiFilter(); + } + return null; + } + + private PoiUIFilter getPoiFilterForAmenity(Amenity amenity) { + if (amenity != null) { + PoiCategory category = amenity.getType(); + PoiType poiType = category.getPoiTypeByKeyName(amenity.getSubType()); + return app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + poiType.getKeyName()); + } + return null; + } + private List getSortedAmenities(PoiUIFilter filter, final LatLon latLon) { QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 8b0d02546a..54e04071fa 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -684,18 +684,18 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestWiki() && nearestWiki.size() > 0) { AmenityInfoRow wikiInfo = new AmenityInfoRow( - keyWiki, R.drawable.ic_plugin_wikipedia, null, + NEAREST_WIKI_KEY, R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", - null, true, getCollapsableView(view.getContext(), true, nearestWiki, keyWiki), + null, true, getCollapsableView(view.getContext(), true, nearestWiki, NEAREST_WIKI_KEY), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, wikiInfo); } if (processNearestPoi() && nearestPoi.size() > 0) { AmenityInfoRow poiInfo = new AmenityInfoRow( - keyPoi, AmenityMenuController.getRightIconId(amenity), null, + NEAREST_POI_KEY, AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", - null, true, getCollapsableView(view.getContext(), true, nearestPoi, keyPoi), + null, true, getCollapsableView(view.getContext(), true, nearestPoi, NEAREST_POI_KEY), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, poiInfo); }