mirror of https://github.com/espruino/BangleApps
gbmusic: Simplify touch controls
parent
eb64a7a436
commit
60cae6bc84
|
@ -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
|
||||
|
|
|
@ -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 |
|
||||
|:-------------------------------------------|:-------------------------------------------|
|
||||
|  |  |
|
||||
| Bangle.js 1 | Bangle.js 2 |
|
||||
|:---------------------------------------------------------|:---------------------------------------------------------|
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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 |
Loading…
Reference in New Issue