From df44d4cc4f112ba59e16a1213a816478cbe1d68c Mon Sep 17 00:00:00 2001 From: sk Date: Tue, 10 Jan 2023 05:38:28 -0300 Subject: [PATCH] don't overwrite notifications re: sk22#219 --- .../joinmastodon/android/PushNotificationReceiver.java | 8 ++------ .../joinmastodon/android/fragments/SettingsFragment.java | 2 +- .../res/drawable/ic_fluent_convert_range_24_regular.xml | 3 +++ mastodon/src/main/res/values/strings_sk.xml | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 mastodon/src/main/res/drawable/ic_fluent_convert_range_24_regular.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index a667f8ea1..3b8dfbb28 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -37,8 +37,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{ private static final String TAG="PushNotificationReceive"; public static final int NOTIFICATION_ID=178; - - private static int notificationID; + private static int notificationId = 0; @Override public void onReceive(Context context, Intent intent){ @@ -127,9 +126,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{ .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); } Drawable avatar=ImageCache.getInstance(context).get(new UrlImageLoaderRequest(pn.icon, V.dp(50), V.dp(50))); - - notificationID = GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : (int)System.currentTimeMillis(); - Intent contentIntent=new Intent(context, MainActivity.class); contentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); contentIntent.putExtra("fromNotification", true); @@ -166,6 +162,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{ if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){ builder.setSubText(accountName); } - nm.notify(accountID, notificationID, builder.build()); + nm.notify(accountID, GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : notificationId++, 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 1022a6194..1bd1b1df3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -244,7 +244,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_custom_alert_latest_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{ + items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{ GlobalUserPreferences.keepOnlyLatestNotification=i.checked; GlobalUserPreferences.save(); })); diff --git a/mastodon/src/main/res/drawable/ic_fluent_convert_range_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_convert_range_24_regular.xml new file mode 100644 index 000000000..9e9786edf --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_convert_range_24_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 9e4a42b31..be8b6e499 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -143,6 +143,7 @@ Announcements Mark as read About instance + Only show one notification Add new poll option