mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Merge branch 'improve_pronouns_support' into develop
This commit is contained in:
commit
2ecd51230f
6 changed files with 87 additions and 17 deletions
|
@ -0,0 +1,44 @@
|
||||||
|
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 <http://www.gnu.org/licenses>. */
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PronounsHelper {
|
||||||
|
|
||||||
|
public static List<String> pronouns = new ArrayList<>() {
|
||||||
|
{
|
||||||
|
add("pronoun");
|
||||||
|
add("pronouns");
|
||||||
|
add("pronoms");
|
||||||
|
add("pronom");
|
||||||
|
add("pronombres");
|
||||||
|
add("לשון פנייה");
|
||||||
|
add("כינויי גוף");
|
||||||
|
add("pronomen");
|
||||||
|
add("pronomina");
|
||||||
|
add("称谓");
|
||||||
|
add("pronomes");
|
||||||
|
add("pronome");
|
||||||
|
add("pronomi");
|
||||||
|
add("pronomoj");
|
||||||
|
add("zaimki");
|
||||||
|
add("voornaamwoorden");
|
||||||
|
add("riochdairean");
|
||||||
|
add("כינויי גוף");
|
||||||
|
add("personlig pronomen");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.drawer;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -23,16 +24,19 @@ import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.DrawerAccountSearchBinding;
|
import app.fedilab.android.databinding.DrawerAccountSearchBinding;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Account;
|
import app.fedilab.android.mastodon.client.entities.api.Account;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Field;
|
import app.fedilab.android.mastodon.client.entities.api.Field;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||||
|
import app.fedilab.android.mastodon.helper.PronounsHelper;
|
||||||
|
|
||||||
|
|
||||||
public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filterable {
|
public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filterable {
|
||||||
|
@ -119,10 +123,14 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
|
||||||
holder.binding.accountDn.setText(account.display_name);
|
holder.binding.accountDn.setText(account.display_name);
|
||||||
holder.binding.accountDn.setVisibility(View.VISIBLE);
|
holder.binding.accountDn.setVisibility(View.VISIBLE);
|
||||||
account.pronouns = null;
|
account.pronouns = null;
|
||||||
for (Field field : account.fields) {
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
if (field.name.trim().equalsIgnoreCase("pronouns")) {
|
boolean pronounsSupport = sharedpreferences.getBoolean(getContext().getString(R.string.SET_PRONOUNS_SUPPORT), true);
|
||||||
account.pronouns = Helper.parseHtml(field.value);
|
if(pronounsSupport) {
|
||||||
break;
|
for (Field field : account.fields) {
|
||||||
|
if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
|
||||||
|
account.pronouns = Helper.parseHtml(field.value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (account.pronouns != null) {
|
if (account.pronouns != null) {
|
||||||
|
|
|
@ -128,6 +128,7 @@ import app.fedilab.android.mastodon.helper.ComposeHelper;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
||||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
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.helper.ThemeHelper;
|
||||||
import app.fedilab.android.mastodon.imageeditor.EditImageActivity;
|
import app.fedilab.android.mastodon.imageeditor.EditImageActivity;
|
||||||
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
||||||
|
@ -1426,11 +1427,14 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
Status statusFromUser = statusList.get(position - 1);
|
Status statusFromUser = statusList.get(position - 1);
|
||||||
Account accountFromUser = statusFromUser.account;
|
Account accountFromUser = statusFromUser.account;
|
||||||
statusFromUser.pronouns = null;
|
statusFromUser.pronouns = null;
|
||||||
if (accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
|
boolean pronounsSupport = sharedpreferences.getBoolean(context.getString(R.string.SET_PRONOUNS_SUPPORT), true);
|
||||||
for (Field field : accountFromUser.fields) {
|
if(pronounsSupport) {
|
||||||
if (field.name.toLowerCase().startsWith("pronoun")) {
|
if (accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
|
||||||
statusList.get(position).pronouns = Helper.parseHtml(field.value);
|
for (Field field : accountFromUser.fields) {
|
||||||
break;
|
if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
|
||||||
|
statusList.get(position).pronouns = Helper.parseHtml(field.value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,7 @@ import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
||||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||||
import app.fedilab.android.mastodon.helper.MediaHelper;
|
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.SpannableHelper;
|
||||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||||
import app.fedilab.android.mastodon.helper.TimelineHelper;
|
import app.fedilab.android.mastodon.helper.TimelineHelper;
|
||||||
|
@ -481,17 +482,21 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS");
|
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) {
|
boolean pronounsSupport = sharedpreferences.getBoolean(context.getString(R.string.SET_PRONOUNS_SUPPORT), true);
|
||||||
for (Field field : statusToDeal.account.fields) {
|
if(pronounsSupport) {
|
||||||
if (field.name.toLowerCase().startsWith("pronoun")) {
|
if (statusToDeal.pronouns == null && statusToDeal.account.fields != null && statusToDeal.account.fields.size() > 0) {
|
||||||
statusToDeal.pronouns = Helper.parseHtml(field.value);
|
for (Field field : statusToDeal.account.fields) {
|
||||||
break;
|
if (PronounsHelper.pronouns.contains(field.name.toLowerCase().trim())) {
|
||||||
|
statusToDeal.pronouns = Helper.parseHtml(field.value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (statusToDeal.pronouns == null) {
|
||||||
|
statusToDeal.pronouns = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (statusToDeal.pronouns == null) {
|
|
||||||
statusToDeal.pronouns = "none";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusToDeal.pronouns != null && !statusToDeal.pronouns.equalsIgnoreCase("none")) {
|
if (statusToDeal.pronouns != null && !statusToDeal.pronouns.equalsIgnoreCase("none")) {
|
||||||
holder.binding.pronouns.setVisibility(View.VISIBLE);
|
holder.binding.pronouns.setVisibility(View.VISIBLE);
|
||||||
holder.binding.pronouns.setText(statusToDeal.pronouns);
|
holder.binding.pronouns.setText(statusToDeal.pronouns);
|
||||||
|
|
|
@ -639,6 +639,7 @@
|
||||||
<string name="other">Other</string>
|
<string name="other">Other</string>
|
||||||
<string name="eg_sensitive_content">Eg.: Sensitive Content</string>
|
<string name="eg_sensitive_content">Eg.: Sensitive Content</string>
|
||||||
<string name="Pronouns">Pronouns</string>
|
<string name="Pronouns">Pronouns</string>
|
||||||
|
<string name="pronouns_support">Pronouns support</string>
|
||||||
|
|
||||||
<string name="add_status">Add status</string>
|
<string name="add_status">Add status</string>
|
||||||
<string name="remove_status">Remove status</string>
|
<string name="remove_status">Remove status</string>
|
||||||
|
@ -1197,6 +1198,7 @@
|
||||||
<string name="SET_MARKDOWN_SUPPORT" translatable="false">SET_MARKDOWN_SUPPORT</string>
|
<string name="SET_MARKDOWN_SUPPORT" translatable="false">SET_MARKDOWN_SUPPORT</string>
|
||||||
<string name="SET_TRUNCATE_LINKS" translatable="false">SET_TRUNCATE_LINKS</string>
|
<string name="SET_TRUNCATE_LINKS" translatable="false">SET_TRUNCATE_LINKS</string>
|
||||||
<string name="SET_UNDERLINE_CLICKABLE" translatable="false">SET_UNDERLINE_CLICKABLE</string>
|
<string name="SET_UNDERLINE_CLICKABLE" translatable="false">SET_UNDERLINE_CLICKABLE</string>
|
||||||
|
<string name="SET_PRONOUNS_SUPPORT" translatable="false">SET_PRONOUNS_SUPPORT</string>
|
||||||
<string name="SET_TRUNCATE_LINKS_MAX" translatable="false">SET_TRUNCATE_LINKS_MAX</string>
|
<string name="SET_TRUNCATE_LINKS_MAX" translatable="false">SET_TRUNCATE_LINKS_MAX</string>
|
||||||
|
|
||||||
<string name="SET_HIDE_SINGLE_MEDIA_WITH_CARD" translatable="false">SET_HIDE_SINGLE_MEDIA_WITH_CARD</string>
|
<string name="SET_HIDE_SINGLE_MEDIA_WITH_CARD" translatable="false">SET_HIDE_SINGLE_MEDIA_WITH_CARD</string>
|
||||||
|
|
|
@ -79,6 +79,13 @@
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:title="@string/underline_links" />
|
app:title="@string/underline_links" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="@string/SET_PRONOUNS_SUPPORT"
|
||||||
|
app:singleLineTitle="false"
|
||||||
|
app:title="@string/pronouns_support" />
|
||||||
|
|
||||||
<androidx.preference.SeekBarPreference
|
<androidx.preference.SeekBarPreference
|
||||||
android:defaultValue="30"
|
android:defaultValue="30"
|
||||||
android:max="150"
|
android:max="150"
|
||||||
|
|
Loading…
Reference in a new issue