Support Gadgetbridge canned responses

pull/3556/head
Brian Whelan 2024-09-03 22:57:35 +01:00
parent 48d077e2e4
commit 919e7243b7
6 changed files with 19 additions and 5 deletions

View File

@ -37,3 +37,4 @@
0.35: Implement API to enable/disable acceleration data tracking. 0.35: Implement API to enable/disable acceleration data tracking.
0.36: Move from wrapper function to {} and let - faster execution at boot 0.36: Move from wrapper function to {} and let - faster execution at boot
Allow `calendar-` to take an array of items to remove Allow `calendar-` to take an array of items to remove
0.37: Support Gadgetbridge canned responses

View File

@ -67,6 +67,9 @@
title:event.name||/*LANG*/"Call", body:/*LANG*/"Incoming call\n"+event.number}); title:event.name||/*LANG*/"Call", body:/*LANG*/"Incoming call\n"+event.number});
require("messages").pushMessage(event); require("messages").pushMessage(event);
}, },
"canned_responses_sync" : function() {
require("Storage").writeJSON("replies.json", event.d);
},
// {"t":"alarm", "d":[{h:int,m:int,rep:int},... } // {"t":"alarm", "d":[{h:int,m:int,rep:int},... }
"alarm" : function() { "alarm" : function() {
//wipe existing GB alarms //wipe existing GB alarms

View File

@ -2,7 +2,7 @@
"id": "android", "id": "android",
"name": "Android Integration", "name": "Android Integration",
"shortName": "Android", "shortName": "Android",
"version": "0.36", "version": "0.37",
"description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.", "description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.",
"icon": "app.png", "icon": "app.png",
"tags": "tool,system,messages,notifications,gadgetbridge", "tags": "tool,system,messages,notifications,gadgetbridge",

View File

@ -1,2 +1,3 @@
0.01: New Library! 0.01: New Library!
0.02: Minor bug fixes 0.02: Minor bug fixes
0.03: Support Gadgetbridge canned responses

View File

@ -46,11 +46,20 @@ exports.reply = function (options) {
options.fileOverride || "replies.json", options.fileOverride || "replies.json",
true true
) || []; ) || [];
replies.forEach((reply) => { replies.forEach((reply) => {
menu = Object.defineProperty(menu, reply.text, { var displayString = reply.disp ?? reply.text;
var truncatedDisplayString = g.wrapString(displayString, 120);
// Generally handles truncating nicely, but falls down in long runs of emoji since they count as one image
if (truncatedDisplayString.length > 1) {
truncatedDisplayString = truncatedDisplayString.slice(0,1);
truncatedDisplayString[truncatedDisplayString.length-1] += "...";
}
menu = Object.defineProperty(menu, truncatedDisplayString, {
value: () => constructReply(options.msg ?? {}, reply.text, resolve, reject), value: () => constructReply(options.msg ?? {}, reply.text, resolve, reject),
}); });
}); });
if (!keyboard) delete menu[/*LANG*/ "Compose"]; if (!keyboard) delete menu[/*LANG*/ "Compose"];
if (replies.length == 0) { if (replies.length == 0) {

View File

@ -1,6 +1,6 @@
{ "id": "reply", { "id": "reply",
"name": "Reply Library", "name": "Reply Library",
"version": "0.02", "version": "0.03",
"description": "A library for replying to text messages via predefined responses or keyboard", "description": "A library for replying to text messages via predefined responses or keyboard",
"icon": "app.png", "icon": "app.png",
"type": "module", "type": "module",