Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Show another color if the user is mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
kunall17 authored and Kunal Gupta committed Aug 26, 2016
1 parent 08ec3ab commit be45398
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -44,6 +44,7 @@
import android.text.style.UnderlineSpan;

import com.zulip.android.R;
import com.zulip.android.ZulipApp;

import org.ccil.cowan.tagsoup.Parser;
import org.xml.sax.Attributes;
Expand Down Expand Up @@ -72,6 +73,7 @@ public class CustomHtmlToSpannedConverter implements ContentHandler {
private Html.ImageGetter mEmojiGetter;
private String mBaseUri;
private static int userMentionColor;
private static int userMentionSelfColor;
public CustomHtmlToSpannedConverter(String source,
Html.ImageGetter imageGetter, Html.TagHandler tagHandler,
Parser parser, Html.ImageGetter emojiGetter, String baseUri, Context context) {
Expand All @@ -83,6 +85,7 @@ public CustomHtmlToSpannedConverter(String source,
mEmojiGetter = emojiGetter;
mBaseUri = baseUri;
userMentionColor = ContextCompat.getColor(context, R.color.dark_red);
userMentionSelfColor = ContextCompat.getColor(context, R.color.dark_blue);
}

public Spanned convert() {
Expand Down Expand Up @@ -432,8 +435,11 @@ private static void endSpan(SpannableStringBuilder text) {
if (where != len) {
Href h = (Href) obj;
if (h != null && h.mHref != null) {
text.setSpan(new ProfileSpan(h.mHref, userMentionColor), where, len,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
if (ZulipApp.get().getEmail().equals(h.mHref)) {
text.setSpan(new ForegroundColorSpan(userMentionSelfColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
text.setSpan(new ProfileSpan(h.mHref, userMentionColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Expand Up @@ -18,4 +18,5 @@
<color name="loadingBackground">#eeeeee</color>
<color name="indigo_material_500">#3F51B5</color>
<color name="dark_red">#d14444</color>
<color name="dark_blue">#303F9F</color>
</resources>

0 comments on commit be45398

Please sign in to comment.