Added poi/category type icons to amenity and edit poi context menues

This commit is contained in:
Alexey Kulish 2015-11-20 16:53:05 +03:00
parent f534f5a783
commit 9e8e315966
4 changed files with 49 additions and 9 deletions

View file

@ -132,11 +132,11 @@ public class MenuBuilder {
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);

View file

@ -75,11 +75,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);

View file

@ -89,7 +89,21 @@ public class AmenityMenuController extends MenuController {
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
if (!Algorithms.isEmpty(typeStr)) {
addPlainMenuItem(R.drawable.ic_action_info_dark, typeStr, false);
int resId = 0;
PoiCategory pc = amenity.getType();
if (!Algorithms.isEmpty(getNameStr())) {
resId = getLeftIconId();
}
if (resId == 0) {
resId = RenderingIcons.getBigIconResourceId(pc.getIconKeyName());
}
if (resId == 0) {
resId = getLeftIconId();
}
if (resId == 0) {
resId = R.drawable.ic_action_folder_stroke;
}
addPlainMenuItem(resId, typeStr, false);
}
addMyLocationToPlainItems(pointDescription, amenity.getLocation());
}

View file

@ -2,9 +2,12 @@ package net.osmand.plus.osmedit;
import android.view.View;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.render.RenderingIcons;
import java.util.Map;
@ -29,12 +32,35 @@ public class EditPOIMenuBuilder extends MenuBuilder {
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
String text;
if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) {
text = e.getValue();
} else {
text = e.getKey() + "=" + e.getValue();
String poiTranslation = e.getValue();
Map<String, PoiType> poiTypeMap = MapPoiTypes.getDefault().getAllTranslatedNames(false);
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
int resId = 0;
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) {
resId = RenderingIcons.getBigIconResourceId(id);
}
}
if (resId == 0) {
resId = R.drawable.ic_action_folder_stroke;
}
buildRow(view, resId, poiTranslation, 0, false, 0);
break;
}
}
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) {
continue;
}
String text = e.getKey() + "=" + e.getValue();
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, 0);
}
}