parent
8ca9a89dd0
commit
1ca96bca90
|
|
@ -6,3 +6,4 @@
|
|||
removed lib no longer used
|
||||
1.3: icon changed
|
||||
1.4: new management of events implemented; removed code no longer used (from now the music will be managed by the Messagesgui app)
|
||||
1.5: Fix graphic bug; View via popup while there are other open apps
|
||||
|
|
@ -493,7 +493,7 @@ let main = function(){
|
|||
Bangle.on('tap', doubleTapUnlock);
|
||||
Bangle.on('touch', toushScroll);
|
||||
|
||||
//quando apro quest'app, do per scontato che c'è un messaggio da leggere posto in un file particolare ( NewMessage.json )
|
||||
//quando apro quest'app, do per scontato che c'è un messaggio da leggere posto in un file particolare ( messages_light.NewEvent.json )
|
||||
let eventToShow = require('Storage').readJSON(settings.NewEventFileName, true);
|
||||
require("Storage").erase(settings.NewEventFileName)
|
||||
if( eventToShow!==undefined)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,25 @@
|
|||
|
||||
let overlayTimeout=undefined;
|
||||
exports.listener = function(type, event) {
|
||||
|
||||
/*
|
||||
//salva gli eventi che arrivano su file
|
||||
events=require("Storage").readJSON("events_log",true) || [];
|
||||
events.push ( event)
|
||||
require("Storage").writeJSON("events_log",events);*/
|
||||
|
||||
//salva gli eventi che arrivano su file
|
||||
/* events=require("Storage").readJSON("events_log",true) || [];
|
||||
events.push ( event)
|
||||
require("Storage").writeJSON("events_log",events);
|
||||
*/
|
||||
//if (event.handled) return; // already handled/app open
|
||||
if( type=="music" || event.id=="music") return; //lo lascio gestire a qualcun altro
|
||||
if( type=="clearAll" || type=="music" || event.id=="music") return; //lo lascio gestire a qualcun altro
|
||||
|
||||
//se arrivo qua gestisco io
|
||||
//non mi preoccupo di salvare ( a meno di problemi a mantenere tanti messaggi in queue nella ram...)
|
||||
event.handled=true;
|
||||
|
||||
|
||||
if( Bangle.CLOCK || global.__FILE__ === undefined || global.__FILE__ === ".bootcde" || global.__FILE__.startsWith("messages_light."))
|
||||
{
|
||||
//se non ci sono app aperte ( clock oppure c'è messages_light)
|
||||
//continuo con la visualizzazione dell messaggio
|
||||
|
||||
let callApp;
|
||||
//se l'app non è aperta
|
||||
|
|
@ -38,6 +44,79 @@ exports.listener = function(type, event) {
|
|||
|
||||
callApp(event);
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
//TODO: BHOO!!!
|
||||
//vibro e basta?
|
||||
//faccio comparire un overlay veloce?
|
||||
//uso l'overlay sempre? ( gestione di tutti gli eventi smadonnosa... )
|
||||
//salvo lo stato dell'app attuale( NON SO COME ), lancio la mia app e alla chiusura torno allo stato precedente?
|
||||
|
||||
console.log(event);
|
||||
let ovr=undefined;
|
||||
let palette;
|
||||
let timeout;
|
||||
|
||||
if(event.id=="call" && event.t!="remove")
|
||||
{
|
||||
let count=3;
|
||||
let idInter= setInterval(()=>{
|
||||
if(--count<=0)
|
||||
clearInterval(idInter);
|
||||
|
||||
Bangle.buzz(100,1);
|
||||
},200);
|
||||
|
||||
ovr = Graphics.createArrayBuffer(136,136,2,{msb:true});
|
||||
ovr.setColor(1).fillRect({x:0,y:0,w:135,h:135,r:8});
|
||||
ovr.setColor(2).setFont("Vector:30").setFontAlign(0,0).drawString("Call",68,20);
|
||||
var lines=ovr.wrapString(event.title,136);
|
||||
for(let i=0;i< lines.length;i++)
|
||||
ovr.setColor(2).setFont("Vector:20").setFontAlign(0,0).drawString(lines[i],68,50+i*15);
|
||||
|
||||
palette=[0,g.toColor("#141"),g.toColor("#fff"),g.toColor("#FFF")];
|
||||
timeout=4000;
|
||||
}
|
||||
else if(event.t=="add" || event.t=="modify")
|
||||
{
|
||||
Bangle.buzz();
|
||||
ovr = Graphics.createArrayBuffer(136,136,2,{msb:true});
|
||||
ovr.setColor(1).fillRect({x:0,y:0,w:135,h:135,r:8});
|
||||
ovr.setColor(2).setFont("Vector:20").setFontAlign(0,0).drawString(event.src,68,15);
|
||||
ovr.setColor(2).setFont("Vector:15").setFontAlign(0,0).drawString(event.title,68,35);
|
||||
var lines=ovr.wrapString(event.body,136);
|
||||
for(let i=0;i< lines.length;i++)
|
||||
ovr.setColor(2).setFont("Vector:15").setFontAlign(0,0).drawString(lines[i],68,60+i*15);
|
||||
|
||||
|
||||
palette=[0,g.toColor("#09c"),g.toColor("#fff"),g.toColor("#FFF")];
|
||||
timeout=5000;
|
||||
}
|
||||
|
||||
|
||||
if(ovr===undefined)
|
||||
return;
|
||||
|
||||
|
||||
Bangle.setLCDPower(true);
|
||||
|
||||
Bangle.setLCDOverlay({
|
||||
width:ovr.getWidth(), height:ovr.getHeight(),
|
||||
bpp:2, transparent:0,
|
||||
palette:new Uint16Array(palette),
|
||||
buffer:ovr.buffer
|
||||
},20,20);
|
||||
|
||||
Bangle.setLCDPower(true);
|
||||
|
||||
if(overlayTimeout) clearTimeout(overlayTimeout);
|
||||
overlayTimeout=setTimeout(()=>{
|
||||
Bangle.setLCDOverlay();
|
||||
overlayTimeout=undefined;
|
||||
},timeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "messages_light",
|
||||
"name": "Messages Light",
|
||||
"version": "1.4",
|
||||
"version": "1.5",
|
||||
"description": "A light implementation of messages App (display notifications from iOS and Gadgetbridge/Android)",
|
||||
"icon": "app.png",
|
||||
"type": "app",
|
||||
|
|
|
|||
Loading…
Reference in New Issue