mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Bangle.js: Fix message reply (and add .reply in notify if message supports reply)
NotificationListener now stores the handle ID in wearableAction.handle rather than hard-coding the calculation Should fix ZeppOS too which was copy&paste from Bangle.js
This commit is contained in:
parent
d68cb8c743
commit
665656ddc0
@ -433,9 +433,9 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
} else {
|
} else {
|
||||||
wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_SIMPLE;
|
wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_SIMPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationSpec.attachedActions.add(wearableAction);
|
notificationSpec.attachedActions.add(wearableAction);
|
||||||
mActionLookup.add((notificationSpec.getId() << 4) + notificationSpec.attachedActions.size(), act);
|
wearableAction.handle = (notificationSpec.getId() << 4) + notificationSpec.attachedActions.size();
|
||||||
|
mActionLookup.add((int)wearableAction.handle, act);
|
||||||
LOG.info("Found wearable action: {} - {} {}", notificationSpec.attachedActions.size(), act.getTitle(), sbn.getTag());
|
LOG.info("Found wearable action: {} - {} {}", notificationSpec.attachedActions.size(), act.getTitle(), sbn.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1276,11 +1276,14 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotification(NotificationSpec notificationSpec) {
|
public void onNotification(NotificationSpec notificationSpec) {
|
||||||
|
boolean canReply = false;
|
||||||
if (notificationSpec.attachedActions!=null)
|
if (notificationSpec.attachedActions!=null)
|
||||||
for (int i=0;i<notificationSpec.attachedActions.size();i++) {
|
for (int i=0;i<notificationSpec.attachedActions.size();i++) {
|
||||||
NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
|
NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
|
||||||
if (action.type==NotificationSpec.Action.TYPE_WEARABLE_REPLY)
|
if (action.type==NotificationSpec.Action.TYPE_WEARABLE_REPLY) {
|
||||||
mNotificationReplyAction.add(notificationSpec.getId(), ((long) notificationSpec.getId() << 4) + i + 1);
|
mNotificationReplyAction.add(notificationSpec.getId(), action.handle);
|
||||||
|
canReply = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// sourceName isn't set for SMS messages
|
// sourceName isn't set for SMS messages
|
||||||
String src = notificationSpec.sourceName;
|
String src = notificationSpec.sourceName;
|
||||||
@ -1297,6 +1300,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
o.put("body", renderUnicodeAsImage(cropToLength(notificationSpec.body, 400)));
|
o.put("body", renderUnicodeAsImage(cropToLength(notificationSpec.body, 400)));
|
||||||
o.put("sender", renderUnicodeAsImage(cropToLength(notificationSpec.sender,40)));
|
o.put("sender", renderUnicodeAsImage(cropToLength(notificationSpec.sender,40)));
|
||||||
o.put("tel", notificationSpec.phoneNumber);
|
o.put("tel", notificationSpec.phoneNumber);
|
||||||
|
if (canReply) o.put("reply", true);
|
||||||
uartTxJSON("onNotification", o);
|
uartTxJSON("onNotification", o);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
LOG.info("JSONException: " + e.getLocalizedMessage());
|
LOG.info("JSONException: " + e.getLocalizedMessage());
|
||||||
|
@ -272,7 +272,7 @@ public class ZeppOsNotificationService extends AbstractZeppOsService {
|
|||||||
case NotificationSpec.Action.TYPE_WEARABLE_REPLY:
|
case NotificationSpec.Action.TYPE_WEARABLE_REPLY:
|
||||||
case NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR:
|
case NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR:
|
||||||
hasReply = true;
|
hasReply = true;
|
||||||
mNotificationReplyAction.add(notificationSpec.getId(), ((long) notificationSpec.getId() << 4) + i + 1);
|
mNotificationReplyAction.add(notificationSpec.getId(), action.handle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user