diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/banglejs/BangleJSCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/banglejs/BangleJSCoordinator.java index 172c1fb8a..61efe43a3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/banglejs/BangleJSCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/banglejs/BangleJSCoordinator.java @@ -187,6 +187,7 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator { settings.add(R.xml.devicesettings_header_notifications); settings.add(R.xml.devicesettings_send_app_notifications); + settings.add(R.xml.devicesettings_notification_wake_on_open); settings.add(R.xml.devicesettings_text_bitmaps); settings.add(R.xml.devicesettings_transliteration); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java index 504266ed3..85175ea69 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java @@ -27,6 +27,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_GPS_USE_NETWORK_ONLY; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_INTENTS; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_INTERNET_ACCESS; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_NOTIFICATION_WAKE_ON_OPEN; import static nodomain.freeyourgadget.gadgetbridge.database.DBHelper.getUser; import static nodomain.freeyourgadget.gadgetbridge.devices.banglejs.BangleJSConstants.PREF_BANGLEJS_ACTIVITY_FULL_SYNC_START; import static nodomain.freeyourgadget.gadgetbridge.devices.banglejs.BangleJSConstants.PREF_BANGLEJS_ACTIVITY_FULL_SYNC_STATUS; @@ -98,6 +99,7 @@ import io.wax911.emojify.EmojiUtils; import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.WakeActivity; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.BarcodeFormat; import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard; @@ -637,9 +639,21 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { * Handle "notify" packet, used to send notification control from device to GB */ private void handleNotificationControl(JSONObject json) throws JSONException { + + String response = json.getString("n").toUpperCase(); + LOG.debug("Notification response: " + response); + + // Wake the Android device if the setting is toggled on by user. + // Doesn't work if run after the notification handling below for some reason (which + // I'd rather do since the screen would only be opened once the content was ready). + Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())); + if (devicePrefs.getBoolean(PREF_NOTIFICATION_WAKE_ON_OPEN, false) && response.equals("OPEN")) { + WakeActivity.start(getContext()); + } + GBDeviceEventNotificationControl deviceEvtNotificationControl = new GBDeviceEventNotificationControl(); // .title appears unused - deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.valueOf(json.getString("n").toUpperCase()); + deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.valueOf(response); if (json.has("id")) deviceEvtNotificationControl.handle = json.getInt("id"); if (json.has("tel"))