Fix issue #830 - Poll having html

custom_theming
Thomas 2 years ago
parent 7743de24d2
commit 75139a8523

@ -61,7 +61,7 @@ public class Poll implements Serializable {
public transient Spannable span_title;
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;
}
}

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

Loading…
Cancel
Save