diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 15c102dea..da3e4c7c4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -32,6 +32,7 @@ public class GlobalUserPreferences{ public static boolean enableDeleteNotifications; public static boolean relocatePublishButton; public static boolean reduceMotion; + public static boolean keepOnlyLatestNotification; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -70,6 +71,7 @@ public class GlobalUserPreferences{ voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true); enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", true); reduceMotion=prefs.getBoolean("reduceMotion", false); + keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>()); @@ -105,6 +107,7 @@ public class GlobalUserPreferences{ .putBoolean("uniformNotificationIcon", uniformNotificationIcon) .putBoolean("enableDeleteNotifications", enableDeleteNotifications) .putBoolean("reduceMotion", reduceMotion) + .putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification) .putString("publishButtonText", publishButtonText) .putInt("theme", theme.ordinal()) .putString("color", color.name()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index d144dcd1c..560127c64 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -160,6 +160,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{ if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){ builder.setSubText(accountName); } - nm.notify(accountID, (int)System.currentTimeMillis(), builder.build()); + nm.notify(accountID, GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : (int)System.currentTimeMillis(), builder.build()); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index b50936034..0a2dc1515 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -243,6 +243,10 @@ public class SettingsFragment extends MastodonToolbarFragment{ items.add(new SwitchItem(R.string.notify_reblog, R.drawable.ic_fluent_arrow_repeat_all_24_regular, pushSubscription.alerts.reblog, i->onNotificationsChanged(PushNotification.Type.REBLOG, i.checked))); items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_fluent_mention_24_regular, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, i.checked))); items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_alert_24_regular, pushSubscription.alerts.status, i->onNotificationsChanged(PushNotification.Type.STATUS, i.checked))); + items.add(new SwitchItem(R.string.sk_keep_only_latest_notification, R.drawable.ic_fluent_alert_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{ + GlobalUserPreferences.keepOnlyLatestNotification=i.checked; + GlobalUserPreferences.save(); + })); items.add(new HeaderItem(R.string.settings_account)); items.add(new TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular)); diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index f83d6610d..911280364 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -136,4 +136,5 @@ Recently used Clear recently used emoji Disable "Relocate publish button" to allow customization + Keep only latest notification \ No newline at end of file