don't overwrite notifications

re: sk22#219
This commit is contained in:
sk 2023-01-10 05:38:28 -03:00 committed by LucasGGamerM
parent b666048603
commit df44d4cc4f
4 changed files with 7 additions and 7 deletions

View File

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

View File

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

View File

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M6.25 3C5.007 3 4 4.007 4 5.25v2.5C4 8.993 5.007 10 6.25 10h9.5C16.993 10 18 8.993 18 7.75v-2.5C18 4.007 16.993 3 15.75 3h-9.5zM5.5 5.25c0-0.414 0.336-0.75 0.75-0.75h9.5c0.414 0 0.75 0.336 0.75 0.75v2.5c0 0.414-0.336 0.75-0.75 0.75h-9.5C5.836 8.5 5.5 8.164 5.5 7.75v-2.5zM8.7 16C8.313 16 8 16.336 8 16.75s0.313 0.75 0.7 0.75h4.6c0.387 0 0.7-0.336 0.7-0.75S13.687 16 13.3 16H8.7zm8.653 0.445L17.28 16.53c-0.266 0.267-0.683 0.29-0.976 0.073L16.22 16.53l-2-2c-0.267-0.266-0.29-0.682-0.073-0.976l0.073-0.084 2-2c0.293-0.293 0.767-0.293 1.06 0 0.267 0.266 0.29 0.683 0.073 0.976L17.28 12.53l-0.719 0.721h1.5c0.647 0 1.18-0.492 1.243-1.122L19.311 12V9.75c0-0.415 0.335-0.75 0.75-0.75 0.38 0 0.693 0.282 0.743 0.648L20.81 9.75V12c0 1.462-1.142 2.658-2.583 2.745L18.06 14.75h-1.499l0.718 0.719c0.267 0.266 0.29 0.683 0.073 0.976zM18 19.25v-2.026l-0.013 0.012c-0.405 0.406-0.96 0.57-1.487 0.495v1.519c0 0.414-0.336 0.75-0.75 0.75h-9.5c-0.414 0-0.75-0.336-0.75-0.75v-5c0-0.414 0.336-0.75 0.75-0.75h6.822c0.058-0.192 0.148-0.376 0.272-0.543l0.022-0.03 0.12-0.14L14.275 12H6.25C5.007 12 4 13.007 4 14.25v5c0 1.243 1.007 2.25 2.25 2.25h9.5c1.243 0 2.25-1.007 2.25-2.25z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@ -143,6 +143,7 @@
<string name="sk_announcements">Announcements</string>
<string name="sk_mark_as_read">Mark as read</string>
<string name="sk_settings_about_instance">About instance</string>
<string name="sk_settings_single_notification">Only show one notification</string>
<!-- accessibility labels-->
<string name="sk_poll_option_add">Add new poll option</string>