From dd4bad706bf03d975920159d2600ed34744d4b83 Mon Sep 17 00:00:00 2001 From: FineFindus <63370021+FineFindus@users.noreply.github.com> Date: Wed, 5 Apr 2023 19:54:26 +0200 Subject: [PATCH] fix(notification): saved used ids --- .../java/org/joinmastodon/android/GlobalUserPreferences.java | 3 +++ .../org/joinmastodon/android/PushNotificationReceiver.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index d16262f15..bcd85af70 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -52,6 +52,7 @@ public class GlobalUserPreferences{ public static boolean compactReblogReplyLine; public static boolean replyLineAboveHeader; public static boolean swapBookmarkWithBoostAction; + public static int latestNotificationId = 0; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -126,6 +127,7 @@ public class GlobalUserPreferences{ accountsWithLocalOnlySupport=prefs.getStringSet("accountsWithLocalOnlySupport", new HashSet<>()); accountsInGlitchMode=prefs.getStringSet("accountsInGlitchMode", new HashSet<>()); replyVisibility=prefs.getString("replyVisibility", null); + latestNotificationId=prefs.getInt("latestNotificationId", 0); try { if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){ @@ -182,6 +184,7 @@ public class GlobalUserPreferences{ .putStringSet("accountsWithLocalOnlySupport", accountsWithLocalOnlySupport) .putStringSet("accountsInGlitchMode", accountsInGlitchMode) .putString("replyVisibility", replyVisibility) + .putInt("latestNotificationId", latestNotificationId) .apply(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index da76f0c03..41fae8d6a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -54,7 +54,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ private static final String ACTION_KEY_TEXT_REPLY = "ACTION_KEY_TEXT_REPLY"; private static final int SUMMARY_ID = 791; - private static int notificationId = 0; + private static int notificationId = GlobalUserPreferences.latestNotificationId; @Override public void onReceive(Context context, Intent intent){ @@ -214,6 +214,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ } int id = GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : notificationId++; + GlobalUserPreferences.save(); if (notification != null){ switch (pn.notificationType){