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 4d33a66fb..6e8b26ec5 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 @@ -86,6 +86,11 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator { return true; } + @Override + public int getCannedRepliesSlotCount(final GBDevice device) { + return 16; + } + @Override public boolean supportsSleepAsAndroid() { return true; @@ -225,6 +230,7 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator { settings.add(R.xml.devicesettings_notification_wake_on_open); settings.add(R.xml.devicesettings_text_bitmaps); settings.add(R.xml.devicesettings_transliteration); + settings.add(R.xml.devicesettings_canned_reply_16); settings.add(R.xml.devicesettings_header_calendar); settings.add(R.xml.devicesettings_sync_calendar); 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 5320077fa..8fb2775e1 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 @@ -131,6 +131,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.Alarm; import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; +import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.model.DeviceService; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; @@ -1522,6 +1523,31 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { } } + @Override + public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) { + try { + JSONObject o = new JSONObject(); + o.put("t", "canned_responses_sync"); + JSONArray jsonMessages = new JSONArray(); + o.put("d", jsonMessages); + + for (String message : cannedMessagesSpec.cannedMessages) { + JSONObject jsonMessage = new JSONObject(); + jsonMessages.put(jsonMessage); + // Render unicode (emojis etc.) as an image for BangleJS to display + String unicodeRenderedAsImage = renderUnicodeAsImage(message); + // If the initial and rendered messages are not the same, include the rendered message as "disp(lay)" text so unicode is rendered on device + if (!unicodeRenderedAsImage.equals(message)) { + jsonMessage.put("disp", unicodeRenderedAsImage); + } + jsonMessage.put("text", message); + } + uartTxJSON("onSetCannedMessages", o); + } catch (JSONException e) { + LOG.info("JSONException: " + e.getLocalizedMessage()); + } + } + @Override public void onSetAlarms(ArrayList alarms) { try {