From 594d1e70f3cf7dd1529eaf1b54b4d09a2eec46b6 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 13 Nov 2015 10:05:08 +0200 Subject: [PATCH 1/2] Editing allowed --- .../net/osmand/plus/osmedit/OsmEditingPlugin.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 50f24d72b8..ebd7508969 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -18,6 +18,7 @@ import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; import net.osmand.data.Amenity; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Node; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.OsmandApplication; @@ -161,7 +162,15 @@ public class OsmEditingPlugin extends OsmandPlugin { new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity) .execute((Amenity) selectedObj); } else if (resId == R.string.poi_context_menu_modify) { - EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity); + if (selectedObj instanceof Amenity) { + EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity); + } else if (selectedObj instanceof OpenstreetmapPoint) { + final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity(); + EditPoiDialogFragment.createInstance(entity, false) + .show(mapActivity.getSupportFragmentManager(), "edit_poi"); + } else { + throw new IllegalArgumentException("Selected object is not editable"); + } } return true; } @@ -171,6 +180,8 @@ public class OsmEditingPlugin extends OsmandPlugin { Amenity amenity = (Amenity) selectedObj; final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm(); + } else if (selectedObj instanceof OpenstreetmapPoint) { + isEditable = true; } if (isEditable) { adapter.item(R.string.poi_context_menu_modify).iconColor(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg(); From b28a8b5c601ee073f2201315eb07861f792a70d4 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 13 Nov 2015 10:06:18 +0200 Subject: [PATCH 2/2] Fix #1550 WhatsApp location --- .../src/net/osmand/util/GeoPointParserUtil.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java index a4661d7203..6aa1d46e35 100644 --- a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java @@ -397,7 +397,6 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse(url); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); - // TODO this URL does not work, where is it used? // whatsapp // https://maps.google.com/maps?q=loc:34.99393,-106.61568 (You) z = GeoParsedPoint.NO_ZOOM; @@ -406,6 +405,14 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse(url); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + // whatsapp + // https://maps.google.com/maps?q=loc:34.99393,-106.61568 (USERNAME) + z = GeoParsedPoint.NO_ZOOM; + url = "https://maps.google.com/maps?q=loc:" + dlat + "," + dlon + " (USER NAME)"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse(url); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + // http://www.google.com/maps/search/food/34,-106,14z url = "http://www.google.com/maps/search/food/" + ilat + "," + ilon + "," + z + "z"; System.out.println("url: " + url); @@ -947,10 +954,9 @@ public class GeoPointParserUtil { if(opath.contains(pref)) { opath = opath.substring(opath.lastIndexOf(pref) + pref.length()); } - final String postf = " (You)"; - if (opath.contains(postf)) { - opath = opath.substring(0, opath.indexOf(postf)); - } + final String postf = "\\s\\((\\p{IsAlphabetic}|\\s)*\\)$"; + opath = opath.replaceAll(postf, ""); + System.out.println("opath=" + opath); return parseGoogleMapsPath(opath, params); } if (fragment != null) {