1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Xiaomi: Allow disabling app notifications per device

This commit is contained in:
José Rebelo 2023-12-08 11:39:53 +00:00
parent f29995b571
commit 6479cc3bb0
2 changed files with 12 additions and 0 deletions

View File

@ -390,6 +390,7 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
settings.add(R.xml.devicesettings_display_caller);
settings.add(R.xml.devicesettings_vibrationpatterns);
settings.add(R.xml.devicesettings_donotdisturb_withauto_and_always);
settings.add(R.xml.devicesettings_send_app_notifications);
settings.add(R.xml.devicesettings_screen_on_on_notifications);
settings.add(R.xml.devicesettings_autoremove_notifications);
if (getCannedRepliesSlotCount(device) > 0) {

View File

@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Queue;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
@ -117,6 +118,11 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
}
public void onNotification(final NotificationSpec notificationSpec) {
if (!getDevicePrefs().getBoolean(DeviceSettingsPreferenceConst.PREF_SEND_APP_NOTIFICATIONS, true)) {
LOG.debug("App notifications disabled - ignoring");
return;
}
final XiaomiProto.Notification3.Builder notification3 = XiaomiProto.Notification3.newBuilder()
.setId(notificationSpec.getId())
.setUnknown4("") // ?
@ -175,6 +181,11 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
}
public void onDeleteNotification(final int id) {
if (!getDevicePrefs().getBoolean(DeviceSettingsPreferenceConst.PREF_SEND_APP_NOTIFICATIONS, true)) {
LOG.debug("App notifications disabled - ignoring delete");
return;
}
// TODO
}