Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 22fb0d0

Browse files
kunall17niftynei
authored andcommitted
Show another color if the user is mentioned
1 parent 99ae2a3 commit 22fb0d0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/src/main/java/com/zulip/android/util/CustomHtmlToSpannedConverter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import android.util.Pair;
4848

4949
import com.zulip.android.R;
50+
import com.zulip.android.ZulipApp;
5051

5152
import org.ccil.cowan.tagsoup.Parser;
5253
import org.xml.sax.Attributes;
@@ -77,6 +78,7 @@ public class CustomHtmlToSpannedConverter implements ContentHandler {
7778
private Html.ImageGetter mEmojiGetter;
7879
private String mBaseUri;
7980
private static int userMentionColor;
81+
private static int userMentionSelfColor;
8082
public CustomHtmlToSpannedConverter(String source,
8183
Html.ImageGetter imageGetter, Html.TagHandler tagHandler,
8284
Parser parser, Html.ImageGetter emojiGetter, String baseUri, Context context) {
@@ -88,6 +90,7 @@ public CustomHtmlToSpannedConverter(String source,
8890
mEmojiGetter = emojiGetter;
8991
mBaseUri = baseUri;
9092
userMentionColor = ContextCompat.getColor(context, R.color.dark_red);
93+
userMentionSelfColor = ContextCompat.getColor(context, R.color.dark_blue);
9194
}
9295

9396
public Spanned convert() {
@@ -437,8 +440,11 @@ private static void endSpan(SpannableStringBuilder text) {
437440
if (where != len) {
438441
Href h = (Href) obj;
439442
if (h != null && h.mHref != null) {
440-
text.setSpan(new ProfileSpan(h.mHref, userMentionColor), where, len,
441-
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
443+
if (ZulipApp.get().getEmail().equals(h.mHref)) {
444+
text.setSpan(new ForegroundColorSpan(userMentionSelfColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
445+
} else {
446+
text.setSpan(new ProfileSpan(h.mHref, userMentionColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
447+
}
442448
}
443449
}
444450
}

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
<color name="loadingBackground">#eeeeee</color>
1919
<color name="indigo_material_500">#3F51B5</color>
2020
<color name="dark_red">#d14444</color>
21+
<color name="dark_blue">#303F9F</color>
2122
</resources>

0 commit comments

Comments
 (0)