Android Remove messages on disconnect, Fix music control (ref #909)
parent
31f2809341
commit
4719fada28
10
apps.json
10
apps.json
|
|
@ -32,7 +32,7 @@
|
||||||
{
|
{
|
||||||
"id": "messages",
|
"id": "messages",
|
||||||
"name": "Messages",
|
"name": "Messages",
|
||||||
"version": "0.03",
|
"version": "0.04",
|
||||||
"description": "App to display notifications from iOS and Gadgetbridge",
|
"description": "App to display notifications from iOS and Gadgetbridge",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "app",
|
"type": "app",
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
{
|
{
|
||||||
"id": "android",
|
"id": "android",
|
||||||
"name": "Android Integration",
|
"name": "Android Integration",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "(BETA) App to display notifications from Gadgetbridge on Android. This will eventually replace the Gadgetbridge widget.",
|
"description": "(BETA) App to display notifications from Gadgetbridge on Android. This will eventually replace the Gadgetbridge widget.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,system,messages,notifications",
|
"tags": "tool,system,messages,notifications",
|
||||||
|
|
@ -61,12 +61,12 @@
|
||||||
{"name":"android.img","url":"app-icon.js","evaluate":true},
|
{"name":"android.img","url":"app-icon.js","evaluate":true},
|
||||||
{"name":"android.boot.js","url":"boot.js"}
|
{"name":"android.boot.js","url":"boot.js"}
|
||||||
],
|
],
|
||||||
"sortorder": -9
|
"sortorder": -8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ios",
|
"id": "ios",
|
||||||
"name": "iOS Integration",
|
"name": "iOS Integration",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "(BETA) App to display notifications from iOS devices",
|
"description": "(BETA) App to display notifications from iOS devices",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,system,ios,apple,messages,notifications",
|
"tags": "tool,system,ios,apple,messages,notifications",
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
{"name":"ios.img","url":"app-icon.js","evaluate":true},
|
{"name":"ios.img","url":"app-icon.js","evaluate":true},
|
||||||
{"name":"ios.boot.js","url":"boot.js"}
|
{"name":"ios.boot.js","url":"boot.js"}
|
||||||
],
|
],
|
||||||
"sortorder": -9
|
"sortorder": -8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "health",
|
"id": "health",
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
|
0.02: Remove messages on disconnect
|
||||||
|
Fix music control
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,13 @@
|
||||||
// {t:"musicinfo", artist,album,track,dur,c(track count),n(track num}
|
// {t:"musicinfo", artist,album,track,dur,c(track count),n(track num}
|
||||||
"musicinfo" : function() {
|
"musicinfo" : function() {
|
||||||
require("messages").pushMessage(Object.assign(event, {t:"modify",id:"music",title:"Music"}));
|
require("messages").pushMessage(Object.assign(event, {t:"modify",id:"music",title:"Music"}));
|
||||||
}
|
},
|
||||||
|
// {"t":"call","cmd":"incoming/end","name":"Bob","number":"12421312"})
|
||||||
|
"notify" : function() {
|
||||||
|
event.t=t.cmd=="incoming"?"add":"remove";
|
||||||
|
event.id="call";
|
||||||
|
require("messages").pushMessage(event);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
var h = HANDLERS[event.t];
|
var h = HANDLERS[event.t];
|
||||||
if (h) h(); else console.log("GB Unknown",event);
|
if (h) h(); else console.log("GB Unknown",event);
|
||||||
|
|
@ -42,6 +48,7 @@
|
||||||
// Battery monitor
|
// Battery monitor
|
||||||
function sendBattery() { gbSend({ t: "status", bat: E.getBattery() }); }
|
function sendBattery() { gbSend({ t: "status", bat: E.getBattery() }); }
|
||||||
NRF.on("connect", () => setTimeout(sendBattery, 2000));
|
NRF.on("connect", () => setTimeout(sendBattery, 2000));
|
||||||
|
NRF.on("disconnect", () => require("messages").clearAll()); // remove all messages on disconnect
|
||||||
setInterval(sendBattery, 10*60*1000);
|
setInterval(sendBattery, 10*60*1000);
|
||||||
// Health tracking
|
// Health tracking
|
||||||
Bangle.on('health', health=>{
|
Bangle.on('health', health=>{
|
||||||
|
|
@ -50,6 +57,6 @@
|
||||||
// Music control
|
// Music control
|
||||||
Bangle.musicControl = cmd => {
|
Bangle.musicControl = cmd => {
|
||||||
// play/pause/next/previous/volumeup/volumedown
|
// play/pause/next/previous/volumeup/volumedown
|
||||||
gbSend({ t: "music", m:cmd });
|
gbSend({ t: "music", n:cmd });
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
require("heatshrink").decompress(atob("mEwghC/AEkIxAABwUiAAwKBC6+AC6ERiIXDGBAXPGA8JzIAByQXKGA4XUA4eDmYAGJwQXVxEizAXPIgIXDwWZC6uIxIwCC6eIGAQX/C9i/FC5mCCw0yC5wAMC/4Xnx//ABf4C/Xzdw8zn4XkL/5f/L+oUDI6YX3AB4XeAH4AdA=="))
|
require("heatshrink").decompress(atob("mEw4cA///7c0AYMXlm3gf42s1yvb5xT/ABdJkmStu27YCCtMkCKOACJdm7YRCyARQyQRLBwIRDoARTgVLtu3K4tJl4RQkvpCJdbtwRBkm5CKGZCKGTCKGSsgR/R4gRHpIMBCInaCJIIBARAR/CJtPB5FLCI1KEhMSCLN//4AE/QRbI/5H/CI4PCGpwRXp4RIpZFDCIQiJAQIRWAH4AGA"))
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
|
0.02: Remove messages on disconnect
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,8 @@ E.on('AMS',a=>{
|
||||||
Bangle.musicControl = cmd => {
|
Bangle.musicControl = cmd => {
|
||||||
// play, pause, playpause, next, prev, volup, voldown, repeat, shuffle, skipforward, skipback, like, dislike, bookmark
|
// play, pause, playpause, next, prev, volup, voldown, repeat, shuffle, skipforward, skipback, like, dislike, bookmark
|
||||||
NRF.amsCommand(cmd);
|
NRF.amsCommand(cmd);
|
||||||
}
|
};
|
||||||
|
NRF.on("disconnect", () => require("messages").clearAll()); // remove all messages on disconnect
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// For testing...
|
// For testing...
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Add 'messages' library
|
0.02: Add 'messages' library
|
||||||
0.03: Fixes for Bangle.js 1
|
0.03: Fixes for Bangle.js 1
|
||||||
|
0.04: Add require("messages").clearAll()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
{"t":"add","id":1575479849,"src":"Hangouts","title":"A Name","body":"message contents"}
|
{"t":"add","id":1575479849,"src":"Hangouts","title":"A Name","body":"message contents"}
|
||||||
// maps
|
// maps
|
||||||
{"t":"add","id":1,"src":"Maps","title":"0 yd - High St","body":"Campton - 11:48 ETA","img":"GhqBAAAMAAAHgAAD8AAB/gAA/8AAf/gAP/8AH//gD/98B//Pg/4B8f8Afv+PP//n3/f5//j+f/wfn/4D5/8Aef+AD//AAf/gAD/wAAf4AAD8AAAeAAADAAA="}
|
{"t":"add","id":1,"src":"Maps","title":"0 yd - High St","body":"Campton - 11:48 ETA","img":"GhqBAAAMAAAHgAAD8AAB/gAA/8AAf/gAP/8AH//gD/98B//Pg/4B8f8Afv+PP//n3/f5//j+f/wfn/4D5/8Aef+AD//AAf/gAD/wAAf4AAD8AAAeAAADAAA="}
|
||||||
|
// call
|
||||||
|
{"t:"add","id:"call","name":"Bob","number":"12421312"}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Layout = require("Layout");
|
var Layout = require("Layout");
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,21 @@ exports.pushMessage = function(event) {
|
||||||
// if we're in a clock or it's important, go straight to messages app
|
// if we're in a clock or it's important, go straight to messages app
|
||||||
if (Bangle.CLOCK || event.important) return load("messages.app.js");
|
if (Bangle.CLOCK || event.important) return load("messages.app.js");
|
||||||
if (!global.WIDGETS || !WIDGETS.messages) return Bangle.buzz(); // no widgets - just buzz to let someone know
|
if (!global.WIDGETS || !WIDGETS.messages) return Bangle.buzz(); // no widgets - just buzz to let someone know
|
||||||
WIDGETS.messages.newMessage();
|
WIDGETS.messages.show();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
exports.clearAll = function(event) {
|
||||||
|
var messages, inApp = "undefined"!=typeof MESSAGES;
|
||||||
|
if (inApp) {
|
||||||
|
MESSAGES = [];
|
||||||
|
messages = MESSAGES; // we're in an app that has already loaded messages
|
||||||
|
} else // no app - empty messages
|
||||||
|
messages = [];
|
||||||
|
// Save all messages
|
||||||
|
require("Storage").writeJSON("messages.json",messages);
|
||||||
|
// update app if in app
|
||||||
|
if (inApp) return onMessagesModified();
|
||||||
|
// if we have a widget, update it
|
||||||
|
if (global.WIDGETS && WIDGETS.messages)
|
||||||
|
WIDGETS.messages.hide();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,15 @@ WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
||||||
Bangle.buzz(); // buzz every 4 seconds
|
Bangle.buzz(); // buzz every 4 seconds
|
||||||
}
|
}
|
||||||
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
||||||
},newMessage:function() {
|
},show:function() {
|
||||||
WIDGETS["messages"].t=Date.now(); // first time
|
WIDGETS["messages"].t=Date.now(); // first time
|
||||||
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
||||||
if (WIDGETS["messages"].c!==undefined) return; // already called
|
|
||||||
WIDGETS["messages"].width=64;
|
WIDGETS["messages"].width=64;
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
Bangle.setLCDPower(1);// turns screen on
|
Bangle.setLCDPower(1);// turns screen on
|
||||||
|
},hide:function() {
|
||||||
|
delete WIDGETS["messages"].t;
|
||||||
|
delete WIDGETS["messages"].l;
|
||||||
|
WIDGETS["messages"].width=0;
|
||||||
|
Bangle.drawWidgets();
|
||||||
}};
|
}};
|
||||||
|
|
|
||||||
2
core
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit 905adb6ce4ae002e943a14d1724744e0c1326277
|
Subproject commit 996299a285c95136ad0049febb5399ee837c42d3
|
||||||
Loading…
Reference in New Issue