Support pronouns

This commit is contained in:
Thomas 2024-01-23 19:03:41 +01:00
parent 7ab24d900b
commit 394d72bd01
3 changed files with 29 additions and 0 deletions

View file

@ -88,6 +88,7 @@ public class Account implements Serializable {
@SerializedName("role") @SerializedName("role")
public Role role; public Role role;
public transient RelationShip relationShip; public transient RelationShip relationShip;
public transient String pronouns = null;
public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) { public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) {

View file

@ -30,6 +30,7 @@ import java.util.List;
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.helper.MastodonHelper; 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.accountUn.setText(String.format("@%s", account.acct));
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;
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); MastodonHelper.loadPPMastodon(holder.binding.accountPp, account);
return holder.view; return holder.view;
} }

View file

@ -15,6 +15,7 @@
see <http://www.gnu.org/licenses> see <http://www.gnu.org/licenses>
--> -->
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" <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:id="@+id/account_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -27,16 +28,29 @@
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="5dp" android:layout_margin="5dp"
tools:src="@tools:sample/avatars"
android:contentDescription="@string/profile_picture" /> android:contentDescription="@string/profile_picture" />
<TextView <TextView
android:id="@+id/account_un" android:id="@+id/account_un"
tools:text="@tools:sample/lorem"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:singleLine="true" /> 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 <TextView
android:id="@+id/account_dn" android:id="@+id/account_dn"
android:layout_width="wrap_content" android:layout_width="wrap_content"