gbmusic: Simplify touch controls

pull/1489/head
Richard de Boer 2022-02-13 15:57:40 +01:00
parent eb64a7a436
commit 60cae6bc84
No known key found for this signature in database
GPG Key ID: 8721727971871937
10 changed files with 14 additions and 51 deletions

View File

@ -7,3 +7,4 @@
0.07: Fix "previous" button image
0.08: Fix scrolling title background color
0.09: Move event listener from widget to boot code, stops music from showing up in messages
0.10: Simplify touch events

View File

@ -3,9 +3,10 @@
If you have an Android phone with Gadgetbridge, this app allows you to view
and control music playback.
| Bangle.js 1 | Bangle.js 2 |
|:-------------------------------------------|:-------------------------------------------|
| ![Screenshot: Bangle 1](screenshot_v1.png) | ![Screenshot: Bangle 2](screenshot_v2.png) |
| Bangle.js 1 | Bangle.js 2 |
|:---------------------------------------------------------|:---------------------------------------------------------|
| ![Screenshot: Bangle 1 Dark theme](screenshot_v1_d.png) | ![Screenshot: Bangle 2 Darm theme](screenshot_v2_d.png) |
| ![Screenshot: Bangle 1 Light theme](screenshot_v1_l.png) | ![Screenshot: Bangle 2 Light theme](screenshot_v2_l.png) |
Download the [latest Gadgetbridge for Android here](https://f-droid.org/packages/nodomain.freeyourgadget.gadgetbridge/).
@ -40,9 +41,7 @@ Disable double/triple pressing Middle Button: always simply toggle play/pause.
* Button 3 (*Bangle.js 1*): Volume down
### Touch
* Left: Pause/previous song
* Right: Next song/resume
* Center: Toggle play/pause
* Touch: Toggle play/pause
* Swipe left/right: Next/previous song
* Swipe up/down (*Bangle.js 2*): Volume up/down

View File

@ -195,9 +195,7 @@ function makeUI() {
{
type: "h", c: [
{width: 3},
{id: "prev", type: "custom", height: 15, width: 15, icon: "previous", render: rIcon, bgCol: g.theme.bg},
{id: "date", type: "txt", halign: 0, valign: 1, label: "", font: "8%", fillx: 1, bgCol: g.theme.bg},
{id: "next", type: "custom", height: 15, width: 15, icon: "next", render: rIcon, bgCol: g.theme.bg},
BANGLE2 ? {width: 3} : {id: "down", type: "txt", label: " -", font: "6x8:2"},
],
},
@ -295,16 +293,10 @@ function drawDateTime() {
}
function drawControls() {
let l = layout;
if (BANGLE2) return;
const cc = a => (a ? "#f00" : "#0f0"); // control color: red for active, green for inactive
if (!BANGLE2) {
l.up.col = cc("volumeup" in tCommand);
l.down.col = cc("volumedown" in tCommand);
}
l.prev.icon = (stat==="play") ? "pause" : "previous";
l.prev.col = cc("prev" in tCommand || "pause" in tCommand);
l.next.icon = (stat==="play") ? "next" : "play";
l.next.col = cc("next" in tCommand || "play" in tCommand);
layout.up.col = cc("volumeup" in tCommand);
layout.down.col = cc("volumedown" in tCommand);
layout.render();
}
@ -473,37 +465,16 @@ function sendCommand(command) {
drawControls();
}
// touch/swipe: navigation
function togglePlay() {
sendCommand(stat==="play" ? "pause" : "play");
}
function pausePrev() {
sendCommand(stat==="play" ? "pause" : "previous");
}
function nextPlay() {
sendCommand(stat==="play" ? "next" : "play");
}
/**
* Setup touch+swipe for Bangle.js 1
*/
function touch1() {
Bangle.on("touch", side => {
if (!Bangle.isLCDOn()) {return;} // for <2v10 firmware
switch(side) {
case 1:
pausePrev();
break;
case 2:
nextPlay();
break;
default:
togglePlay();
break;
}
});
Bangle.on("touch", togglePlay);
Bangle.on("swipe", dir => {
if (!Bangle.isLCDOn()) {return;} // for <2v10 firmware
sendCommand(dir===1 ? "previous" : "next");
});
}
@ -511,16 +482,7 @@ function touch1() {
* Setup touch+swipe for Bangle.js 2
*/
function touch2() {
Bangle.on("touch", (side, xy) => {
const ar = Bangle.appRect;
if (xy.x<ar.x+ar.w/3) {
pausePrev();
} else if (xy.x>ar.x+ar.w*2/3) {
nextPlay();
} else {
togglePlay();
}
});
Bangle.on("touch", togglePlay);
// swiping
let drag;
Bangle.on("drag", e => {

View File

@ -2,10 +2,11 @@
"id": "gbmusic",
"name": "Gadgetbridge Music Controls",
"shortName": "Music Controls",
"version": "0.09",
"version": "0.10",
"description": "Control the music on your Gadgetbridge-connected phone",
"icon": "icon.png",
"screenshots": [{"url":"screenshot_v1.png"},{"url":"screenshot_v2.png"}],
"screenshots": [{"url":"screenshot_v1_d.png"},{"url":"screenshot_v1_l.png"},
{"url":"screenshot_v2_d.png"},{"url":"screenshot_v2_l.png"}],
"type": "app",
"tags": "tools,bluetooth,gadgetbridge,music",
"supports": ["BANGLEJS","BANGLEJS2"],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB