Fix issue #830 - Poll having html

This commit is contained in:
Thomas 2023-03-22 17:43:35 +01:00
parent 7743de24d2
commit 75139a8523
2 changed files with 16 additions and 6 deletions

View file

@ -61,7 +61,7 @@ public class Poll implements Serializable {
public transient Spannable span_title; public transient Spannable span_title;
public Spannable getSpanTitle(Context context, Status status, WeakReference<View> viewWeakReference) { public Spannable getSpanTitle(Context context, Status status, WeakReference<View> viewWeakReference) {
span_title = SpannableHelper.convert(context, title, status, null, null, viewWeakReference); span_title = SpannableHelper.convert(context, title, status, null, null, viewWeakReference, null, false);
return span_title; return span_title;
} }
} }

View file

@ -95,12 +95,18 @@ public class SpannableHelper {
public static Spannable convert(Context context, String text, public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, WeakReference<View> viewWeakReference) { Status status, Account account, Announcement announcement, WeakReference<View> viewWeakReference) {
return convert(context, text, status, account, announcement, viewWeakReference, null); return convert(context, text, status, account, announcement, viewWeakReference, null, true);
} }
public static Spannable convert(Context context, String text, public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, Status.Callback callback) { WeakReference<View> viewWeakReference, Status.Callback callback) {
return convert(context, text, status, account, announcement, viewWeakReference, callback, true);
}
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml) {
if (text == null) { if (text == null) {
return null; return null;
} }
@ -133,10 +139,14 @@ public class SpannableHelper {
text = text.trim().replaceAll("\\s{3}", "&nbsp;&nbsp;&nbsp;"); text = text.trim().replaceAll("\\s{3}", "&nbsp;&nbsp;&nbsp;");
text = text.trim().replaceAll("\\s{2}", "&nbsp;&nbsp;"); text = text.trim().replaceAll("\\s{2}", "&nbsp;&nbsp;");
SpannableString initialContent; SpannableString initialContent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (convertHtml) {
initialContent = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
else initialContent = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
initialContent = new SpannableString(Html.fromHtml(text)); else
initialContent = new SpannableString(Html.fromHtml(text));
} else {
initialContent = new SpannableString(text);
}
//Get all links //Get all links
SpannableStringBuilder content = new SpannableStringBuilder(initialContent); SpannableStringBuilder content = new SpannableStringBuilder(initialContent);