Add swipe right to reply and PR fixes
parent
dc8a475474
commit
81fdfc9f09
|
|
@ -24,7 +24,8 @@ require("messages").pushMessage({"t":"add","id":"call","src":"Phone","title":"Bo
|
||||||
var Layout = require("Layout");
|
var Layout = require("Layout");
|
||||||
var layout; // global var containing the layout for the currently displayed message
|
var layout; // global var containing the layout for the currently displayed message
|
||||||
var settings = require('Storage').readJSON("messages.settings.json", true) || {};
|
var settings = require('Storage').readJSON("messages.settings.json", true) || {};
|
||||||
var reply = require("reply");
|
var reply;
|
||||||
|
try { reply = require("reply"); } catch (e) {}
|
||||||
var fontSmall = "6x8";
|
var fontSmall = "6x8";
|
||||||
var fontMedium = g.getFonts().includes("6x15")?"6x15":"6x8:2";
|
var fontMedium = g.getFonts().includes("6x15")?"6x15":"6x8:2";
|
||||||
var fontBig = g.getFonts().includes("12x20")?"12x20":"6x8:2";
|
var fontBig = g.getFonts().includes("12x20")?"12x20":"6x8:2";
|
||||||
|
|
@ -269,7 +270,10 @@ function showMessageSettings(msg) {
|
||||||
/*LANG*/"View Message" : () => {
|
/*LANG*/"View Message" : () => {
|
||||||
showMessageScroller(msg);
|
showMessageScroller(msg);
|
||||||
},
|
},
|
||||||
/*LANG*/"Reply": () => {
|
};
|
||||||
|
|
||||||
|
if (msg.reply && reply) {
|
||||||
|
menu[/*LANG*/"Reply"] = () => {
|
||||||
replying = true;
|
replying = true;
|
||||||
reply.reply({msg: msg})
|
reply.reply({msg: msg})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
|
@ -281,14 +285,15 @@ function showMessageSettings(msg) {
|
||||||
replying = false;
|
replying = false;
|
||||||
showMessage(msg.id);
|
showMessage(msg.id);
|
||||||
});
|
});
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
menu = Object.assign(menu, {
|
||||||
/*LANG*/"Delete" : () => {
|
/*LANG*/"Delete" : () => {
|
||||||
MESSAGES = MESSAGES.filter(m=>m.id!=msg.id);
|
MESSAGES = MESSAGES.filter(m=>m.id!=msg.id);
|
||||||
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0});
|
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0});
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
if (!msg.reply || !reply) delete menu[/*LANG*/"Reply"];
|
|
||||||
|
|
||||||
if (Bangle.messageIgnore && msg.src)
|
if (Bangle.messageIgnore && msg.src)
|
||||||
menu[/*LANG*/"Ignore"] = () => {
|
menu[/*LANG*/"Ignore"] = () => {
|
||||||
|
|
@ -393,15 +398,32 @@ function showMessage(msgid, persist) {
|
||||||
}; footer.push({type:"img",src:atob("PhAB4A8AAAAAAAPAfAMAAAAAD4PwHAAAAAA/H4DwAAAAAH78B8AAAAAA/+A/AAAAAAH/Af//////w/gP//////8P4D///////H/Af//////z/4D8AAAAAB+/AfAAAAAA/H4DwAAAAAPg/AcAAAAADwHwDAAAAAA4A8AAAAAAAA=="),col:"#f00",cb:negHandler});
|
}; footer.push({type:"img",src:atob("PhAB4A8AAAAAAAPAfAMAAAAAD4PwHAAAAAA/H4DwAAAAAH78B8AAAAAA/+A/AAAAAAH/Af//////w/gP//////8P4D///////H/Af//////z/4D8AAAAAB+/AfAAAAAA/H4DwAAAAAPg/AcAAAAADwHwDAAAAAA4A8AAAAAAAA=="),col:"#f00",cb:negHandler});
|
||||||
}
|
}
|
||||||
footer.push({fillx:1}); // push images to left/right
|
footer.push({fillx:1}); // push images to left/right
|
||||||
if (msg.positive) {
|
if (msg.reply && reply) {
|
||||||
|
posHandler = ()=>{
|
||||||
|
replying = true;
|
||||||
|
msg.new = false;
|
||||||
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
|
reply.reply({msg: msg})
|
||||||
|
.then(result => {
|
||||||
|
Bluetooth.println(JSON.stringify(result));
|
||||||
|
replying = false;
|
||||||
|
layout.render();
|
||||||
|
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
replying = false;
|
||||||
|
layout.render();
|
||||||
|
showMessage(msg.id);
|
||||||
|
});
|
||||||
|
}; footer.push({type:"img",src:atob("QRABAAAAAAAH//+AAAAABgP//8AAAAADgf//4AAAAAHg4ABwAAAAAPh8APgAAAAAfj+B////////geHv///////hf+f///////GPw///////8cGBwAAAAAPx/gDgAAAAAfD/gHAAAAAA8DngOAAAAABwDHP8AAAAADACGf4AAAAAAAAM/w=="),col:"#0f0", cb:posHandler});
|
||||||
|
}
|
||||||
|
else if (msg.positive) {
|
||||||
posHandler = ()=>{
|
posHandler = ()=>{
|
||||||
msg.new = false;
|
msg.new = false;
|
||||||
cancelReloadTimeout(); // don't auto-reload to clock now
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
Bangle.messageResponse(msg,true);
|
Bangle.messageResponse(msg,true);
|
||||||
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic});
|
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic});
|
||||||
};
|
}; footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler});
|
||||||
footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = new Layout({ type:"v", c: [
|
layout = new Layout({ type:"v", c: [
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: New Library!
|
0.01: New Library!
|
||||||
|
0.02: Minor bug fixes
|
||||||
|
|
@ -6,7 +6,12 @@ exports.reply = function (options) {
|
||||||
keyboard = null;
|
keyboard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructReply(msg, replyText, resolve) {
|
function constructReply(msg, replyText, resolve, reject) {
|
||||||
|
if (!replyText) {
|
||||||
|
reject("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var responseMessage = {msg: replyText};
|
var responseMessage = {msg: replyText};
|
||||||
if (msg.id) {
|
if (msg.id) {
|
||||||
responseMessage = { t: "notify", id: msg.id, n: "REPLY", msg: replyText };
|
responseMessage = { t: "notify", id: msg.id, n: "REPLY", msg: replyText };
|
||||||
|
|
@ -29,7 +34,10 @@ exports.reply = function (options) {
|
||||||
}, // options
|
}, // options
|
||||||
/*LANG*/ "Compose": function () {
|
/*LANG*/ "Compose": function () {
|
||||||
keyboard.input().then((result) => {
|
keyboard.input().then((result) => {
|
||||||
constructReply(options.msg ?? {}, result, resolve);
|
if (result)
|
||||||
|
constructReply(options.msg ?? {}, result, resolve, reject);
|
||||||
|
else
|
||||||
|
E.showMenu(menu);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -40,7 +48,7 @@ exports.reply = function (options) {
|
||||||
) || [];
|
) || [];
|
||||||
replies.forEach((reply) => {
|
replies.forEach((reply) => {
|
||||||
menu = Object.defineProperty(menu, reply.text, {
|
menu = Object.defineProperty(menu, reply.text, {
|
||||||
value: () => constructReply(options.msg ?? {}, reply.text, resolve),
|
value: () => constructReply(options.msg ?? {}, reply.text, resolve, reject),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!keyboard) delete menu[/*LANG*/ "Compose"];
|
if (!keyboard) delete menu[/*LANG*/ "Compose"];
|
||||||
|
|
@ -60,10 +68,11 @@ exports.reply = function (options) {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
keyboard.input().then((result) => {
|
keyboard.input().then((result) => {
|
||||||
constructReply(options.msg.id, result, resolve);
|
constructReply(options.msg, result, resolve, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else{
|
||||||
|
E.showMenu(menu);
|
||||||
}
|
}
|
||||||
E.showMenu(menu);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{ "id": "reply",
|
{ "id": "reply",
|
||||||
"name": "Reply Library",
|
"name": "Reply Library",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue