Order notification by date

pull/483/head
Thomas 2 years ago
parent a946ea49d1
commit 9dc4b46fdb

@ -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("<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!</a).)*)</a>");
public static final Pattern imgPattern = Pattern.compile("<img [^>]*src=\"([^\"]+)\"[^>]*>");

@ -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<String, String> 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<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> 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<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> 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);
}

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

Loading…
Cancel
Save