diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java index a649e3f97..cf103de63 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java @@ -135,7 +135,6 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc return true; } else if (item.getItemId() == R.id.filter_notifications) { Context ctx = getToolbarContext(); - LinearLayout linearLayout = new LinearLayout(getToolbarContext()); String[] listItems = { ctx.getString(R.string.notification_type_mentions_and_replies), ctx.getString(R.string.notification_type_reblog), @@ -175,6 +174,14 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc this.allNotificationsFragment.reload(); }).setNeutralButton(R.string.clear, (d, which) -> { Arrays.fill(checkedItems, true); + getLocalPrefs().notificationFilters.mention=checkedItems[0]; + getLocalPrefs().notificationFilters.reblog=checkedItems[1]; + getLocalPrefs().notificationFilters.favourite=checkedItems[2]; + getLocalPrefs().notificationFilters.follow=checkedItems[3]; + getLocalPrefs().notificationFilters.poll=checkedItems[4]; + getLocalPrefs().notificationFilters.update=checkedItems[5]; + getLocalPrefs().notificationFilters.status=checkedItems[6]; + getLocalPrefs().save(); this.allNotificationsFragment.reload(); }).setNegativeButton(R.string.cancel, (d, which) -> {}); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java index 5c735c540..71b82aa1a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java @@ -88,6 +88,40 @@ public class NotificationsListFragment extends BaseStatusListFragment buildDisplayItems(Notification n){ + if(!onlyMentions && !onlyPosts){ + switch(n.type){ + case MENTION -> { + if(!getLocalPrefs().notificationFilters.mention) + return new ArrayList<>(); + } + case REBLOG -> { + if(!getLocalPrefs().notificationFilters.reblog) + return new ArrayList<>(); + } + case FAVORITE -> { + if(!getLocalPrefs().notificationFilters.favourite) + return new ArrayList<>(); + } + case FOLLOW, FOLLOW_REQUEST -> { + if(!getLocalPrefs().notificationFilters.follow) + return new ArrayList<>(); + } + case POLL -> { + if(!getLocalPrefs().notificationFilters.poll) + return new ArrayList<>(); + } + case UPDATE -> { + if(!getLocalPrefs().notificationFilters.update) + return new ArrayList<>(); + } + case STATUS -> { + if(!getLocalPrefs().notificationFilters.status) + return new ArrayList<>(); + } + default -> {} + } + } + NotificationHeaderStatusDisplayItem titleItem; if(n.type==Notification.Type.MENTION || n.type==Notification.Type.STATUS){ titleItem=null;