From b943309dd2225a5af2663484b61330a18a8fbfb0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 23 Feb 2024 10:17:55 +0100 Subject: [PATCH] Add localization for pronons support --- .../mastodon/helper/PronounsHelper.java | 31 +++++++++++++++++++ .../ui/drawer/AccountsSearchAdapter.java | 3 +- .../mastodon/ui/drawer/ComposeAdapter.java | 3 +- .../mastodon/ui/drawer/StatusAdapter.java | 3 +- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/app/fedilab/android/mastodon/helper/PronounsHelper.java diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/PronounsHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/PronounsHelper.java new file mode 100644 index 00000000..f3bcdbbc --- /dev/null +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/PronounsHelper.java @@ -0,0 +1,31 @@ +package app.fedilab.android.mastodon.helper; +/* Copyright 2024 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +import java.util.ArrayList; +import java.util.List; + +public class PronounsHelper { + + public static List pronouns = new ArrayList<>() { + { + add("pronouns"); + add("pronoms"); + add("pronombres"); + add("לשון פנייה"); + add("כינויי גוף"); + add("Pronomen"); + } + }; +} diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchAdapter.java index 974b2325..a5a72862 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchAdapter.java @@ -33,6 +33,7 @@ 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; +import app.fedilab.android.mastodon.helper.PronounsHelper; public class AccountsSearchAdapter extends ArrayAdapter implements Filterable { @@ -120,7 +121,7 @@ public class AccountsSearchAdapter extends ArrayAdapter implements Filt holder.binding.accountDn.setVisibility(View.VISIBLE); account.pronouns = null; for (Field field : account.fields) { - if (field.name.trim().equalsIgnoreCase("pronouns")) { + if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) { account.pronouns = Helper.parseHtml(field.value); break; } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 1578e4de..09bab05a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -128,6 +128,7 @@ import app.fedilab.android.mastodon.helper.ComposeHelper; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod; import app.fedilab.android.mastodon.helper.MastodonHelper; +import app.fedilab.android.mastodon.helper.PronounsHelper; import app.fedilab.android.mastodon.helper.ThemeHelper; import app.fedilab.android.mastodon.imageeditor.EditImageActivity; import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM; @@ -1428,7 +1429,7 @@ public class ComposeAdapter extends RecyclerView.Adapter 0) { for (Field field : accountFromUser.fields) { - if (field.name.toLowerCase().startsWith("pronoun")) { + if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) { statusList.get(position).pronouns = Helper.parseHtml(field.value); break; } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index 479c8746..188378f0 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -169,6 +169,7 @@ import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod; import app.fedilab.android.mastodon.helper.MastodonHelper; import app.fedilab.android.mastodon.helper.MediaHelper; +import app.fedilab.android.mastodon.helper.PronounsHelper; import app.fedilab.android.mastodon.helper.SpannableHelper; import app.fedilab.android.mastodon.helper.ThemeHelper; import app.fedilab.android.mastodon.helper.TimelineHelper; @@ -483,7 +484,7 @@ public class StatusAdapter extends RecyclerView.Adapter String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS"); 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")) { + if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) { statusToDeal.pronouns = Helper.parseHtml(field.value); break; }