Skip to content

Commit

Permalink
Bugfix/null notifications (#2)
Browse files Browse the repository at this point in the history
Notifications with no content will now not be echoed by the app
  • Loading branch information
SilverTuxedo authored Dec 23, 2020
1 parent d718470 commit 12e3343
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.talmar.conveyor.notificationFilters;

import android.app.Notification;
import android.service.notification.StatusBarNotification;

import androidx.annotation.NonNull;

/**
* Filters out notifications that don't have a title and text.
*/
public class NullContentFilter implements INotificationFilter {

@Override
public boolean shouldIgnoreNotification(@NonNull StatusBarNotification sbn) {
Notification notification = sbn.getNotification();

return notification.extras.get(Notification.EXTRA_TITLE) == null
&& notification.extras.get(Notification.EXTRA_TEXT) == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.talmar.conveyor.NotificationEchoing;
import com.talmar.conveyor.notificationFilters.CategoryFilter;
import com.talmar.conveyor.notificationFilters.INotificationFilter;
import com.talmar.conveyor.notificationFilters.NullContentFilter;
import com.talmar.conveyor.notificationFilters.OwnNotificationFilter;
import com.talmar.conveyor.notificationFilters.SelectedAppsFilter;
import com.talmar.conveyor.notificationFilters.SummaryNotificationFilter;
Expand Down Expand Up @@ -47,6 +48,7 @@ public void onCreate() {
new OwnNotificationFilter(),
new SummaryNotificationFilter(),
new CategoryFilter(),
new NullContentFilter(),
new SelectedAppsFilter(sharedPreferences),
new UserPresenceFilter(this, sharedPreferences)
};
Expand Down

0 comments on commit 12e3343

Please sign in to comment.