From 8efdb1024d926efb9e2c3dc97429778001ef6d71 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 6 Jun 2015 14:16:08 +0200 Subject: [PATCH 1/2] Fix margin --- .../net/osmand/plus/activities/EditPOIFilterActivity.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index 2078f0421d..7c6f3dcd27 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -113,8 +113,6 @@ public class EditPOIFilterActivity extends OsmandListActivity { View v = lv.getChildAt(0); final int top = (v == null) ? 0 : v.getTop(); Builder builder = new AlertDialog.Builder(this); - ScrollView scroll = new ScrollView(this); - ListView listView = new ListView(this); final LinkedHashMap subCategories = new LinkedHashMap(); Set acceptedCategories = filter.getAcceptedSubtypes(poiCategory); if (acceptedCategories != null) { @@ -150,9 +148,6 @@ public class EditPOIFilterActivity extends OsmandListActivity { selected[i] = acceptedCategories.contains(subcategory); } } - - scroll.addView(listView); - builder.setView(scroll); builder.setNeutralButton(EditPOIFilterActivity.this.getText(R.string.shared_string_close), new DialogInterface.OnClickListener() { @Override From 2544e1f27935485e3ef37c88d0e580195eff07af Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 6 Jun 2015 16:34:02 +0200 Subject: [PATCH 2/2] Fix next turn arrow --- .../osmand/plus/views/OsmandMapTileView.java | 1 + .../src/net/osmand/plus/views/RouteLayer.java | 146 ++++++++++-------- 2 files changed, 80 insertions(+), 67 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 2480624671..f9c20d5781 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -461,6 +461,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback { canvas.restore(); } catch (IndexOutOfBoundsException e) { // skip it + canvas.restore(); } } Bitmap t = bufferBitmap; diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 938a6ff481..f86afdab7d 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -124,8 +124,6 @@ public class RouteLayer extends OsmandMapLayer { paint.setStrokeWidth(12 * view.getDensity()); } osmandRenderer.updatePaint(req, actionPaint, 2, false, rc); - // TODO remove - // actionPaint.setColor(Color.BLUE); paintIconAction.setColorFilter(new PorterDuffColorFilter(actionPaint.getColor(), Mode.MULTIPLY)); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); @@ -191,79 +189,84 @@ public class RouteLayer extends OsmandMapLayer { private void drawAction(RotatedTileBox tb, Canvas canvas) { if (actionPoints.size() > 0) { canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); - Path pth = new Path(); - Matrix matrix = new Matrix(); - boolean first = true; - int x = 0, px = 0, py = 0, y = 0; - for (int i = 0; i < actionPoints.size(); i++) { - Location o = actionPoints.get(i); - if (o == null) { - canvas.drawPath(pth, actionPaint); - double angleRad = Math.atan2(y - py, x - px); - double angle = (angleRad * 180 / Math.PI) + 90f; - double distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px)); - if (distSegment == 0) { - continue; - } - // int len = (int) (distSegment / pxStep); - float pdx = x - px; - float pdy = y - py; - matrix.reset(); - matrix.postTranslate(0, -actionArrow.getHeight() / 2); - matrix.postRotate((float) angle, actionArrow.getWidth() / 2, 0); - matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy); - canvas.drawBitmap(actionArrow, matrix, paintIconAction); - first = true; - } else { - px = x; - py = y; - x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); - y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); - if(first) { - pth.reset(); - pth.moveTo(x, y); - first = false; + try { + Path pth = new Path(); + Matrix matrix = new Matrix(); + boolean first = true; + int x = 0, px = 0, py = 0, y = 0; + for (int i = 0; i < actionPoints.size(); i++) { + Location o = actionPoints.get(i); + if (o == null) { + canvas.drawPath(pth, actionPaint); + double angleRad = Math.atan2(y - py, x - px); + double angle = (angleRad * 180 / Math.PI) + 90f; + double distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px)); + if (distSegment == 0) { + continue; + } + // int len = (int) (distSegment / pxStep); + float pdx = x - px; + float pdy = y - py; + matrix.reset(); + matrix.postTranslate(0, -actionArrow.getHeight() / 2); + matrix.postRotate((float) angle, actionArrow.getWidth() / 2, 0); + matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy); + canvas.drawBitmap(actionArrow, matrix, paintIconAction); + first = true; } else { - pth.lineTo(x, y); + px = x; + py = y; + x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); + y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); + if (first) { + pth.reset(); + pth.moveTo(x, y); + first = false; + } else { + pth.lineTo(x, y); + } } } + + } finally { + canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } - - canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } } private void drawSegment(RotatedTileBox tb, Canvas canvas) { if (points.size() > 0) { canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); - - TIntArrayList tx = new TIntArrayList(); - TIntArrayList ty = new TIntArrayList(); - for (int i = 0; i < points.size(); i++) { - Location o = points.get(i); - int x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); - int y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); - tx.add(x); - ty.add(y); + try { + TIntArrayList tx = new TIntArrayList(); + TIntArrayList ty = new TIntArrayList(); + for (int i = 0; i < points.size(); i++) { + Location o = points.get(i); + int x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); + int y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); + tx.add(x); + ty.add(y); + } + calculatePath(tb, tx, ty, path); + + if (isPaint_1) { + canvas.drawPath(path, paint_1); + } + if (isShadowPaint) { + canvas.drawPath(path, shadowPaint); + } + canvas.drawPath(path, paint); + if (isPaint2) { + canvas.drawPath(path, paint2); + } + if (tb.getZoomAnimation() == 0) { + TIntArrayList lst = new TIntArrayList(50); + calculateSplitPaths(tb, tx, ty, lst); + drawArrowsOverPath(canvas, lst, coloredArrowUp); + } + } finally { + canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } - calculatePath(tb, tx, ty, path); - - if(isPaint_1) { - canvas.drawPath(path, paint_1); - } - if(isShadowPaint) { - canvas.drawPath(path, shadowPaint); - } - canvas.drawPath(path, paint); - if(isPaint2) { - canvas.drawPath(path, paint2); - } - if (tb.getZoomAnimation() == 0) { - TIntArrayList lst = new TIntArrayList(50); - calculateSplitPaths(tb, tx, ty, lst); - drawArrowsOverPath(canvas, lst, coloredArrowUp); - } - canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } } @@ -360,7 +363,15 @@ public class RouteLayer extends OsmandMapLayer { double rightLongitude, Location lastProjection, List routeNodes, int cd, Iterator it, int zoom) { RouteDirectionInfo nf = null; - double DISTANCE_ACTION = zoom >= 17 ? 15 : 35; + + double DISTANCE_ACTION = 35; + if(zoom >= 17) { + DISTANCE_ACTION = 15; + } else if (zoom == 15) { + DISTANCE_ACTION = 70; + } else if (zoom < 15) { + DISTANCE_ACTION = 110; + } double actionDist = 0; Location previousAction = null; actionPoints.clear(); @@ -421,9 +432,10 @@ public class RouteLayer extends OsmandMapLayer { break; } else { if(prevPoint == k) { - actionPoints.remove(ind - 1); - actionPoints.remove(ind - 1); + actionPoints.remove(actionPoints.size() - 1); + actionPoints.remove(actionPoints.size() - 1); prevPoint = -2; + ind = actionPoints.size(); } actionPoints.add(ind, l); lp = l;