mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Add canned response support to BangleJS
This commit is contained in:
parent
33b2d43991
commit
e870122dd0
@ -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);
|
||||
|
@ -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<? extends Alarm> alarms) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user