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

Commit 370d2b1

Browse files
Sam1301timabbott
authored andcommitted
Handle new data-user-id for clickable spans.
1 parent 68ec133 commit 370d2b1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import com.zulip.android.R;
5050
import com.zulip.android.ZulipApp;
51+
import com.zulip.android.models.Person;
5152

5253
import org.ccil.cowan.tagsoup.Parser;
5354
import org.xml.sax.Attributes;
@@ -64,6 +65,8 @@
6465
import java.util.List;
6566
import java.util.Locale;
6667

68+
import static android.R.attr.id;
69+
6770
public class CustomHtmlToSpannedConverter implements ContentHandler {
6871

6972
private static final float[] HEADER_SIZES = {1.5f, 1.4f, 1.3f, 1.2f, 1.1f,
@@ -233,7 +236,16 @@ private static void endFont(SpannableStringBuilder text) {
233236
}
234237

235238
private static void startSpan(SpannableStringBuilder text, Attributes attributes) {
236-
String email = attributes.getValue("data-user-email");
239+
String email;
240+
String stringId = attributes.getValue("data-user-id");
241+
if (stringId != null) {
242+
int id = Integer.parseInt(stringId);
243+
email = Person.getById(ZulipApp.get(), id).getEmail();
244+
} else {
245+
// for historical messages
246+
email = attributes.getValue("data-user-email");
247+
}
248+
237249
int len = text.length();
238250
text.setSpan(new Href(email), len, len, Spannable.SPAN_MARK_MARK);
239251
}

0 commit comments

Comments
 (0)