[gbmusic] fix #3737; fix autostart saved state; pass playpause to gb instead of play; allow widget clicks

master
Logan B 2025-02-08 14:27:01 -06:00
parent c51785467c
commit 205e95347e
No known key found for this signature in database
4 changed files with 15 additions and 8 deletions

View File

@ -12,3 +12,4 @@
0.11: Use default Bangle formatter for booleans 0.11: Use default Bangle formatter for booleans
0.12: Issue newline before GB commands (solves issue with console.log and ignored commands) 0.12: Issue newline before GB commands (solves issue with console.log and ignored commands)
0.13: Upgrade to new translation system 0.13: Upgrade to new translation system
0.14: Fix auto-start saved state; fix clearing track number; allow widget clicks

View File

@ -91,8 +91,8 @@ function rScroller(l) {
const w = g.stringWidth(l.label)+40, const w = g.stringWidth(l.label)+40,
y = l.y+l.h/2; y = l.y+l.h/2;
l.offset = l.offset%w; l.offset = l.offset%w;
g.setClipRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1) //g.setClipRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1)
.setColor(l.col).setBgColor(l.bgCol) // need to set colors: iScroll calls this function outside Layout g.setColor(l.col).setBgColor(l.bgCol) // need to set colors: iScroll calls this function outside Layout
.setFontAlign(-1, 0) // left center .setFontAlign(-1, 0) // left center
.clearRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1) .clearRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1)
.drawString(l.label, l.x-l.offset+40, y) .drawString(l.label, l.x-l.offset+40, y)
@ -433,15 +433,21 @@ function sendCommand(command) {
drawControls(); drawControls();
} }
function handleTouch(btn, pos) {
if (pos === undefined || pos.y >= Bangle.appRect.y) {
togglePlay();
}
}
function togglePlay() { function togglePlay() {
sendCommand(stat==="play" ? "pause" : "play"); sendCommand(stat==="play" ? "pause" : "playpause");
} }
/** /**
* Setup touch+swipe for Bangle.js 1 * Setup touch+swipe for Bangle.js 1
*/ */
function touch1() { function touch1() {
Bangle.on("touch", togglePlay); Bangle.on("touch", handleTouch);
Bangle.on("swipe", dir => { Bangle.on("swipe", dir => {
sendCommand(dir===1 ? "previous" : "next"); sendCommand(dir===1 ? "previous" : "next");
}); });
@ -450,7 +456,7 @@ function touch1() {
* Setup touch+swipe for Bangle.js 2 * Setup touch+swipe for Bangle.js 2
*/ */
function touch2() { function touch2() {
Bangle.on("touch", togglePlay); Bangle.on("touch", handleTouch);
// swiping // swiping
let drag; let drag;
Bangle.on("drag", e => { Bangle.on("drag", e => {

View File

@ -10,7 +10,7 @@ setTimeout( // make other boot code run first, so we override e.g. android.boot.
* Only runs while other apps are loaded * Only runs while other apps are loaded
*/ */
function check() { function check() {
if (s!=="play" || !i || !a || !Bangle.CLOCK) return; // only launch app if we know which song we are playing, and autoLoad is enabled if ((!s || s.state!=="play") || !i || !a || !Bangle.CLOCK) return; // only launch app if we know which song we are playing, and autoLoad is enabled
delete (i.t); delete (i.t);
// store info and launch music app // store info and launch music app
require("Storage").writeJSON("gbmusic.load.json", { require("Storage").writeJSON("gbmusic.load.json", {
@ -27,7 +27,7 @@ setTimeout( // make other boot code run first, so we override e.g. android.boot.
i = e; i = e;
return APP ? info(e) : check(); return APP ? info(e) : check();
case "musicstate": case "musicstate":
s = e.state; s = e;
return APP ? state(e) : check(); return APP ? state(e) : check();
default: default:
// pass on other events // pass on other events

View File

@ -2,7 +2,7 @@
"id": "gbmusic", "id": "gbmusic",
"name": "Gadgetbridge Music Controls", "name": "Gadgetbridge Music Controls",
"shortName": "Music Controls", "shortName": "Music Controls",
"version": "0.13", "version": "0.14",
"description": "Control the music on your Gadgetbridge-connected phone", "description": "Control the music on your Gadgetbridge-connected phone",
"icon": "icon.png", "icon": "icon.png",
"screenshots": [{"url":"screenshot_v1_d.png"},{"url":"screenshot_v1_l.png"}, "screenshots": [{"url":"screenshot_v1_d.png"},{"url":"screenshot_v1_l.png"},