parse html for pronouns

fix_513
Thomas 9 months ago
parent 0400f316e6
commit ec44a6e4f3

@ -57,6 +57,7 @@ import android.os.Looper;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@ -2121,6 +2122,15 @@ public class Helper {
.build();
}
public static String parseHtml(String html) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY).toString();
} else {
//noinspection deprecation
return Html.fromHtml(html).toString();
}
}
//Enum that described actions to replace inside a toot content
public enum PatternType {
MENTION,

@ -31,6 +31,7 @@ import java.util.List;
import app.fedilab.android.databinding.DrawerAccountSearchBinding;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Field;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
@ -120,7 +121,7 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
account.pronouns = null;
for (Field field : account.fields) {
if (field.name.trim().equalsIgnoreCase("pronouns")) {
account.pronouns = field.value;
account.pronouns = Helper.parseHtml(field.value);
break;
}
}

@ -1429,7 +1429,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
if (accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
for (Field field : accountFromUser.fields) {
if (field.name.toLowerCase().startsWith("pronoun")) {
statusList.get(position).pronouns = field.value;
statusList.get(position).pronouns = Helper.parseHtml(field.value);
break;
}
}

@ -484,7 +484,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (statusToDeal.pronouns == null && statusToDeal.account.fields != null && statusToDeal.account.fields.size() > 0) {
for (Field field : statusToDeal.account.fields) {
if (field.name.toLowerCase().startsWith("pronoun")) {
statusToDeal.pronouns = field.value;
statusToDeal.pronouns = Helper.parseHtml(field.value);
break;
}
}

Loading…
Cancel
Save