From 9dc4b46fdb55ff2375e55051437685bd9a8bca9a Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 17 Nov 2022 14:06:48 +0100 Subject: [PATCH] Order notification by date --- app/src/main/java/app/fedilab/android/helper/Helper.java | 4 ++-- .../java/app/fedilab/android/helper/SpannableHelper.java | 9 ++++----- .../fragment/timeline/FragmentMastodonNotification.java | 3 ++- 3 files changed, 8 insertions(+), 8 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 05352d7d..f9003667 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -340,7 +340,7 @@ public class Helper { public static final Pattern codePattern = Pattern.compile("code=([\\w-]+)"); public static final Pattern nitterIDPattern = Pattern.compile("/status/(\\d+)"); public static final Pattern emailPattern = Pattern.compile("(\\s+[\\w_.-]+@[a-zA-Z0-9][a-zA-Z0-9.-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+)"); - public static final Pattern urlPattern = Pattern.compile( + /*public static final Pattern urlPattern = Pattern.compile( "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); @@ -348,7 +348,7 @@ public class Helper { public static final Pattern urlPatternSimple = Pattern.compile( "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)", - Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);*/ public static final Pattern aLink = Pattern.compile("]*(((?!"); public static final Pattern imgPattern = Pattern.compile("]*src=\"([^\"]+)\"[^>]*>"); 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 f94a7576..df8c628a 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -17,8 +17,6 @@ package app.fedilab.android.helper; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.helper.Helper.USER_AGENT; -import static app.fedilab.android.helper.Helper.urlPattern; -import static app.fedilab.android.helper.Helper.urlPatternSimple; import static app.fedilab.android.helper.ThemeHelper.linkColor; import android.content.ClipData; @@ -39,6 +37,7 @@ import android.text.TextPaint; import android.text.style.ClickableSpan; import android.text.style.QuoteSpan; import android.text.style.URLSpan; +import android.util.Patterns; import android.view.LayoutInflater; import android.view.View; import android.webkit.URLUtil; @@ -191,7 +190,7 @@ public class SpannableHelper { private static void linkify(Context context, SpannableStringBuilder content, HashMap urlDetails) { //--- URLs ---- - Matcher matcherLink = urlPatternSimple.matcher(content); + Matcher matcherLink = Patterns.WEB_URL.matcher(content); int offSetTruncate = 0; @@ -315,7 +314,7 @@ public class SpannableHelper { Map> map = httpsURLConnection.getHeaderFields(); for (Map.Entry> entry : map.entrySet()) { if (entry.toString().toLowerCase().startsWith("location")) { - Matcher matcher = urlPattern.matcher(entry.toString()); + Matcher matcher = Patterns.WEB_URL.matcher(entry.toString()); if (matcher.find()) { redirect = matcher.group(1); } @@ -544,7 +543,7 @@ public class SpannableHelper { Map> map = httpsURLConnection.getHeaderFields(); for (Map.Entry> entry : map.entrySet()) { if (entry.toString().toLowerCase().startsWith("location")) { - Matcher matcher = urlPattern.matcher(entry.toString()); + Matcher matcher = Patterns.WEB_URL.matcher(entry.toString()); if (matcher.find()) { redirect = matcher.group(1); } diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java index fbd29dc8..50ca2d89 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java @@ -616,7 +616,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati for (Notification notificationsAlreadyPresent : notificationList) { //We compare the date of each status and we only add status having a date greater than the another, it is inserted at this position //Pinned messages are ignored because their date can be older - if (Helper.compareTo(notificationReceived.id, notificationsAlreadyPresent.id) > 0) { + //if (Helper.compareTo(notificationReceived.id, notificationsAlreadyPresent.id) > 0) { + if (notificationReceived.created_at.after(notificationsAlreadyPresent.created_at)) { if (!notificationList.contains(notificationReceived)) { notificationList.add(position, notificationReceived); notificationAdapter.notifyItemInserted(position);