Skip to content

Commit

Permalink
feat(notification-filters): implement logic and save notification fil…
Browse files Browse the repository at this point in the history
…ters when they are cleared
  • Loading branch information
LucasGGamerM committed Oct 1, 2023
1 parent 8adb1d5 commit df2211f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
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),
Expand Down Expand Up @@ -175,6 +174,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
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) -> {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,40 @@ public void onAttach(Activity activity){

@Override
protected List<StatusDisplayItem> 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;
Expand Down

0 comments on commit df2211f

Please sign in to comment.