commit
aeaf87e230
2 changed files with 37 additions and 36 deletions
|
@ -97,6 +97,8 @@ public class OsmBugMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||||
|
String link = "https://www.openstreetmap.org/note/" + bug.getId();
|
||||||
|
addPlainMenuItem(R.drawable.ic_action_openstreetmap_logo, null, link, true, true, null);
|
||||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||||
for (String description : bug.getCommentDescriptionList()) {
|
for (String description : bug.getCommentDescriptionList()) {
|
||||||
addPlainMenuItem(R.drawable.ic_action_note_dark, null, description, true, false, null);
|
addPlainMenuItem(R.drawable.ic_action_note_dark, null, description, true, false, null);
|
||||||
|
|
|
@ -292,18 +292,15 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
current.id = Long.parseLong(readText(parser, "id"));
|
current.id = Long.parseLong(readText(parser, "id"));
|
||||||
} else if (parser.getName().equals("comment")) {
|
} else if (parser.getName().equals("comment")) {
|
||||||
commentIndex++;
|
commentIndex++;
|
||||||
|
if (current != null) {
|
||||||
|
current.comments.add(commentIndex, new Comment());
|
||||||
|
}
|
||||||
} else if (parser.getName().equals("user") && current != null) {
|
} else if (parser.getName().equals("user") && current != null) {
|
||||||
if (commentIndex == current.users.size()) {
|
current.comments.get(commentIndex).user = readText(parser, "user");
|
||||||
current.users.add(readText(parser, "user"));
|
|
||||||
}
|
|
||||||
} else if (parser.getName().equals("date") && current != null) {
|
} else if (parser.getName().equals("date") && current != null) {
|
||||||
if (commentIndex == current.dates.size()) {
|
current.comments.get(commentIndex).date = readText(parser, "date");
|
||||||
current.dates.add(readText(parser, "date"));
|
|
||||||
}
|
|
||||||
} else if (parser.getName().equals("text") && current != null) {
|
} else if (parser.getName().equals("text") && current != null) {
|
||||||
if (commentIndex == current.comments.size()) {
|
current.comments.get(commentIndex).text = readText(parser, "text");
|
||||||
current.comments.add(readText(parser, "text"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,33 +549,17 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
private double longitude;
|
private double longitude;
|
||||||
private String description;
|
private String description;
|
||||||
private String typeName;
|
private String typeName;
|
||||||
private List<String> dates = new ArrayList<>();
|
private List<Comment> comments = new ArrayList<>();
|
||||||
private List<String> comments = new ArrayList<>();
|
|
||||||
private List<String> users = new ArrayList<>();
|
|
||||||
private long id;
|
private long id;
|
||||||
private boolean opened;
|
private boolean opened;
|
||||||
|
|
||||||
private void acquireDescriptionAndType() {
|
private void acquireDescriptionAndType() {
|
||||||
if (comments.size() > 0) {
|
if (comments.size() > 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
Comment comment = comments.get(0);
|
||||||
if (dates.size() > 0) {
|
description = comment.text;
|
||||||
sb.append(dates.get(0)).append(" ");
|
typeName = comment.date + " " + comment.user;
|
||||||
}
|
if (description != null && description.length() < 100) {
|
||||||
if (users.size() > 0) {
|
comments.remove(comment);
|
||||||
sb.append(users.get(0));
|
|
||||||
}
|
|
||||||
description = comments.get(0);
|
|
||||||
typeName = sb.toString();
|
|
||||||
}
|
|
||||||
if (description != null && description.length() < 100) {
|
|
||||||
if (comments.size() > 0) {
|
|
||||||
comments.remove(0);
|
|
||||||
}
|
|
||||||
if (dates.size() > 0) {
|
|
||||||
dates.remove(0);
|
|
||||||
}
|
|
||||||
if (users.size() > 0) {
|
|
||||||
users.remove(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,18 +604,19 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
for (int i = 0; i < comments.size(); i++) {
|
for (int i = 0; i < comments.size(); i++) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean needLineFeed = false;
|
boolean needLineFeed = false;
|
||||||
if (i < dates.size()) {
|
Comment comment = comments.get(i);
|
||||||
sb.append(dates.get(i)).append(" ");
|
if (!comment.date.isEmpty()) {
|
||||||
|
sb.append(comment.date).append(" ");
|
||||||
needLineFeed = true;
|
needLineFeed = true;
|
||||||
}
|
}
|
||||||
if (i < users.size()) {
|
if (!comment.user.isEmpty()) {
|
||||||
sb.append(users.get(i)).append(":");
|
sb.append(comment.user).append(":");
|
||||||
needLineFeed = true;
|
needLineFeed = true;
|
||||||
}
|
}
|
||||||
if (needLineFeed) {
|
if (needLineFeed) {
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
sb.append(comments.get(i));
|
sb.append(comment.text);
|
||||||
res.add(sb.toString());
|
res.add(sb.toString());
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -665,5 +647,22 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Comment implements Serializable {
|
||||||
|
|
||||||
|
private String date = "";
|
||||||
|
private String text = "";
|
||||||
|
private String user = "";
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue