Commit 4204f658 authored by Thomas's avatar Thomas
Browse files

Fix issue #1014 - Wrong profiles when enabling remote conversations

parent dd119449
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.List;

import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.SpannableHelper;
import de.timfreiheit.mathjax.android.MathJaxView;

@@ -152,9 +153,9 @@ public class Status implements Serializable, Cloneable {
        return same;
    }

    public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference, Callback callback) {
    public synchronized Spannable getSpanContent(Context context, boolean checkRemotely, WeakReference<View> viewWeakReference, Callback callback) {
        if (contentSpan == null) {
            contentSpan = SpannableHelper.convert(context, content, this, null, null, viewWeakReference, callback, true, true);
            contentSpan = SpannableHelper.convert(context, content, this, null, null, checkRemotely, viewWeakReference, callback, true, true);
        }
        return contentSpan;
    }
+16 −1
Original line number Diff line number Diff line
@@ -111,6 +111,12 @@ public class SpannableHelper {
    public static Spannable convert(Context context, String text,
                                    Status status, Account account, Announcement announcement,
                                    WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml, boolean convertMarkdown) {
        return convert(context, text, status, account, announcement, false, viewWeakReference, callback, convertHtml, convertMarkdown);
    }

    public static Spannable convert(Context context, String text,
                                    Status status, Account account, Announcement announcement, boolean checkRemotely,
                                    WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml, boolean convertMarkdown) {
        if (text == null) {
            return null;
        }
@@ -296,14 +302,23 @@ public class SpannableHelper {
                            intent = new Intent(context, ProfileActivity.class);
                            args = new Bundle();
                            Mention targetedMention = null;
                            String acct = null;

                            for (Mention mention : mentions) {
                                if (word.compareToIgnoreCase("@" + mention.username) == 0) {
                                    if(!checkRemotely) {
                                        targetedMention = mention;
                                    } else {
                                        acct = mention.acct;
                                    }
                                    break;
                                }
                            }

                            if (targetedMention != null) {
                                args.putString(Helper.ARG_USER_ID, targetedMention.id);
                            } else if( acct != null){
                                args.putString(Helper.ARG_MENTION, acct);
                            } else {
                                args.putString(Helper.ARG_MENTION, word);
                            }
+1 −1
Original line number Diff line number Diff line
@@ -1395,7 +1395,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                holder.binding.simpleMediaContainer.setVisibility(View.GONE);
            }
            holder.binding.statusContent.setText(
                    status.getSpanContent(context,
                    status.getSpanContent(context, false,
                            new WeakReference<>(holder.binding.statusContent), () -> mRecyclerView.post(() -> notifyItemChanged(position))),
                    TextView.BufferType.SPANNABLE);
            holder.binding.statusContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
+1 −1
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
        }
        //--- MAIN CONTENT ---
        holder.binding.statusContent.setText(
                conversation.last_status.getSpanContent(context,
                conversation.last_status.getSpanContent(context, false,
                        new WeakReference<>(holder.binding.statusContent), () -> mRecyclerView.post(() -> notifyItemChanged(holder.getBindingAdapterPosition()))),
                TextView.BufferType.SPANNABLE);
        //--- DATE ---
+2 −3
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            });
            holder.binding.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
            holder.binding.quotedMessage.statusContent.setText(
                    statusToDeal.quote.getSpanContent(context,
                    statusToDeal.quote.getSpanContent(context, remote,
                            new WeakReference<>(holder.binding.quotedMessage.statusContent), null),
                    TextView.BufferType.SPANNABLE);
            MastodonHelper.loadPPMastodon(holder.binding.quotedMessage.avatar, statusToDeal.quote.account);
@@ -1413,10 +1413,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            }
            case "direct" -> holder.binding.actionButtonBoost.setVisibility(View.GONE);
        }

        //--- MAIN CONTENT ---
        holder.binding.statusContent.setText(
                statusToDeal.getSpanContent(context,
                statusToDeal.getSpanContent(context, remote,
                        new WeakReference<>(holder.binding.statusContent), () -> {
                            recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
                        }),
Loading