mirror of https://github.com/espruino/BangleApps
gbridge: Modified music notification for updated 'notify' library
parent
48bf67dfb1
commit
6406788165
|
@ -121,7 +121,7 @@
|
|||
{ "id": "gbridge",
|
||||
"name": "Gadgetbridge",
|
||||
"icon": "app.png",
|
||||
"version":"0.16",
|
||||
"version":"0.17",
|
||||
"description": "The default notification handler for Gadgetbridge notifications from Android",
|
||||
"tags": "tool,system,android,widget",
|
||||
"type":"widget",
|
||||
|
|
|
@ -15,4 +15,5 @@
|
|||
0.14: Added 'find' event handling
|
||||
0.15: Don't keep LCD on while playing music
|
||||
0.16: Handle dismissing notifications on the phone
|
||||
Nicer display of alarm clock notifications
|
||||
Nicer display of alarm clock notifications
|
||||
0.17: Modified music notification for updated 'notify' library
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
case "ALARMCLOCKRECEIVER":
|
||||
return {
|
||||
id: event.id,
|
||||
title: event.title || "Alarm",
|
||||
title: event.title || "Alarm: "+require('locale').time(new Date(), true),
|
||||
body: event.body,
|
||||
// same icon as apps/alarm/app-icon.js
|
||||
icon: require("heatshrink").decompress(atob("mEwwkGswAhiMRCCAREAo4eHBIQLEAgwYHsIJDiwHB5gACBpIhHCoYZEGA4gFCw4ABGA4HEjgXJ4IXGAwcUB4VEmf//8zogICoJIFAodMBoNDCoIADmgJB4gXIFwXDCwoABngwFC4guB4k/CQXwh4EC+YMCC44iBp4qDC4n/+gNBC41sEIJCEC4v/GAPGC4dhXYRdFC4xhCCYIXCdQRdDC5HzegQXCsxGHC45IDCwQXCUgwXHJAIXGRogXJSIIXcOw4XIPAYXcBwv/mEDBAwXOgtQC65QGC5vzoEAJAx3Nmk/mEABIiPN+dDAQIwFC4zXGFwKRCGAjvMFwQECGAgXI4YuGGAUvAgU8C4/EFwwGCAgdMC4p4EFwobFOwoXDJAIoEAApGBC4xIEABJGHGAapEAAqNBFwwXD4heI+YuBC5BIBVQhdHIw4wD5inFS4IKCCxFmigNCokzCoMzogICoIWIsMRjgPCAA3BiMWC48RBQIXJEgMRFxAJCCw4lEC44IECooOIBAaBJKwhgIAH4ACA==")),
|
||||
|
@ -51,13 +51,60 @@
|
|||
if (state.music === "play") {
|
||||
require("notify").show(Object.assign({
|
||||
size:40, id:"music",
|
||||
render:y => {
|
||||
g.setColor(-1);
|
||||
g.drawImage(require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")), 8, y + 8);
|
||||
g.setFontAlign(-1, -1);
|
||||
var x = 40;
|
||||
g.setFont("4x6", 2).drawString(state.musicInfo.artist, x, y + 8);
|
||||
g.setFont("6x8", 1).drawString(state.musicInfo.track, x, y + 22);
|
||||
render:a => {
|
||||
if (a.h>200) {
|
||||
// large:
|
||||
// [icon]
|
||||
// [ ]
|
||||
// <artist>
|
||||
// ------------- middle of screen
|
||||
// <title>
|
||||
const iconSize = 24*3; // 24x24px, scale 3
|
||||
let x = a.x,
|
||||
y = a.y+a.h/2, // we use coords relative to vertical middle
|
||||
w=a.w,h=a.h;
|
||||
// try to fit musicInfo property into width
|
||||
const fitFont = (prop,max) => {
|
||||
if (!(prop in state.musicInfo)) return max;
|
||||
let size = Math.floor(w/(state.musicInfo[prop].length*6));
|
||||
if (size<1) {size=1}
|
||||
if (size>max) {size=max}
|
||||
return size;
|
||||
}
|
||||
let aSize = fitFont('artist',3);
|
||||
// TODO: split long title over multiple lines instead
|
||||
let tSize = fitFont('track',2);
|
||||
let bSize = fitFont('album',2);
|
||||
g.setColor(-1);
|
||||
// TODO: use a nicer large icon?
|
||||
g.drawImage(
|
||||
require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")),
|
||||
x+(w-iconSize)/2, y-(iconSize+aSize*8)-12, {scale: 3});
|
||||
// artist: centered above middle
|
||||
g.setFontAlign(0, 1).setFont("6x8", aSize).drawString(state.musicInfo.artist, x+w/2, y-4);
|
||||
// title: left-aligned below middle
|
||||
g.setFontAlign(-1, -1).setFont("6x8", tSize).drawString(state.musicInfo.track, x, y+4);
|
||||
// album: centered at bottom
|
||||
if (state.musicInfo.album) {
|
||||
// note: using a.y rather than y
|
||||
g.setFontAlign(0, 1).setFont("6x8", bSize).drawString(state.musicInfo.album, x+w/2, a.y+h);
|
||||
}
|
||||
} else {
|
||||
// regular size:
|
||||
// [icon] <artist>
|
||||
// [ ] <title>
|
||||
const size=40, iconSize = 24;
|
||||
let x = a.x,
|
||||
y = a.y+(a.h-size)/2; // center vertically in available area
|
||||
g.setColor(-1);
|
||||
g.drawImage(
|
||||
require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")),
|
||||
x+8, y+8);
|
||||
g.setFontAlign(-1, -1);
|
||||
x += iconSize+16;
|
||||
g.setFont("4x6", 2).drawString(state.musicInfo.artist, x, y+8);
|
||||
g.setFont("6x8", 1).drawString(state.musicInfo.track, x, y+22);
|
||||
}
|
||||
}}, options));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue