1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-22 06:41:06 +02:00

Add option to ignore low priority notifications

This commit is contained in:
José Rebelo 2022-08-25 14:29:34 +01:00 committed by Gitea
parent 5920b26aab
commit 5637a2bc45
3 changed files with 18 additions and 1 deletions

View File

@ -911,10 +911,11 @@ public class NotificationListener extends NotificationListenerService {
return true;
}
Prefs prefs = GBApplication.getPrefs();
// Check for screen on when posting the notification; for removal, the screen
// has to be on (obviously)
if(!remove) {
Prefs prefs = GBApplication.getPrefs();
if (!prefs.getBoolean("notifications_generic_whenscreenon", false)) {
PowerManager powermanager = (PowerManager) getSystemService(POWER_SERVICE);
if (powermanager != null && powermanager.isScreenOn()) {
@ -924,6 +925,13 @@ public class NotificationListener extends NotificationListenerService {
}
}
if (sbn.getNotification().priority < Notification.PRIORITY_DEFAULT) {
if (prefs.getBoolean("notifications_ignore_low_priority", true)) {
LOG.info("Ignoring low priority notification");
return true;
}
}
if (shouldIgnoreOngoing(sbn)){
return false;
}

View File

@ -197,6 +197,8 @@
<string name="pref_title_notifications_generic">Generic notification support</string>
<string name="pref_title_notifications_generic_settings">Android notification settings</string>
<string name="pref_title_whenscreenon">…also when screen is on</string>
<string name="pref_title_notifications_ignore_low_priority">Ignore low priority notifications</string>
<string name="pref_summary_notifications_ignore_low_priority">Do not send low and minimum priority notifications to the watch</string>
<string name="pref_title_notification_filter">Do Not Disturb</string>
<string name="pref_summary_notification_filter">Block all notifications when Do Not Disturb is enabled on the phone</string>
<string name="pref_header_notification_application_settings">Per application settings</string>

View File

@ -17,6 +17,13 @@
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_whenscreenon" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notifications_ignore_low_priority"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_notifications_ignore_low_priority"
android:summary="@string/pref_summary_notifications_ignore_low_priority" />
<CheckBoxPreference
android:defaultValue="false"
android:key="minimize_priority"