Update shield res icon

This commit is contained in:
Victor Shcherb 2015-04-28 22:36:04 +02:00
parent 5ccb27a421
commit e5b6bbe32d
2 changed files with 31 additions and 22 deletions

View file

@ -239,11 +239,11 @@ collectExternalResources.dependsOn collectVoiceAssets,
collectMiscResources, collectMiscResources,
copyStyleIcons, copyStyleIcons,
updateNoTranslate updateNoTranslate
tasks.whenTaskAdded { task -> // tasks.whenTaskAdded { task ->
if (task.name.startsWith("generate") && task.name.endsWith("Resources")) { // if (task.name.startsWith("generate") && task.name.endsWith("Resources")) {
task.dependsOn collectExternalResources // task.dependsOn collectExternalResources
} // }
} // }
// Legacy core build // Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os

View file

@ -57,6 +57,7 @@ public class TextRenderer {
int textWrap = 0; int textWrap = 0;
boolean bold = false; boolean bold = false;
String shieldRes = null; String shieldRes = null;
String shieldResIcon = null;
int textOrder = 100; int textOrder = 100;
int textShadowColor = Color.WHITE; int textShadowColor = Color.WHITE;
@ -81,6 +82,9 @@ public class TextRenderer {
if (render.isSpecified(render.ALL.R_TEXT_SHIELD)) { if (render.isSpecified(render.ALL.R_TEXT_SHIELD)) {
shieldRes = render.getStringPropertyValue(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); textOrder = render.getIntPropertyValue(render.ALL.R_TEXT_ORDER, 100);
} }
} }
@ -251,23 +255,8 @@ public class TextRenderer {
cv.drawTextOnPath(text.text, text.drawOnPath, 0, cv.drawTextOnPath(text.text, text.drawOnPath, 0,
text.vOffset - ( paintText.ascent()/2 + paintText.descent()), paintText); text.vOffset - ( paintText.ascent()/2 + paintText.descent()), paintText);
} else { } else {
if (text.shieldRes != null) { drawShieldIcon(rc, cv, text, text.shieldRes);
float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale); drawShieldIcon(rc, cv, text, text.shieldResIcon);
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);
}
}
}
drawWrappedText(cv, text, textSize); 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) { private void drawWrappedText(Canvas cv, TextDrawInfo text, float textSize) {
if (text.textWrap == 0) { if (text.textWrap == 0) {
// set maximum for all text // set maximum for all text