Commit 7ab24d90 authored by Thomas's avatar Thomas
Browse files

Indicator with pronouns

parent 773322b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@ public class Status implements Serializable, Cloneable {
    public transient MathJaxView mathJaxView;
    public String lemmy_post_id;

    public transient String pronouns = null;

    @Override
    public boolean equals(@Nullable Object obj) {
        boolean same = false;
+21 −2
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Emoji;
import app.fedilab.android.mastodon.client.entities.api.EmojiInstance;
import app.fedilab.android.mastodon.client.entities.api.Field;
import app.fedilab.android.mastodon.client.entities.api.Mention;
import app.fedilab.android.mastodon.client.entities.api.Poll;
import app.fedilab.android.mastodon.client.entities.api.Status;
@@ -1358,6 +1359,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
        if (getItemViewType(position) == TYPE_NORMAL) {
            Status status = statusList.get(position);
            StatusSimpleViewHolder holder = (StatusSimpleViewHolder) viewHolder;

            if (status.media_attachments != null && status.media_attachments.size() > 0) {
                holder.binding.simpleMedia.removeAllViews();
                List<Attachment> attachmentList = statusList.get(position).media_attachments;
@@ -1421,13 +1423,30 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder

        } else if (getItemViewType(position) == TYPE_COMPOSE) {
            Status statusDraft = statusList.get(position);

            if(position > 0 && getItemViewType(position -1 ) == TYPE_NORMAL) {
                Status statusFromUser = statusList.get(position-1);
                Account accountFromUser = statusFromUser.account;
                statusFromUser.pronouns = null;
                if(accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
                    for(Field field: accountFromUser.fields) {
                        if(field.name.toLowerCase().startsWith("pronoun")) {
                            statusList.get(position).pronouns = field.value;
                            break;
                        }
                    }
                }
            }
            ComposeViewHolder holder = (ComposeViewHolder) viewHolder;
            boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
            boolean mathsComposer = sharedpreferences.getBoolean(context.getString(R.string.SET_MATHS_COMPOSER), true);
            boolean forwardTag = sharedpreferences.getBoolean(context.getString(R.string.SET_FORWARD_TAGS_IN_REPLY), false);


            if(statusDraft.pronouns != null) {
                holder.binding.genders.setVisibility(View.VISIBLE);
                holder.binding.pronouns.setText(statusDraft.pronouns);
            } else {
                holder.binding.genders.setVisibility(View.GONE);
            }
            if (mathsComposer) {
                holder.binding.buttonMathsComposer.setVisibility(View.VISIBLE);
                holder.binding.buttonMathsComposer.setOnClickListener(v -> {
+18 −2
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import android.os.Looper;
import android.text.Html;
import android.text.SpannableString;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -148,6 +147,7 @@ import app.fedilab.android.mastodon.activities.StatusInfoActivity;
import app.fedilab.android.mastodon.activities.TimelineActivity;
import app.fedilab.android.mastodon.activities.admin.AdminAccountActivity;
import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Field;
import app.fedilab.android.mastodon.client.entities.api.Poll;
import app.fedilab.android.mastodon.client.entities.api.Reaction;
import app.fedilab.android.mastodon.client.entities.api.Status;
@@ -482,7 +482,23 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
        }

        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")) {
                    statusToDeal.pronouns = field.value;
                    break;
                }
            }
            if(statusToDeal.pronouns == null) {
                statusToDeal.pronouns = "none";
            }
        }
        if(statusToDeal.pronouns != null && !statusToDeal.pronouns.equalsIgnoreCase("none")) {
            holder.binding.pronouns.setVisibility(View.VISIBLE);
            holder.binding.pronouns.setText(statusToDeal.pronouns);
        } else {
            holder.binding.pronouns.setVisibility(View.INVISIBLE);
        }
        if (statusToDeal.quote != null && (statusToDeal.spoiler_text == null || statusToDeal.spoiler_text.trim().isEmpty() || statusToDeal.isExpended)) {
            holder.binding.quotedMessage.cardviewContainer.setCardElevation((int) Helper.convertDpToPixel(5, context));
            holder.binding.quotedMessage.dividerCard.setVisibility(View.GONE);
+13 −1
Original line number Diff line number Diff line
@@ -163,13 +163,25 @@

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/display_name"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="6dp"
                            android:ellipsize="end"
                            android:singleLine="true"
                            tools:text="@tools:sample/full_names" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/pronouns"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="6dp"
                            android:layout_weight="1"
                            android:visibility="invisible"
                            tools:visibility="visible"
                            android:textColor="?colorPrimary"
                            android:ellipsize="end"
                            android:singleLine="true"
                            tools:text="@tools:sample/full_names" />
                            tools:text="He/Him" />

                        <androidx.appcompat.widget.AppCompatImageView
                            android:id="@+id/local_only"
+26 −3
Original line number Diff line number Diff line
@@ -42,8 +42,31 @@
            app:layout_constraintTop_toTopOf="parent">

        </androidx.core.widget.NestedScrollView>


        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/genders"
            android:visibility="gone"
            tools:visibility="visible"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toStartOf="@id/button_emoji"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/laTexView_container"
            android:orientation="horizontal"
            android:layout_marginStart="6dp"
            >
            <com.google.android.material.textview.MaterialTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Pronouns"/>
            <com.google.android.material.textview.MaterialTextView
                android:layout_marginStart="10dp"
                android:id="@+id/pronouns"
                style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
                android:textColor="?colorPrimary"
                tools:text="He/Him"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </androidx.appcompat.widget.LinearLayoutCompat>
        <com.google.android.material.textfield.MaterialAutoCompleteTextView
            android:id="@+id/content_spoiler"
            android:layout_width="0dp"
@@ -57,7 +80,7 @@
            android:visibility="gone"
            app:layout_constraintEnd_toStartOf="@id/button_emoji"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/laTexView_container"
            app:layout_constraintTop_toBottomOf="@+id/genders"
            tools:visibility="visible" />

        <com.google.android.material.button.MaterialButton
Loading