mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-27 02:55:50 +01:00
Delete notifications from connected devices only
This commit is contained in:
parent
9babbf504e
commit
d28cff478c
@ -774,17 +774,18 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
// Clean up removed notifications from internal list
|
// Clean up removed notifications from internal list
|
||||||
notificationsActive.removeAll(notificationsToRemove);
|
notificationsActive.removeAll(notificationsToRemove);
|
||||||
|
|
||||||
// TODO prevent this from being called multiple times for the same ID
|
|
||||||
// TODO prevent this from being called form notifications removed from the device
|
|
||||||
|
|
||||||
// Send notification remove request to device
|
// Send notification remove request to device
|
||||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getDevices();
|
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||||
for (GBDevice device : devices) {
|
for (GBDevice device : devices) {
|
||||||
|
if (!device.isInitialized()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
||||||
if (devicePrefs.getBoolean("autoremove_notifications", true)) {
|
if (devicePrefs.getBoolean("autoremove_notifications", true)) {
|
||||||
for (int id : notificationsToRemove) {
|
for (int id : notificationsToRemove) {
|
||||||
LOG.info("Notification " + id + " removed, will ask device to delete it");
|
LOG.info("Notification {} removed, deleting from {}", id, device.getAliasOrName());
|
||||||
GBApplication.deviceService().onDeleteNotification(id);
|
GBApplication.deviceService(device).onDeleteNotification(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user