From 05b85352efbd91387ffe4b1dd6827e3b1492d63e Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 9 Nov 2015 17:17:32 +0300 Subject: [PATCH] Fixed osm bug context menu --- .../net/osmand/plus/osmedit/OsmBugsLayer.java | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index f2c28764ed..144db14a79 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -279,6 +279,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } } reader.close(); + for (OpenStreetNote note : bugs) { + note.acquireDescriptionAndType(); + } } catch (IOException e) { log.warn("Error loading bugs", e); //$NON-NLS-1$ } catch (NumberFormatException e) { @@ -513,7 +516,10 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider @Override public PointDescription getObjectName(Object o) { if(o instanceof OpenStreetNote){ - return new PointDescription(PointDescription.POINT_TYPE_OSM_NOTE, activity.getString(R.string.osb_bug_name), ""); + OpenStreetNote bug = (OpenStreetNote) o; + String name = bug.description != null ? bug.description : ""; + String typeName = bug.typeName != null ? bug.typeName : activity.getString(R.string.osb_bug_name); + return new PointDescription(PointDescription.POINT_TYPE_OSM_NOTE, typeName, name); } return null; } @@ -567,25 +573,64 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider private static final long serialVersionUID = -7848941747811172615L; private double latitude; private double longitude; - private String name; + private String description; + private String typeName; private List dates = new ArrayList(); private List comments = new ArrayList(); private List users = new ArrayList(); private long id; private boolean opened; + + private void acquireDescriptionAndType() { + for (int i = 0; i < comments.size(); i++) { + StringBuilder sb = new StringBuilder(); + if (i < dates.size()) { + sb.append(dates.get(i)).append(" "); + } + if (i < users.size()) { + sb.append(users.get(i)); + } + description = comments.get(i); + typeName = sb.toString(); + break; + } + if (description != null) { + if (comments.size() > 0) { + comments.remove(0); + } + if (dates.size() > 0) { + dates.remove(0); + } + if (users.size() > 0) { + users.remove(0); + } + } + } + public double getLatitude() { return latitude; } + public void setLatitude(double latitude) { this.latitude = latitude; } + public double getLongitude() { return longitude; } + public void setLongitude(double longitude) { this.longitude = longitude; } + public String getDescription() { + return description; + } + + public String getTypeName() { + return typeName; + } + public String getCommentDescription() { StringBuilder sb = new StringBuilder(); for (String s : getCommentDescriptionList()) {