From c08ef7a60be99cfcfce3034afa95fae5c4d277ca Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 10 Nov 2017 16:57:18 +0200 Subject: [PATCH] Extract constants to resources --- OsmAnd/res/values/sizes.xml | 3 +++ .../net/osmand/plus/views/MapMarkersLayer.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 4012fb9081..0c9d3c1a12 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -143,6 +143,9 @@ 150dp 128dp + + 14sp + 6dp 42dp 30dp diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 9769c66bc5..cfb8acd1e1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -50,8 +50,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi private static final long USE_FINGER_LOCATION_DELAY = 1000; private static final int MAP_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 6; protected static final int DIST_TO_SHOW = 80; - private static final int TEXT_SIZE = 14; - private static final int VERTICAL_OFFSET = 10; private final MapActivity map; private OsmandMapTileView view; @@ -84,6 +82,9 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi private final RenderingLineAttributes planRouteAttrs = new RenderingLineAttributes("markerPlanRouteline"); private TrkSegment route; + private float textSize; + private int verticalOffset; + private TIntArrayList tx = new TIntArrayList(); private TIntArrayList ty = new TIntArrayList(); private Path linePath = new Path(); @@ -146,6 +147,9 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi widgetsFactory = new MapMarkersWidgetsFactory(map); contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class); + + textSize = map.getResources().getDimensionPixelSize(R.dimen.guide_line_text_size); + verticalOffset = map.getResources().getDimensionPixelSize(R.dimen.guide_line_vertical_offset); } private Paint createPaintDest(int colorId) { @@ -239,7 +243,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi } if (map.getMyApplication().getSettings().SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) { - float textSize = TEXT_SIZE * map.getResources().getDisplayMetrics().density * map.getMyApplication().getSettings().TEXT_SCALE.get(); textAttrs.paint.setTextSize(textSize); textAttrs.paint2.setTextSize(textSize); @@ -292,12 +295,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi canvas.drawPath(linePath, lineAttrs.paint); if (locX >= markerX) { canvas.rotate(180, pos[0], pos[1]); - canvas.drawTextOnPath(text, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint2); - canvas.drawTextOnPath(text, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint); + canvas.drawTextOnPath(text, linePath, hOffset, bounds.height() + verticalOffset, textAttrs.paint2); + canvas.drawTextOnPath(text, linePath, hOffset, bounds.height() + verticalOffset, textAttrs.paint); canvas.rotate(-180, pos[0], pos[1]); } else { - canvas.drawTextOnPath(text, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint2); - canvas.drawTextOnPath(text, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint); + canvas.drawTextOnPath(text, linePath, hOffset, -verticalOffset, textAttrs.paint2); + canvas.drawTextOnPath(text, linePath, hOffset, -verticalOffset, textAttrs.paint); } canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); }