From 3b68f2ead265b3b3fae71c25a757d84dda015a15 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 13 Jun 2017 16:33:47 +0300 Subject: [PATCH] Fix paint for text on circles; add attributes for the dotted line in the first ruler mode; add a switching between the night and day central icon --- OsmAnd/res/drawable-hdpi/map_ruler_center.png | Bin 1358 -> 0 bytes OsmAnd/res/drawable-mdpi/map_ruler_center.png | Bin 1193 -> 0 bytes .../res/drawable-xhdpi/map_ruler_center.png | Bin 1485 -> 0 bytes .../res/drawable-xxhdpi/map_ruler_center.png | Bin 1724 -> 0 bytes .../osmand/plus/views/RulerControlLayer.java | 63 +++++++++--------- 5 files changed, 33 insertions(+), 30 deletions(-) delete mode 100644 OsmAnd/res/drawable-hdpi/map_ruler_center.png delete mode 100644 OsmAnd/res/drawable-mdpi/map_ruler_center.png delete mode 100644 OsmAnd/res/drawable-xhdpi/map_ruler_center.png delete mode 100644 OsmAnd/res/drawable-xxhdpi/map_ruler_center.png diff --git a/OsmAnd/res/drawable-hdpi/map_ruler_center.png b/OsmAnd/res/drawable-hdpi/map_ruler_center.png deleted file mode 100644 index 2f608322dc805fb0ad580af2c395b92516cb6188..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1358 zcmbVMTTC2f6dt-QXIO9~cks!5}bO`E8xT75AatbNc2ftZpsUfRSri1i;}(Ff88Co}W^ z|C#fh%XiM16D`e8mu#)viXcddzljUNb&viO=EL^_GC2vCotn2zYgHmzKd%DBEh=Gv z`enWo1OYD&^nM5G5yUVkh1#^XzyVfJWD~FJn38fFq7kINAsOd|ZlIxI&?&{7*q_%v z$52UhVu!2&G7$HGsMIv5g4V(2kTBRSFe29Q6k4BTp#d3aJerhyVhJ|s#8&OHaIcFA z3|&>xx}DfsP;G%0)T5{XwVG_WK$&UO&X_1GLpv<{P@1G{1Zg2C2B*v{ye%ZUeqqp? zDn{5K=Uev$PfjeVX>pby`uqD${brM*c0w$}5F|~|G!8ZJ#6V2rlXxt#J8OXh2|<54EK_Mj@kqVPSOBJ{~1rujK12EUj@Nn{~$BptRya0khV zxP=q}?y%YHIODKTJSEyihH_->Y=(E(9hA@R_Lw=wN>N^WBiU$fw7Pw6uh&7FZRRZ2 zA4_O_OaNKm67+5NkY4#!jj|zBAQA3K-lkI|*sG=!}s1ip#9=+;TlNGHC@PZW6 z#ZTy^TFaaRs&oX1K2?#?RjyfSlQ^sqnxXA>Gahl!VcY`gz!}PB#jO+*p~Do#h`@%e zFj4G4%GxW%qnu z+2OoJ!L>5{u7!JJsO>dJZtC}Y!{oP_8?Nj5saNLa-0Ajr3}2mftrVo*MDF|1m-G9E zca)uTS8WR(eI&JR$NRaR1psTZ8ZCTjxu$y(MEKnb{#<6<33lbs)d39IKq`nh^9q NoZs8bebm@-{2$aZ$oc>P diff --git a/OsmAnd/res/drawable-mdpi/map_ruler_center.png b/OsmAnd/res/drawable-mdpi/map_ruler_center.png deleted file mode 100644 index 177d381d75865a158b9ffa55e55642c7b8d2d544..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1193 zcmbVMO>ERw5cU#55I=1y1T8dbUL6i;g#Ybb+w3Onu6N5qHbl#|M4|`$^EPWG_A~Yi zyU78Og2c8`D^yjgdT3P|4)j8WdZ-HGA0!Y`i$IlV)k8~FPL(P+aVUc4BpWzH9I$M^ zdE@zJ=6y5ck4A>yUAt=2DvF}kmbM!evc3^ND_4;BpN-5TvTVeKQM?<~aKj8Cm35E> zLCG`6UV+2Vjx6Ffuizd-Rr>0ko z;zBI4%g}X<1D)d_sKUTjJmumjx1`OQ;&?$z<19M#K z?h<(@HBl2&DT%46qQ%IB4n`A_3Zn>GO|%3-b6}EQz&kI?AxDzp;)Z#yf!Zq4m9e-u z4rH@9P|zn+6q0dy7##VFjM}x5k*zj=xBh?fWUzxt{C#ry=DioMUvKStJk_R85E<1MfhnYvOc730? zw{B$rYVbQ?u*^lLl2 zPux+~&s0C&koBt+AYB90qm9vEBpD`or;$c6RrD-)EoS z^YMG0XB*cQua1vPk5j2s@r4BrH(ZIxGjA?@Z;H9!0GBky=}|UFex;g`fy&BBK7bSo z%ogAV3|CWm3goI(vupVhkK%C^nORBDFcBS1NC-f*N|n1R6kynLpddc5g%>U8?SUZ_ z;W-PsN$(XU$Q+Ca89}(jy zGNq!FThQsCJg#+!U6KK!*BCIC)KZ9%){uIdGU-+z6hRtrLWh$yMrzIQ))C0eg+gyK z=Qq0@`7^%Y$%2+CO2CZc)z#ISYOO|+w?HgS;{=6M6b3c0V2!9SAxsQrMlCo%kd^s> z!b>6&vB>zOD#e1rNT*W}0xs7h!(woTC`cI|Vgfj+A#g#6ZF+0I)#)@*T7x!< zEfj+aBeEdsn}@z#~oBp_2MEC&65kT+BYA1$1b(jpI(y@u5u*3`%_obCv_=# zOu~ni4|Uq}^!T;rJ=>b^4qV>$+sns_4<)Ag-_GB8$+3N2!YmZ=Jl&Jt&VSH$FSbHm zJlk{p5T|ZbEh4TT^nN6_c?-ZX-M-nClSA8A2V(!YI`-L$>mA$Y?2c_ozV?c>(Pzte zQ5dfJB0M_U9;b|-8B8sxf0h^?R0kGZw5m@A?_hzr7oKZzfBVvjr)>tbC(YH>!(acNv*1DZ&6Q!#pt|7b z;mu3G%R7Itn|!}JW^qMT3OVty=klI&JKyWyU)P`TgX?Hz%kAt3x7AIj;%?PvFT0L6 zTv^VJJvH$9{`#yhvs1`#1{YeF{F*)n8Y&M==)-q5o`_#Kt~*JOkDk5T((_tM`$z+u zC++w&{>n3TtxGRtcOO4vd-cXh(Ol<|E^kp2yK5qQz*~o(<~JrDo@_mL_i9sJV(GFK zJG_&f2mT`F-{|Y1en}m-1?P&xTQmP0+|>KIuy|(H@zPG4U6|?Uh7uJBDi~L{ diff --git a/OsmAnd/res/drawable-xxhdpi/map_ruler_center.png b/OsmAnd/res/drawable-xxhdpi/map_ruler_center.png deleted file mode 100644 index 4c934217c8d5e49ceb3a66acf9e3ab09292d484d..0000000000000000000000000000000000000000 GIT binary patch literal 0 H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Han%!ZERm%Qj6RiFWs}X;oJjwTt(AG z_Q6%WdAd@2OnUw3h??g=xf+YZFL^en9AO7E{?bDH<>hrd>aU)99huu(+SA%wEva6LK?CM(O_t|13*Q*WgBhc2$hN`c<8863oFUe}5msY)EHTq65dQaZ~yt zCIq@YW0%e8t^TUQM>adukIvtoU6<7~UG=bS%1!UA!_kxVr(W2wk?W96yCnLTjs zgtb1VZU*F%c;&0^cQ*qO cacheDistances; - private Bitmap centerIcon; + private Bitmap centerIconDay; + private Bitmap centerIconNight; private Paint bitmapPaint; - private Paint distancePaint; - private RenderingLineAttributes attrs; + private RenderingLineAttributes lineAttrs; + private RenderingLineAttributes circleAttrs; public RulerControlLayer(MapActivity mapActivity) { this.mapActivity = mapActivity; @@ -57,32 +57,30 @@ public class RulerControlLayer extends OsmandMapLayer { cacheCenter = new QuadPoint(); maxRadiusInDp = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_radius); - centerIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center); + centerIconDay = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_day); + centerIconNight = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_night); bitmapPaint = new Paint(); bitmapPaint.setAntiAlias(true); bitmapPaint.setDither(true); bitmapPaint.setFilterBitmap(true); - distancePaint = new Paint(); - distancePaint.setAntiAlias(true); - distancePaint.setStyle(Style.STROKE); - distancePaint.setStrokeWidth(10); - distancePaint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0)); + lineAttrs = new RenderingLineAttributes("rulerLine"); - attrs = new RenderingLineAttributes("rulerCircle"); - attrs.paint.setStrokeWidth(2); - attrs.paint2.setTextSize(TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density); - attrs.paint2.setStyle(Style.FILL_AND_STROKE); - attrs.shadowPaint.setTextSize(TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density); - attrs.shadowPaint.setStrokeWidth(6); - attrs.shadowPaint.setColor(Color.WHITE); + circleAttrs = new RenderingLineAttributes("rulerCircle"); + circleAttrs.paint.setStrokeWidth(2); + circleAttrs.paint2.setTextSize(TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density); + circleAttrs.shadowPaint.setTextSize(TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density); + circleAttrs.shadowPaint.setStrokeWidth(6); + circleAttrs.shadowPaint.setColor(Color.WHITE); } @Override public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { if (mapActivity.getMapLayers().getMapWidgetRegistry().isVisible("ruler")) { - attrs.updatePaints(view, settings, tb); + lineAttrs.updatePaints(view, settings, tb); + circleAttrs.updatePaints(view, settings, tb); + circleAttrs.paint2.setStyle(Style.FILL); final QuadPoint center = tb.getCenterPixelPoint(); final RulerMode mode = app.getSettings().RULER_MODE.get(); @@ -92,14 +90,14 @@ public class RulerControlLayer extends OsmandMapLayer { if (firstFinger.x != -1 && firstFinger.y != -1 && secondFinger.x != -1 && secondFinger.y != -1) { drawFingerDistance(canvas, tb, center, firstFinger, secondFinger); } else { - drawCenterIcon(canvas, tb, center); + drawCenterIcon(canvas, tb, center, settings.isNightMode()); Location currentLoc = app.getLocationProvider().getLastKnownLocation(); if (currentLoc != null) { drawDistance(canvas, tb, center, currentLoc); } } } else if (mode == RulerMode.SECOND) { - drawCenterIcon(canvas, tb, center); + drawCenterIcon(canvas, tb, center, settings.isNightMode()); updateData(tb, center); for (int i = 1; i <= cacheDistances.size(); i++) { drawCircle(canvas, tb, i, center); @@ -110,21 +108,26 @@ public class RulerControlLayer extends OsmandMapLayer { private void drawFingerDistance(Canvas canvas, RotatedTileBox tb, QuadPoint center, PointF first, PointF second) { canvas.rotate(-tb.getRotate(), center.x, center.y); - canvas.drawLine(first.x, first.y, second.x, second.y, distancePaint); + canvas.drawLine(first.x, first.y, second.x, second.y, lineAttrs.paint); canvas.rotate(tb.getRotate(), center.x, center.y); } - private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center) { + private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) { canvas.rotate(-tb.getRotate(), center.x, center.y); - canvas.drawBitmap(centerIcon, center.x - centerIcon.getWidth() / 2, - center.y - centerIcon.getHeight() / 2, bitmapPaint); + if (nightMode) { + canvas.drawBitmap(centerIconNight, center.x - centerIconNight.getWidth() / 2, + center.y - centerIconNight.getHeight() / 2, bitmapPaint); + } else { + canvas.drawBitmap(centerIconDay, center.x - centerIconDay.getWidth() / 2, + center.y - centerIconDay.getHeight() / 2, bitmapPaint); + } canvas.rotate(tb.getRotate(), center.x, center.y); } private void drawDistance(Canvas canvas, RotatedTileBox tb, QuadPoint center, Location currentLoc) { int currentLocX = tb.getPixXFromLonNoRot(currentLoc.getLongitude()); int currentLocY = tb.getPixYFromLatNoRot(currentLoc.getLatitude()); - canvas.drawLine(currentLocX, currentLocY, center.x, center.y, distancePaint); + canvas.drawLine(currentLocX, currentLocY, center.x, center.y, lineAttrs.paint); } private void updateData(RotatedTileBox tb, QuadPoint center) { @@ -195,7 +198,7 @@ public class RulerControlLayer extends OsmandMapLayer { private void drawCircle(Canvas canvas, RotatedTileBox tb, int circleNumber, QuadPoint center) { Rect bounds = new Rect(); String text = cacheDistances.get(circleNumber - 1); - attrs.paint2.getTextBounds(text, 0, text.length(), bounds); + circleAttrs.paint2.getTextBounds(text, 0, text.length(), bounds); float x = 0; float y = 0; @@ -216,10 +219,10 @@ public class RulerControlLayer extends OsmandMapLayer { if (!mapActivity.getMapView().isZooming()) { canvas.rotate(-tb.getRotate(), center.x, center.y); - canvas.drawCircle(center.x, center.y, radius * circleNumber, attrs.shadowPaint); - canvas.drawCircle(center.x, center.y, radius * circleNumber, attrs.paint); - canvas.drawText(text, x, y, attrs.shadowPaint); - canvas.drawText(text, x, y, attrs.paint2); + canvas.drawCircle(center.x, center.y, radius * circleNumber, circleAttrs.shadowPaint); + canvas.drawCircle(center.x, center.y, radius * circleNumber, circleAttrs.paint); + canvas.drawText(text, x, y, circleAttrs.shadowPaint); + canvas.drawText(text, x, y, circleAttrs.paint2); canvas.rotate(tb.getRotate(), center.x, center.y); } }