From 0a6d6923c53fefc5efb696e67021a7b759344e9e Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 13 Nov 2019 11:30:01 +0300 Subject: [PATCH] Issue #7224 Show POI category icons for Add POI quick action --- .../quickaction/actions/AddPOIAction.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java index 6c9fea7834..c2b87c5c2a 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java @@ -1,5 +1,6 @@ package net.osmand.plus.quickaction.actions; +import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; @@ -36,7 +37,6 @@ import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Node; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.osmedit.EditPoiData; @@ -49,6 +49,7 @@ import net.osmand.plus.osmedit.OsmPoint; import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment; import net.osmand.plus.quickaction.CreateEditActionDialog; import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.render.RenderingIcons; import net.osmand.util.Algorithms; import java.lang.reflect.Type; @@ -79,6 +80,29 @@ public class AddPOIAction extends QuickAction { super(quickAction); } + @Override + public int getIconRes(Context context) { + if (context instanceof MapActivity) { + final OsmandApplication application = (OsmandApplication) (context).getApplicationContext(); + final MapPoiTypes poiTypes = application.getPoiTypes(); + final Map allTranslatedNames = poiTypes.getAllTranslatedNames(true); + PoiCategory category = getCategory(allTranslatedNames); + + if (category != null) { + + category.getIconKeyName(); + + String res = category.getIconKeyName(); + if (res instanceof String && RenderingIcons.containsBigIcon(res)) { + return RenderingIcons.getBigIconResourceId(res); + } else { + return super.getIconRes(); + } + } + } + return super.getIconRes(); + } + @Override public void execute(final MapActivity activity) {