android: Fix SMS bug

pull/1882/head
Lubomir 2022-05-24 22:08:43 +10:00 committed by Gordon Williams
parent 8e4063004c
commit cb890e6fc5
3 changed files with 14 additions and 2 deletions

View File

@ -8,3 +8,4 @@
0.07: Include charging state in battery updates to phone 0.07: Include charging state in battery updates to phone
0.08: Handling of alarms 0.08: Handling of alarms
0.09: Alarm vibration, repeat, and auto-snooze now handled by sched 0.09: Alarm vibration, repeat, and auto-snooze now handled by sched
0.10: Fix SMS bug

View File

@ -3,6 +3,7 @@
Bluetooth.println(""); Bluetooth.println("");
Bluetooth.println(JSON.stringify(message)); Bluetooth.println(JSON.stringify(message));
} }
var lastMsg;
var settings = require("Storage").readJSON("android.settings.json",1)||{}; var settings = require("Storage").readJSON("android.settings.json",1)||{};
//default alarm settings //default alarm settings
@ -18,7 +19,17 @@
/* TODO: Call handling, fitness */ /* TODO: Call handling, fitness */
var HANDLERS = { var HANDLERS = {
// {t:"notify",id:int, src,title,subject,body,sender,tel:string} add // {t:"notify",id:int, src,title,subject,body,sender,tel:string} add
"notify" : function() { Object.assign(event,{t:"add",positive:true, negative:true});require("messages").pushMessage(event); }, "notify" : function() {
Object.assign(event,{t:"add",positive:true, negative:true});
// Detect a weird GadgetBridge bug and fix it
// For some reason SMS messages send two GB notifications, with different sets of info
if (lastMsg && event.body == lastMsg.body && lastMsg.src == undefined && event.src == "Messages") {
// Mutate the other message
event.id = lastMsg.id;
}
lastMsg = event;
require("messages").pushMessage(event);
},
// {t:"notify~",id:int, title:string} // modified // {t:"notify~",id:int, title:string} // modified
"notify~" : function() { event.t="modify";require("messages").pushMessage(event); }, "notify~" : function() { event.t="modify";require("messages").pushMessage(event); },
// {t:"notify-",id:int} // remove // {t:"notify-",id:int} // remove

View File

@ -2,7 +2,7 @@
"id": "android", "id": "android",
"name": "Android Integration", "name": "Android Integration",
"shortName": "Android", "shortName": "Android",
"version": "0.09", "version": "0.10",
"description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.", "description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.",
"icon": "app.png", "icon": "app.png",
"tags": "tool,system,messages,notifications,gadgetbridge", "tags": "tool,system,messages,notifications,gadgetbridge",