diff options
author | Thomas <tschneider.ac@gmail.com> | 2024-01-23 19:03:41 +0100 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2024-01-23 19:03:41 +0100 |
commit | 394d72bd017b11fa560889f547508b53eb8d6075 (patch) | |
tree | 5121186cbd14cb1f85ce4ce4df2f8c2c809adffe | |
parent | 7ab24d900b493d4ae9f68fb9ed5498a591cbc619 (diff) |
Support pronouns
3 files changed, 29 insertions, 0 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Account.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Account.java index 5fc2e8d76..8d4cad290 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Account.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Account.java @@ -88,6 +88,7 @@ public class Account implements Serializable { @SerializedName("role") public Role role; public transient RelationShip relationShip; + public transient String pronouns = null; public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) { 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 d75f4faa0..a6c09c5e1 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 @@ -30,6 +30,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.MastodonHelper; @@ -116,6 +117,19 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt holder.binding.accountUn.setText(String.format("@%s", account.acct)); holder.binding.accountDn.setText(account.display_name); holder.binding.accountDn.setVisibility(View.VISIBLE); + account.pronouns = null; + for(Field field: account.fields) { + if(field.name.trim().equalsIgnoreCase("pronouns")) { + account.pronouns = field.value; + break; + } + } + if(account.pronouns != null) { + holder.binding.pronouns.setText(account.pronouns); + holder.binding.pronouns.setVisibility(View.VISIBLE); + } else { + holder.binding.pronouns.setVisibility(View.GONE); + } MastodonHelper.loadPPMastodon(holder.binding.accountPp, account); return holder.view; } diff --git a/app/src/main/res/layouts/mastodon/layout/drawer_account_search.xml b/app/src/main/res/layouts/mastodon/layout/drawer_account_search.xml index c4695cceb..102b5b0df 100644 --- a/app/src/main/res/layouts/mastodon/layout/drawer_account_search.xml +++ b/app/src/main/res/layouts/mastodon/layout/drawer_account_search.xml @@ -15,6 +15,7 @@ see <http://www.gnu.org/licenses> --> <androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:id="@+id/account_container" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -27,10 +28,12 @@ android:layout_height="30dp" android:layout_gravity="center" android:layout_margin="5dp" + tools:src="@tools:sample/avatars" android:contentDescription="@string/profile_picture" /> <TextView android:id="@+id/account_un" + tools:text="@tools:sample/lorem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" @@ -38,6 +41,17 @@ android:singleLine="true" /> <TextView + android:layout_marginStart="2dp" + android:id="@+id/pronouns" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:visibility="gone" + tools:visibility="visible" + android:textColor="?colorPrimary" + tools:text="He/Him" /> + + <TextView android:id="@+id/account_dn" android:layout_width="wrap_content" android:layout_height="wrap_content" |