Commit 83c7d1fb authored by Thomas's avatar Thomas
Browse files

- Fix #1372 Fix #1074 improve pronouns and display name handling

parent 92197838
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -15,9 +15,21 @@ package app.fedilab.android.mastodon.helper;
 * see <http://www.gnu.org/licenses>. */
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class PronounsHelper {

    private static final Pattern EMOJI_SHORTCODE_PATTERN = Pattern.compile(":[a-zA-Z0-9_]+:");

    public static String cleanPronouns(String pronouns) {
        if (pronouns == null || pronouns.isEmpty()) {
            return pronouns;
        }
        String cleaned = EMOJI_SHORTCODE_PATTERN.matcher(pronouns).replaceAll("");
        cleaned = cleaned.replaceAll("\\s+", " ").trim();
        return cleaned.isEmpty() ? null : cleaned;
    }

    public static List<String> pronouns = new ArrayList<>() {
        {
            add("pronoun");
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
        if(pronounsSupport) {
            for (Field field : account.fields) {
                if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
                    account.pronouns = Helper.parseHtml(field.value);
                    account.pronouns = PronounsHelper.cleanPronouns(Helper.parseHtml(field.value));
                    break;
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -1498,7 +1498,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                    if (accountFromUser.fields != null && !accountFromUser.fields.isEmpty()) {
                        for (Field field : accountFromUser.fields) {
                            if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
                                statusList.get(position).pronouns = Helper.parseHtml(field.value);
                                statusList.get(position).pronouns = PronounsHelper.cleanPronouns(Helper.parseHtml(field.value));
                                break;
                            }
                        }
+1 −1
Original line number Diff line number Diff line
@@ -719,7 +719,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            if (statusToDeal.pronouns == null && statusToDeal.account != null && statusToDeal.account.fields != null && statusToDeal.account.fields.size() > 0) {
                for (Field field : statusToDeal.account.fields) {
                    if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
                        statusToDeal.pronouns = Helper.parseHtml(field.value);
                        statusToDeal.pronouns = PronounsHelper.cleanPronouns(Helper.parseHtml(field.value));
                        break;
                    }
                }
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
        android:visibility="gone"
        tools:visibility="visible"
        android:textColor="?colorPrimary"
        android:ellipsize="end"
        android:singleLine="true"
        tools:text="He/Him" />

    <TextView
Loading