From 67338b6c8567c79146128084ac34077eb357b5c0 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 6 Jan 2023 11:31:25 -0300 Subject: [PATCH 1/4] Allowing multiple notifications by default --- .../java/org/joinmastodon/android/PushNotificationReceiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index 00946de41..d144dcd1c 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, NOTIFICATION_ID, builder.build()); + nm.notify(accountID, (int)System.currentTimeMillis(), builder.build()); } } From 23e49c52e54587ffbaf4158db0621f60be29023d Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 6 Jan 2023 12:26:52 -0300 Subject: [PATCH 2/4] Its working, but it still needs a better icon --- .../java/org/joinmastodon/android/GlobalUserPreferences.java | 3 +++ .../org/joinmastodon/android/PushNotificationReceiver.java | 2 +- .../org/joinmastodon/android/fragments/SettingsFragment.java | 4 ++++ mastodon/src/main/res/values/strings_sk.xml | 1 + 4 files changed, 9 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 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 From 3951acf12e94b4bd49ba77d6f07ba862b684f374 Mon Sep 17 00:00:00 2001 From: Florian Obernberger Date: Fri, 6 Jan 2023 18:12:42 +0100 Subject: [PATCH 3/4] Add new and custom icon (cherry picked from commit 13a80fb536a003f58a2ca7b7886072d2c983404b) --- .../ic_fluent_custom_alert_latest_24_regular.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 mastodon/src/main/res/drawable/ic_fluent_custom_alert_latest_24_regular.xml diff --git a/mastodon/src/main/res/drawable/ic_fluent_custom_alert_latest_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_custom_alert_latest_24_regular.xml new file mode 100644 index 000000000..fef28319b --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_custom_alert_latest_24_regular.xml @@ -0,0 +1,12 @@ + + + + From 263bde658e622c91e2b087bc56bd45f42f42394c Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 6 Jan 2023 14:47:06 -0300 Subject: [PATCH 4/4] Fixing #29 for good --- .../org/joinmastodon/android/fragments/SettingsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0a2dc1515..ce7c8ecc4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -243,7 +243,7 @@ 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->{ + items.add(new SwitchItem(R.string.sk_keep_only_latest_notification, R.drawable.ic_fluent_custom_alert_latest_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{ GlobalUserPreferences.keepOnlyLatestNotification=i.checked; GlobalUserPreferences.save(); }));