Garmin: Add setting to disable notifications

This commit is contained in:
José Rebelo 2024-04-21 20:10:21 +01:00
parent 438bfa4cce
commit dbebca5b6b
2 changed files with 11 additions and 2 deletions

View File

@ -36,12 +36,13 @@ public abstract class GarminCoordinator extends AbstractBLEDeviceCoordinator {
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
final List<Integer> notifications = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
notifications.add(R.xml.devicesettings_send_app_notifications);
final List<Integer> connection = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CONNECTION);
connection.add(R.xml.devicesettings_high_mtu);
if (getCannedRepliesSlotCount(device) > 0) {
final List<Integer> notifications = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
notifications.add(R.xml.devicesettings_garmin_default_reply_suffix);
notifications.add(R.xml.devicesettings_canned_reply_16);
notifications.add(R.xml.devicesettings_canned_dismisscall_16);

View File

@ -66,6 +66,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GARMIN_DEFAULT_REPLY_SUFFIX;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SEND_APP_NOTIFICATIONS;
public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommunicator.Callback {
@ -258,6 +259,13 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
@Override
public void onNotification(NotificationSpec notificationSpec) {
if (!getDevicePrefs().getBoolean(PREF_SEND_APP_NOTIFICATIONS, true)) {
// FIXME: Instead of silently dropping the notification, use NotificationSubscriptionMessage
// to signal to the watch that they're disabled
LOG.debug("App notifications disabled - ignoring");
return;
}
sendOutgoingMessage(notificationsHandler.onNotification(notificationSpec));
}