diff --git a/application/src/org/yaaic/model/Message.java b/application/src/org/yaaic/model/Message.java index 5dfe1c2..a9f2345 100644 --- a/application/src/org/yaaic/model/Message.java +++ b/application/src/org/yaaic/model/Message.java @@ -229,15 +229,24 @@ public class Message 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 class Message 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); } }