Fixed icons on map for OSM Note (no small icons yet), other fixes
This commit is contained in:
parent
977c75af8f
commit
be325e09c6
2 changed files with 68 additions and 79 deletions
|
@ -3,6 +3,8 @@ package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
@ -20,6 +22,7 @@ import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
|
import net.osmand.data.QuadTree;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.osm.io.NetworkUtils;
|
import net.osmand.osm.io.NetworkUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -27,7 +30,6 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.DialogProvider;
|
import net.osmand.plus.activities.DialogProvider;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.osmedit.OsmPoint.Action;
|
|
||||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
@ -51,11 +53,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
private final OsmEditingPlugin plugin;
|
private final OsmEditingPlugin plugin;
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
|
||||||
private Paint pointClosedUI;
|
private Paint paintIcon;
|
||||||
private Paint pointOpenedUI;
|
private Bitmap unresolvedNote;
|
||||||
private Paint pointNotSubmitedUI;
|
private Bitmap resolvedNote;
|
||||||
|
private Bitmap unresolvedNoteSmall;
|
||||||
|
private Bitmap resolvedNoteSmall;
|
||||||
|
|
||||||
private final MapActivity activity;
|
private final MapActivity activity;
|
||||||
|
|
||||||
private static final String KEY_AUTHOR = "author";
|
private static final String KEY_AUTHOR = "author";
|
||||||
|
@ -90,16 +94,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
pointOpenedUI = new Paint();
|
|
||||||
pointOpenedUI.setColor(activity.getResources().getColor(R.color.osmbug_opened));
|
paintIcon = new Paint();
|
||||||
pointOpenedUI.setAntiAlias(true);
|
resolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_resolved);
|
||||||
pointNotSubmitedUI = new Paint();
|
unresolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_unresolved);
|
||||||
pointNotSubmitedUI.setColor(activity.getResources().getColor(R.color.osmbug_not_submitted));
|
resolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||||
pointNotSubmitedUI.setAntiAlias(true);
|
unresolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||||
pointClosedUI = new Paint();
|
|
||||||
pointClosedUI.setColor(activity.getResources().getColor(R.color.osmbug_closed));
|
|
||||||
pointClosedUI.setAntiAlias(true);
|
|
||||||
|
|
||||||
data = new OsmandMapLayer.MapLayerData<List<OpenStreetNote>>() {
|
data = new OsmandMapLayer.MapLayerData<List<OpenStreetNote>>() {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -120,7 +121,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawInScreenPixels() {
|
public boolean drawInScreenPixels() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,12 +130,37 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
// request to load
|
// request to load
|
||||||
data.queryNewData(tileBox);
|
data.queryNewData(tileBox);
|
||||||
List<OpenStreetNote> objects = data.getResults();
|
List<OpenStreetNote> objects = data.getResults();
|
||||||
|
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
|
float iconSize = resolvedNote.getWidth() * 3 / 2.5f;
|
||||||
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||||
|
List<OpenStreetNote> fullObjects = new ArrayList<>();
|
||||||
for (OpenStreetNote o : objects) {
|
for (OpenStreetNote o : objects) {
|
||||||
int x = tileBox.getPixXFromLonNoRot(o.getLongitude());
|
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
int y = tileBox.getPixYFromLatNoRot(o.getLatitude());
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
canvas.drawCircle(x, y, getRadiusBug(tileBox), o.isLocal() ? pointNotSubmitedUI
|
|
||||||
: (o.isOpened() ? pointOpenedUI : pointClosedUI));
|
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||||
|
Bitmap b;
|
||||||
|
if (o.isOpened()) {
|
||||||
|
b = unresolvedNoteSmall;
|
||||||
|
} else {
|
||||||
|
b = resolvedNoteSmall;
|
||||||
|
}
|
||||||
|
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
|
||||||
|
} else {
|
||||||
|
fullObjects.add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (OpenStreetNote o : fullObjects) {
|
||||||
|
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
|
Bitmap b;
|
||||||
|
if (o.isOpened()) {
|
||||||
|
b = unresolvedNote;
|
||||||
|
} else {
|
||||||
|
b = resolvedNote;
|
||||||
|
}
|
||||||
|
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,20 +312,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
log.warn("Error loading bugs", e); //$NON-NLS-1$
|
log.warn("Error loading bugs", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
for(OsmNotesPoint p : local.getOsmbugsPoints() ) {
|
|
||||||
if(p.getId() < 0 ) {
|
|
||||||
OpenStreetNote bug = new OpenStreetNote();
|
|
||||||
bug.setId(p.getId());
|
|
||||||
bug.setLongitude(p.getLongitude());
|
|
||||||
bug.setLatitude(p.getLatitude());
|
|
||||||
bug.dates.add("");
|
|
||||||
bug.users.add(activity.getMyApplication().getSettings().USER_NAME.get());
|
|
||||||
bug.comments.add(p.getText());
|
|
||||||
bug.setOpened(p.getAction() == Action.CREATE || p.getAction() == Action.MODIFY);
|
|
||||||
bug.setLocal(true);
|
|
||||||
bugs.add(bug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bugs;
|
return bugs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,12 +323,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
dialogBundle.putString(KEY_AUTHOR, settings.USER_NAME.get());
|
dialogBundle.putString(KEY_AUTHOR, settings.USER_NAME.get());
|
||||||
createOpenBugDialog(dialogBundle).show();
|
createOpenBugDialog(dialogBundle).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareOpenBugDialog(Dialog dlg, Bundle args) {
|
|
||||||
((EditText)dlg.findViewById(R.id.messageEditText)).setText(args.getString(KEY_MESSAGE));
|
|
||||||
((EditText)dlg.findViewById(R.id.userNameEditText)).setText(args.getString(KEY_AUTHOR));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dialog createOpenBugDialog(final Bundle args) {
|
private Dialog createOpenBugDialog(final Bundle args) {
|
||||||
final View openBug = activity.getLayoutInflater().inflate(R.layout.open_bug, null);
|
final View openBug = activity.getLayoutInflater().inflate(R.layout.open_bug, null);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
@ -365,7 +372,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
openBugAlertDialog(latitude, longitude, text);
|
openBugAlertDialog(latitude, longitude, text);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
executeTaskInBackground(task);
|
executeTaskInBackground(task);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +396,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
} else {
|
} else {
|
||||||
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.osb_comment_dialog_error) + "\n" + warn, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.osb_comment_dialog_error) + "\n" + warn, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
executeTaskInBackground(task);
|
executeTaskInBackground(task);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +502,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
AccessibleToast.makeText(activity, activity.getString(R.string.osb_close_dialog_error) + "\n" + closed,
|
AccessibleToast.makeText(activity, activity.getString(R.string.osb_close_dialog_error) + "\n" + closed,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
executeTaskInBackground(task);
|
executeTaskInBackground(task);
|
||||||
}
|
}
|
||||||
|
@ -577,17 +584,16 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
private boolean opened;
|
private boolean opened;
|
||||||
|
|
||||||
private void acquireDescriptionAndType() {
|
private void acquireDescriptionAndType() {
|
||||||
for (int i = 0; i < comments.size(); i++) {
|
if (comments.size() > 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (i < dates.size()) {
|
if (dates.size() > 0) {
|
||||||
sb.append(dates.get(i)).append(" ");
|
sb.append(dates.get(0)).append(" ");
|
||||||
}
|
}
|
||||||
if (i < users.size()) {
|
if (users.size() > 0) {
|
||||||
sb.append(users.get(i));
|
sb.append(users.get(0));
|
||||||
}
|
}
|
||||||
description = comments.get(i);
|
description = comments.get(0);
|
||||||
typeName = sb.toString();
|
typeName = sb.toString();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
if (comments.size() > 0) {
|
if (comments.size() > 0) {
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import java.util.List;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.views.ContextMenuLayer;
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
import java.util.List;
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.PointF;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on
|
* Created by Denis on
|
||||||
|
@ -31,9 +29,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
private Bitmap poi;
|
private Bitmap poi;
|
||||||
private Bitmap bug;
|
private Bitmap bug;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private Paint pointAtUI;
|
|
||||||
private Paint paintIcon;
|
private Paint paintIcon;
|
||||||
private Paint point;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,20 +42,9 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
|
|
||||||
pointAtUI = new Paint();
|
|
||||||
pointAtUI.setColor(0xa0FF3344);
|
|
||||||
pointAtUI.setStyle(Paint.Style.FILL);
|
|
||||||
|
|
||||||
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
||||||
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
||||||
|
|
||||||
paintIcon = new Paint();
|
paintIcon = new Paint();
|
||||||
|
|
||||||
point = new Paint();
|
|
||||||
point.setColor(Color.RED);
|
|
||||||
point.setAntiAlias(true);
|
|
||||||
point.setStyle(Paint.Style.STROKE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,9 +62,8 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
|
|
||||||
private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List<? extends OsmPoint> objects) {
|
private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List<? extends OsmPoint> objects) {
|
||||||
for (OsmPoint o : objects) {
|
for (OsmPoint o : objects) {
|
||||||
int locationX = tileBox.getPixXFromLonNoRot(o.getLongitude());
|
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
int locationY = tileBox.getPixYFromLatNoRot(o.getLatitude());
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
canvas.rotate(-view.getRotate(), locationX, locationY);
|
|
||||||
Bitmap b;
|
Bitmap b;
|
||||||
if (o.getGroup() == OsmPoint.Group.POI) {
|
if (o.getGroup() == OsmPoint.Group.POI) {
|
||||||
b = poi;
|
b = poi;
|
||||||
|
@ -88,8 +72,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
} else {
|
} else {
|
||||||
b = poi;
|
b = poi;
|
||||||
}
|
}
|
||||||
canvas.drawBitmap(b, locationX - b.getWidth() / 2, locationY - b.getHeight() / 2, paintIcon);
|
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
|
||||||
canvas.rotate(view.getRotate(), locationX, locationY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +83,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawInScreenPixels() {
|
public boolean drawInScreenPixels() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue