Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove color codes if the mirc colors option is off. Fixes #57

  • Loading branch information...
commit c6dbe8cc1816456a2eea41893da12cf9f64c14cf 1 parent 86e0812
@pocmo authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 application/src/org/yaaic/model/Message.java
View
14 application/src/org/yaaic/model/Message.java
@@ -229,15 +229,24 @@ public SpannableString render(Context context)
String prefix = hasIcon() && settings.showIcons() ? " " : "";
String nick = hasSender() ? "<" + sender + "> " : "";
String timestamp = settings.showTimestamp() ? renderTimeStamp(settings.use24hFormat()) : "";
+
canvas = new SpannableString(prefix + timestamp + nick);
- SpannableString renderedText = new SpannableString(text);
+ SpannableString renderedText;
+
if (settings.showMircColors()) {
renderedText = MircColors.toSpannable(text);
+ } else {
+ renderedText = new SpannableString(
+ MircColors.removeStyleAndColors(text)
+ );
}
+
if (settings.showGraphicalSmilies()) {
renderedText = Smilies.toSpannable(renderedText, context);
}
+
canvas = new SpannableString(TextUtils.concat(canvas, renderedText));
+
if (hasSender()) {
int start = (prefix + timestamp).length() + 1;
int end = start + sender.length();
@@ -252,14 +261,17 @@ public SpannableString render(Context context)
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
canvas.setSpan(new ImageSpan(drawable, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
+
if (hasColor() && settings.showColors()) {
// Only apply the foreground color to areas that don't already have a foreground color.
ForegroundColorSpan[] spans = canvas.getSpans(0, canvas.length(), ForegroundColorSpan.class);
int start = 0;
+
for (int i = 0; i < spans.length; i++) {
canvas.setSpan(new ForegroundColorSpan(color), start, canvas.getSpanStart(spans[i]), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
start = canvas.getSpanEnd(spans[i]);
}
+
canvas.setSpan(new ForegroundColorSpan(color), start, canvas.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

0 comments on commit c6dbe8c

Please sign in to comment.
Something went wrong with that request. Please try again.