mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix issue #931 - Click on card does not open Mastodon posts inside the app
This commit is contained in:
parent
243039151a
commit
65b9015d51
2 changed files with 111 additions and 106 deletions
|
@ -598,6 +598,21 @@ public class SpannableHelper {
|
|||
public void onClick(@NonNull View textView) {
|
||||
|
||||
textView.setTag(CLICKABLE_SPAN);
|
||||
linkClickAction(context, finalUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
if (linkColor != -1) {
|
||||
ds.setColor(linkColor);
|
||||
}
|
||||
}
|
||||
}, start, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
public static void linkClickAction(Context context, String finalUrl) {
|
||||
Pattern link = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w._-]*[0-9]*)(/[0-9]+)?$");
|
||||
Matcher matcherLink = link.matcher(finalUrl);
|
||||
Pattern linkLong = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w_.-]+@[a-zA-Z0-9][a-zA-Z0-9.-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+)(/[0-9]+)?$");
|
||||
|
@ -705,18 +720,6 @@ public class SpannableHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
if (linkColor != -1) {
|
||||
ds.setColor(linkColor);
|
||||
}
|
||||
}
|
||||
}, start, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
|
||||
private static void emails(Context context, Spannable content) {
|
||||
// --- For all patterns defined in Helper class ---
|
||||
Pattern pattern = Helper.emailPattern;
|
||||
|
|
|
@ -844,7 +844,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.cardTitle.setText(statusToDeal.card.title);
|
||||
holder.binding.cardDescription.setText(statusToDeal.card.description);
|
||||
holder.binding.cardUrl.setText(Helper.transformURL(context, statusToDeal.card.url));
|
||||
holder.binding.card.setOnClickListener(v -> Helper.openBrowser(context, Helper.transformURL(context, statusToDeal.card.url)));
|
||||
holder.binding.card.setOnClickListener(v -> {
|
||||
SpannableHelper.linkClickAction(context, statusToDeal.card.url);
|
||||
});
|
||||
holder.binding.card.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.binding.card.setVisibility(View.GONE);
|
||||
|
|
Loading…
Reference in a new issue