From c35632d21f52770fc6819ea0c8228874b090380f Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 16:28:43 +0200 Subject: [PATCH] Change edit poi controller (cherry picked from commit 836696f) --- .../plus/osmedit/EditPOIMenuController.java | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index be90b2bd7a..ab5bf002be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -5,13 +5,16 @@ import android.graphics.drawable.Drawable; import android.support.v7.app.AlertDialog; import net.osmand.data.PointDescription; +import net.osmand.osm.PoiType; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; -import net.osmand.util.Algorithms; +import net.osmand.plus.render.RenderingIcons; + +import java.util.Map; public class EditPOIMenuController extends MenuController { @@ -94,6 +97,11 @@ public class EditPOIMenuController extends MenuController { } } + @Override + public boolean displayAdditionalTypeStrInHours() { + return true; + } + @Override protected void setObject(Object object) { if (object instanceof OsmPoint) { @@ -112,19 +120,59 @@ public class EditPOIMenuController extends MenuController { @Override public boolean needTypeStr() { - return !Algorithms.isEmpty(pointTypeStr); + return false; } @Override - public Drawable getLeftIcon() { - return getIcon(R.drawable.ic_action_gabout_dark, R.color.created_poi_icon_color); - } - - @Override - public String getTypeStr() { + public String getAdditionalTypeStr() { return pointTypeStr; } + @Override + public int getTimeStrColor() { + if (osmPoint.getAction() == OsmPoint.Action.CREATE) { + return R.color.color_osm_edit_create; + } else if (osmPoint.getAction() == OsmPoint.Action.MODIFY) { + return R.color.color_osm_edit_modify; + } else if (osmPoint.getAction() == OsmPoint.Action.DELETE) { + return R.color.color_osm_edit_delete; + } else { + return R.color.color_osm_edit_modify; + } + } + + @Override + public Drawable getAdditionalLineTypeIcon() { + if (osmPoint.getGroup() == OsmPoint.Group.POI) { + OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; + int iconResId = 0; + String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + if (poiTranslation != null) { + Map poiTypeMap = getMapActivity().getMyApplication().getPoiTypes().getAllTranslatedNames(false); + PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); + if (poiType != null) { + String id = null; + if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) { + id = poiType.getIconKeyName(); + } else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) { + id = poiType.getOsmTag() + "_" + poiType.getOsmValue(); + } + if (id != null) { + iconResId = RenderingIcons.getBigIconResourceId(id); + } + } + } + if (iconResId == 0) { + iconResId = R.drawable.ic_type_info; + } + return getIcon(iconResId); + } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { + return getIcon(R.drawable.ic_type_bug); + } else { + return null; + } + } + @Override public boolean needStreetName() { return false;