1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-15 21:27:51 +01:00

Bangle.js fix message REPLY option

This commit is contained in:
Gordon Williams 2022-06-10 11:40:53 +01:00
parent 6fb22b9441
commit cf40dae93b

View File

@ -106,6 +106,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils;
import nodomain.freeyourgadget.gadgetbridge.util.EmojiConverter;
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
@ -134,6 +135,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
private boolean realtimeStep = false;
private int realtimeHRMInterval = 30*60;
private final LimitedQueue/*Long*/ mNotificationReplyAction = new LimitedQueue(16);
/// Maximum amount of characters to store in receiveHistory
public static final int MAX_RECEIVE_HISTORY_CHARS = 100000;
// Local Intents - for app manager communication
@ -445,6 +448,13 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
deviceEvtNotificationControl.phoneNumber = json.getString("tel");
if (json.has("msg"))
deviceEvtNotificationControl.reply = json.getString("msg");
/* REPLY responses don't use the ID from the event (MUTE/etc seem to), but instead
* they use a handle that was provided in an action list on the onNotification.. event */
if (deviceEvtNotificationControl.event == GBDeviceEventNotificationControl.Event.REPLY) {
Long foundHandle = (Long)mNotificationReplyAction.lookup((int)deviceEvtNotificationControl.handle);
if (foundHandle!=null)
deviceEvtNotificationControl.handle = foundHandle;
}
evaluateGBDeviceEvent(deviceEvtNotificationControl);
} break;
case "act": {
@ -675,6 +685,11 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
@Override
public void onNotification(NotificationSpec notificationSpec) {
for (int i=0;i<notificationSpec.attachedActions.size();i++) {
NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
if (action.type==NotificationSpec.Action.TYPE_WEARABLE_REPLY)
mNotificationReplyAction.add(notificationSpec.getId(), new Long(((long)notificationSpec.getId()<<4) + i + 1)); // wow. This should be easier!
}
try {
JSONObject o = new JSONObject();
o.put("t", "notify");