From e5b6bbe32d5599cf92182124fa3c00d0f2a983cc Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 28 Apr 2015 22:36:04 +0200 Subject: [PATCH] Update shield res icon --- OsmAnd/build.gradle | 10 ++--- .../net/osmand/plus/render/TextRenderer.java | 43 +++++++++++-------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 398f3ff3f2..2139f1f771 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -239,11 +239,11 @@ collectExternalResources.dependsOn collectVoiceAssets, collectMiscResources, copyStyleIcons, updateNoTranslate -tasks.whenTaskAdded { task -> - if (task.name.startsWith("generate") && task.name.endsWith("Resources")) { - task.dependsOn collectExternalResources - } -} +// tasks.whenTaskAdded { task -> +// if (task.name.startsWith("generate") && task.name.endsWith("Resources")) { +// task.dependsOn collectExternalResources +// } +// } // Legacy core build import org.apache.tools.ant.taskdefs.condition.Os diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index b1d6d09611..f9e3c20f48 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -57,6 +57,7 @@ public class TextRenderer { int textWrap = 0; boolean bold = false; String shieldRes = null; + String shieldResIcon = null; int textOrder = 100; int textShadowColor = Color.WHITE; @@ -81,6 +82,9 @@ public class TextRenderer { if (render.isSpecified(render.ALL.R_TEXT_SHIELD)) { shieldRes = render.getStringPropertyValue(render.ALL.R_TEXT_SHIELD); } + if (render.isSpecified(render.ALL.R_ICON)) { + shieldResIcon = render.getStringPropertyValue(render.ALL.R_ICON); + } textOrder = render.getIntPropertyValue(render.ALL.R_TEXT_ORDER, 100); } } @@ -251,23 +255,8 @@ public class TextRenderer { cv.drawTextOnPath(text.text, text.drawOnPath, 0, text.vOffset - ( paintText.ascent()/2 + paintText.descent()), paintText); } else { - if (text.shieldRes != null) { - float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale); - Bitmap ico = RenderingIcons.getIcon(context, text.shieldRes); - if (ico != null) { - float left = text.centerX - ico.getWidth() / 2 * coef - 0.5f; - float top = text.centerY - ico.getHeight() / 2 * coef - paintText.descent() - 0.5f; - if(rc.screenDensityRatio != 1f){ - RectF rf = new RectF(left, top, left + ico.getWidth() * coef, - top + ico.getHeight() * coef); - Rect src = new Rect(0, 0, ico.getWidth(), ico - .getHeight()); - cv.drawBitmap(ico, src, rf, paintIcon); - } else { - cv.drawBitmap(ico, left, top, paintIcon); - } - } - } + drawShieldIcon(rc, cv, text, text.shieldRes); + drawShieldIcon(rc, cv, text, text.shieldResIcon); drawWrappedText(cv, text, textSize); } @@ -276,6 +265,26 @@ public class TextRenderer { } } + private void drawShieldIcon(RenderingContext rc, Canvas cv, TextDrawInfo text, String sr) { + if (sr != null) { + float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale); + Bitmap ico = RenderingIcons.getIcon(context, sr); + if (ico != null) { + float left = text.centerX - ico.getWidth() / 2 * coef - 0.5f; + float top = text.centerY - ico.getHeight() / 2 * coef - paintText.descent() - 0.5f; + if(rc.screenDensityRatio != 1f){ + RectF rf = new RectF(left, top, left + ico.getWidth() * coef, + top + ico.getHeight() * coef); + Rect src = new Rect(0, 0, ico.getWidth(), ico + .getHeight()); + cv.drawBitmap(ico, src, rf, paintIcon); + } else { + cv.drawBitmap(ico, left, top, paintIcon); + } + } + } + } + private void drawWrappedText(Canvas cv, TextDrawInfo text, float textSize) { if (text.textWrap == 0) { // set maximum for all text