Fix issue #1014 - Wrong profiles when enabling remote conversations

Media3
Thomas 10 months ago
parent dd119449f3
commit 4204f658d7

@ -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;
}

@ -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) {
targetedMention = mention;
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);
}

@ -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());

@ -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 ---

@ -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()));
}),

@ -241,7 +241,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
status.underlined = true;
holder.binding.messageContent.setText(
status.getSpanContent(context,
status.getSpanContent(context, false,
new WeakReference<>(holder.binding.messageContent),
() -> mRecyclerView.post(() -> notifyItemChanged(holder.getBindingAdapterPosition()))),
TextView.BufferType.SPANNABLE);

@ -55,7 +55,7 @@ public class StatusHistoryAdapter extends RecyclerView.Adapter<RecyclerView.View
StatusHistoryViewHolder holder = (StatusHistoryViewHolder) viewHolder;
Status status = statuses.get(position);
holder.binding.statusContent.setText(
status.getSpanContent(context,
status.getSpanContent(context, false,
new WeakReference<>(holder.binding.statusContent), null),
TextView.BufferType.SPANNABLE);
if (status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {

@ -28,7 +28,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;

Loading…
Cancel
Save