1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Allow media notifications to bypass app list

This commit is contained in:
José Rebelo 2022-10-19 00:05:03 +01:00 committed by Gitea
parent cd59511aad
commit 003dd6ce32
3 changed files with 27 additions and 6 deletions

View File

@ -263,18 +263,24 @@ public class NotificationListener extends NotificationListenerService {
logNotification(sbn, true);
LOG.debug("notificationAppListIsBlackList: " + GBApplication.getPrefs().getString("notification_list_is_blacklist","true"));
notificationStack.remove(sbn.getPackageName());
notificationStack.add(sbn.getPackageName());
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
final Prefs prefs = GBApplication.getPrefs();
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
// If media notifications ignore app list, check them before
if (mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
if (shouldIgnoreSource(sbn)) {
LOG.debug("Ignoring notification source");
return;
}
if (handleMediaSessionNotification(sbn)) return;
// If media notifications do NOT ignore app list, check them after
if (!mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
int dndSuppressed = 0;
if (rankingMap != null) {
@ -285,7 +291,6 @@ public class NotificationListener extends NotificationListenerService {
}
}
Prefs prefs = GBApplication.getPrefs();
if (prefs.getBoolean("notification_filter", false) && dndSuppressed == 1) {
return;
}
@ -722,9 +727,17 @@ public class NotificationListener extends NotificationListenerService {
notificationStack.remove(sbn.getPackageName());
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
final Prefs prefs = GBApplication.getPrefs();
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
// If media notifications ignore app list, check them before
if (mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
if (shouldIgnoreSource(sbn)) return;
if (handleMediaSessionNotification(sbn)) return;
// If media notifications do NOT ignore app list, check them after
if (!mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
if(Notification.CATEGORY_CALL.equals(sbn.getNotification().category)
&& activeCallPostTime == sbn.getPostTime()) {
@ -761,8 +774,8 @@ public class NotificationListener extends NotificationListenerService {
// Send notification remove request to device
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
for(GBDevice device : devices){
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
if (prefs.getBoolean("autoremove_notifications", true)) {
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
if (devicePrefs.getBoolean("autoremove_notifications", true)) {
for (int id : notificationsToRemove) {
LOG.info("Notification " + id + " removed, will ask device to delete it");
GBApplication.deviceService().onDeleteNotification(id);

View File

@ -223,6 +223,8 @@
<string name="pref_summary_notification_prefer_long_text">If available, send the long notification text to the device</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_title_notification_media_ignores_application_list">Media notifications ignore app list</string>
<string name="pref_summary_notification_media_ignores_application_list">Process media notifications before the app list. If this preference is unchecked, media applications need to be allowed in the application list for media controls to work on the device.</string>
<string name="pref_header_notification_application_settings">Per application settings</string>
<string name="pref_title_notification_use_as">Use the Applications list to…</string>
<string name="pref_title_notification_use_as_deny">Deny notifications from selected apps</string>

View File

@ -104,6 +104,12 @@
android:key="notification_list_is_blacklist"
android:summary="%s"
android:title="@string/pref_title_notification_use_as" />
<CheckBoxPreference
android:defaultValue="false"
android:key="notification_media_ignores_application_list"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_notification_media_ignores_application_list"
android:title="@string/pref_title_notification_media_ignores_application_list" />
<Preference
android:key="pref_key_blacklist"
android:title="@string/pref_applications_settings" />