Skip to content

Commit

Permalink
Support Gadgetbridge canned responses
Browse files Browse the repository at this point in the history
  • Loading branch information
WhelanB committed Sep 3, 2024
1 parent 48d077e commit 919e724
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/android/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
0.34: Implement API for activity tracks fetching (Recorder app logs).
0.35: Implement API to enable/disable acceleration data tracking.
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
3 changes: 3 additions & 0 deletions apps/android/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
title:event.name||/*LANG*/"Call", body:/*LANG*/"Incoming call\n"+event.number});
require("messages").pushMessage(event);
},
"canned_responses_sync" : function() {
require("Storage").writeJSON("replies.json", event.d);
},
// {"t":"alarm", "d":[{h:int,m:int,rep:int},... }
"alarm" : function() {
//wipe existing GB alarms
Expand Down
2 changes: 1 addition & 1 deletion apps/android/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "android",
"name": "Android Integration",
"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.",
"icon": "app.png",
"tags": "tool,system,messages,notifications,gadgetbridge",
Expand Down
3 changes: 2 additions & 1 deletion apps/reply/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.01: New Library!
0.02: Minor bug fixes
0.02: Minor bug fixes
0.03: Support Gadgetbridge canned responses
11 changes: 10 additions & 1 deletion apps/reply/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,20 @@ exports.reply = function (options) {
options.fileOverride || "replies.json",
true
) || [];

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),
});
});

if (!keyboard) delete menu[/*LANG*/ "Compose"];

if (replies.length == 0) {
Expand Down
2 changes: 1 addition & 1 deletion apps/reply/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "id": "reply",
"name": "Reply Library",
"version": "0.02",
"version": "0.03",
"description": "A library for replying to text messages via predefined responses or keyboard",
"icon": "app.png",
"type": "module",
Expand Down

0 comments on commit 919e724

Please sign in to comment.