gbridge 0.20: Reduce memory usage
parent
0e2f33d656
commit
b5c7ded4b5
|
|
@ -139,7 +139,7 @@
|
|||
{ "id": "gbridge",
|
||||
"name": "Gadgetbridge",
|
||||
"icon": "app.png",
|
||||
"version":"0.19",
|
||||
"version":"0.20",
|
||||
"description": "The default notification handler for Gadgetbridge notifications from Android",
|
||||
"tags": "tool,system,android,widget",
|
||||
"readme": "README.md",
|
||||
|
|
|
|||
|
|
@ -19,3 +19,4 @@
|
|||
0.17: Modified music notification for updated 'notify' library
|
||||
0.18: Added reporting of step count and HRM (new Gadgetbridges can now log this)
|
||||
0.19: Support for call incoming/start/end
|
||||
0.20: Reduce memory usage
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
// Music handling
|
||||
const state = {
|
||||
music: "stop",
|
||||
|
||||
musicInfo: {
|
||||
artist: "",
|
||||
album: "",
|
||||
track: ""
|
||||
},
|
||||
|
||||
scrollPos: 0
|
||||
};
|
||||
// activity reporting
|
||||
|
|
@ -43,14 +41,6 @@
|
|||
return event;
|
||||
}
|
||||
}
|
||||
function handleNotificationEvent(event) {
|
||||
if (event.t === "notify") {
|
||||
require("notify").show(prettifyNotificationEvent(event));
|
||||
Bangle.buzz();
|
||||
} else { // notify-
|
||||
require("notify").hide(event);
|
||||
}
|
||||
}
|
||||
|
||||
function updateMusic(options){
|
||||
if (state.music === "play") {
|
||||
|
|
@ -117,49 +107,6 @@
|
|||
require("notify").hide("music");
|
||||
}
|
||||
}
|
||||
function handleMusicStateUpdate(event) {
|
||||
if (state.music !== event.state) {
|
||||
state.music = event.state
|
||||
updateMusic({on: true});
|
||||
}
|
||||
}
|
||||
function handleMusicInfoUpdate(event) {
|
||||
state.musicInfo = event;
|
||||
updateMusic({on: false});
|
||||
}
|
||||
|
||||
function handleCallEvent(event) {
|
||||
var callIcon = require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="));
|
||||
if (event.cmd === "incoming") {
|
||||
require("notify").show({
|
||||
size: 55, title: event.name, id: "call",
|
||||
body: event.number, icon:callIcon});
|
||||
Bangle.buzz();
|
||||
} else if (event.cmd === "start") {
|
||||
require("notify").show({
|
||||
size: 55, title: event.name, id: "call", bgColor : "#008000", titleBgColor : "#00C000",
|
||||
body: "In progress: "+event.number, icon:callIcon});
|
||||
} else if (event.cmd === "end") {
|
||||
require("notify").show({
|
||||
size: 55, title: event.name, id: "call", bgColor : "#800000", titleBgColor : "#C00000",
|
||||
body: "Ended: "+event.number, icon:callIcon});
|
||||
setTimeout(function() {
|
||||
require("notify").hide({ id: "call" });
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function handleFindEvent(event) {
|
||||
if (state.find) {
|
||||
clearInterval(state.find);
|
||||
delete state.find;
|
||||
}
|
||||
if (event.n)
|
||||
state.find = setInterval(_=>{
|
||||
Bangle.buzz();
|
||||
setTimeout(_=>Bangle.beep(), 1000);
|
||||
},2000);
|
||||
}
|
||||
|
||||
function handleActivityEvent(event) {
|
||||
var s = settings();
|
||||
|
|
@ -205,19 +152,52 @@
|
|||
switch (event.t) {
|
||||
case "notify":
|
||||
case "notify-":
|
||||
handleNotificationEvent(event);
|
||||
if (event.t === "notify") {
|
||||
require("notify").show(prettifyNotificationEvent(event));
|
||||
Bangle.buzz();
|
||||
} else { // notify-
|
||||
require("notify").hide(event);
|
||||
}
|
||||
break;
|
||||
case "musicinfo":
|
||||
handleMusicInfoUpdate(event);
|
||||
state.musicInfo = event;
|
||||
updateMusic({on: false});
|
||||
break;
|
||||
case "musicstate":
|
||||
handleMusicStateUpdate(event);
|
||||
if (state.music !== event.state) {
|
||||
state.music = event.state
|
||||
updateMusic({on: true});
|
||||
}
|
||||
break;
|
||||
case "call":
|
||||
handleCallEvent(event);
|
||||
var note = { size: 55, title: event.name, id: "call",
|
||||
body: event.number, icon:require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="))}
|
||||
if (event.cmd === "incoming") {
|
||||
require("notify").show(note);
|
||||
Bangle.buzz();
|
||||
} else if (event.cmd === "start") {
|
||||
require("notify").show(Object.assign(note, {
|
||||
bgColor : "#008000", titleBgColor : "#00C000",
|
||||
body: "In progress: "+event.number}));
|
||||
} else if (event.cmd === "end") {
|
||||
require("notify").show(Object.assign(note, {
|
||||
bgColor : "#800000", titleBgColor : "#C00000",
|
||||
body: "Ended: "+event.number}));
|
||||
setTimeout(function() {
|
||||
require("notify").hide({ id: "call" });
|
||||
}, 2000);
|
||||
}
|
||||
break;
|
||||
case "find":
|
||||
handleFindEvent(event);
|
||||
if (state.find) {
|
||||
clearInterval(state.find);
|
||||
delete state.find;
|
||||
}
|
||||
if (event.n)
|
||||
state.find = setInterval(_=>{
|
||||
Bangle.buzz();
|
||||
setTimeout(_=>Bangle.beep(), 1000);
|
||||
},2000);
|
||||
break;
|
||||
case "act":
|
||||
handleActivityEvent(event);
|
||||
|
|
|
|||
Loading…
Reference in New Issue