From 2db7b4b87c647ec22760471c854aa539a146b5ce Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 14 Jul 2022 11:04:27 +0200 Subject: [PATCH] Fix mentions --- .../app/fedilab/android/helper/Helper.java | 6 +-- .../android/helper/SpannableHelper.java | 44 ++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 8029b84a7..c3111a67d 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -119,7 +119,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -352,9 +352,9 @@ public class Helper { public static int counter = 1; static { - Map aMap = new HashMap<>(); - aMap.put(PatternType.MENTION, mentionPattern); + LinkedHashMap aMap = new LinkedHashMap<>(); aMap.put(PatternType.MENTION_LONG, mentionLongPattern); + aMap.put(PatternType.MENTION, mentionPattern); aMap.put(PatternType.TAG, hashtagPattern); aMap.put(PatternType.GROUP, groupPattern); patternHashMap = Collections.unmodifiableMap(aMap); diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index c164ae352..19feda165 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -105,7 +105,7 @@ public class SpannableHelper { } if (url != null && urlText != null && !url.equals(urlText) && !urlText.contains(" 0) { //It's a toot + CrossActionHelper.fetchRemoteStatus(context, currentAccount, url, new CrossActionHelper.Callback() { + @Override + public void federatedStatus(Status status) { + Intent intent = new Intent(context, ContextActivity.class); + intent.putExtra(Helper.ARG_STATUS, status); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + + @Override + public void federatedAccount(Account account) { + } + }); + } else {//It's an account + CrossActionHelper.fetchRemoteAccount(context, currentAccount, status.account, new CrossActionHelper.Callback() { + @Override + public void federatedStatus(Status status) { + } + + @Override + public void federatedAccount(Account account) { + Intent intent = new Intent(context, ProfileActivity.class); + Bundle b = new Bundle(); + b.putSerializable(Helper.ARG_ACCOUNT, account); + intent.putExtras(b); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + }); + } + } else { + Helper.openBrowser(context, newURL); + } + } @Override