From 350e0057f417752faa91f62b35eb54a522e56e7a Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 12 Nov 2022 23:29:27 +0100 Subject: [PATCH] podadrem - compatibility with Fastload Utils --- apps/podadrem/ChangeLog | 1 + apps/podadrem/app.js | 90 +++++++++++++++++++++---------------- apps/podadrem/metadata.json | 2 +- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/apps/podadrem/ChangeLog b/apps/podadrem/ChangeLog index c26e40c0ec..837ef7941f 100644 --- a/apps/podadrem/ChangeLog +++ b/apps/podadrem/ChangeLog @@ -4,3 +4,4 @@ Addict. 0.04: New layout. 0.05: Add widget field, tweak layout. +0.06: Add compatibility with Fastload Utils. diff --git a/apps/podadrem/app.js b/apps/podadrem/app.js index b04d80b17d..0e32847efa 100644 --- a/apps/podadrem/app.js +++ b/apps/podadrem/app.js @@ -1,3 +1,4 @@ +{ /* Bluetooth.println(JSON.stringify({t:"intent", action:"", flags:["flag1", "flag2",...], categories:["category1","category2",...], mimetype:"", data:"", package:"", class:"", target:"", extra:{someKey:"someValueOrString"}})); @@ -65,13 +66,14 @@ Since v2020.16 com.bambuna.podcastaddict.service.player.togglespeed – This will toggle the Playback speed for the episode currently playing (alternate between selected speed and 1.0x). */ -var R; -var backToMenu = false; -var dark = g.theme.dark; // bool +let R; +let widgetUtils = require("widget_utils"); +let backToMenu = false; +let dark = g.theme.dark; // bool // The main layout of the app -function gfx() { - //Bangle.drawWidgets(); +let gfx = function() { + widgetUtils.hide(); R = Bangle.appRect; marigin = 8; // g.drawString(str, x, y, solid) @@ -106,10 +108,10 @@ function gfx() { g.setFontAlign(1, 1, 0); g.drawString("Speed", R.x + R.w - 2*marigin, R.y + R.h - 2*marigin); -} +}; // Touch handler for main layout -function touchHandler(_, xy) { +let touchHandler = function(_, xy) { x = xy.x; y = xy.y; len = (R.w { - if (ud) Bangle.musicControl(ud>0 ? "volumedown" : "volumeup"); - } + {mode : "updown", + remove : ()=>{ + Bangle.removeListener("touch", touchHandler); + Bangle.removeListener("swipe", swipeHandler); + clearWatch(buttonHandler); + widgetUtils.show(); + } + }, + ud => { + if (ud) Bangle.musicControl(ud>0 ? "volumedown" : "volumeup"); + } ); Bangle.on("touch", touchHandler); Bangle.on("swipe", swipeHandler); -} + let buttonHandler = setWatch(()=>{load();}, BTN, {edge:'falling'}); +}; /* The functions for interacting with Android and the Podcast Addict app */ -pkg = "com.bambuna.podcastaddict"; -standardCls = pkg + ".receiver.PodcastAddictPlayerReceiver"; -updateCls = pkg + ".receiver.PodcastAddictBroadcastReceiver"; -speed = 1.0; +let pkg = "com.bambuna.podcastaddict"; +let standardCls = pkg + ".receiver.PodcastAddictPlayerReceiver"; +let updateCls = pkg + ".receiver.PodcastAddictBroadcastReceiver"; +let speed = 1.0; -simpleSearch = ""; +let simpleSearch = ""; -function simpleSearchTerm() { // input a simple search term without tags, overrides search with tags (artist and track) +let simpleSearchTerm = function() { // input a simple search term without tags, overrides search with tags (artist and track) require("textinput").input({ text: simpleSearch }).then(result => { @@ -189,9 +199,9 @@ function simpleSearchTerm() { // input a simple search term without tags, overri }).then(() => { E.showMenu(searchMenu); }); -} +}; -function searchPlayWOTags() { //make a search and play using entered terms +let searchPlayWOTags = function() { //make a search and play using entered terms searchString = simpleSearch; Bluetooth.println(JSON.stringify({ t: "intent", @@ -203,9 +213,9 @@ function searchPlayWOTags() { //make a search and play using entered terms }, flags: ["FLAG_ACTIVITY_NEW_TASK"] })); -} +}; -function gadgetbridgeWake() { +let gadgetbridgeWake = function() { Bluetooth.println(JSON.stringify({ t: "intent", target: "activity", @@ -213,15 +223,15 @@ function gadgetbridgeWake() { package: "gadgetbridge", class: "nodomain.freeyourgadget.gadgetbridge.activities.WakeActivity" })); -} +}; // For stringing together the action for Podcast Addict to perform -function actFn(actName, activOrServ) { +let actFn = function(actName, activOrServ) { return "com.bambuna.podcastaddict." + (activOrServ == "service" ? "service." : "") + actName; -} +}; // Send the intent message to Gadgetbridge -function btMsg(activOrServ, cls, actName, xtra) { +let btMsg = function(activOrServ, cls, actName, xtra) { Bluetooth.println(JSON.stringify({ t: "intent", @@ -231,10 +241,10 @@ function btMsg(activOrServ, cls, actName, xtra) { target: "broadcastreceiver", extra: xtra })); -} +}; // Get back to the main layout -function backToGfx() { +let backToGfx = function() { E.showMenu(); g.clear(); g.reset(); @@ -243,10 +253,10 @@ function backToGfx() { setUI(); gfx(); backToMenu = false; -} +}; // Podcast Addict Menu -var paMenu = { +let paMenu = { "": { title: " ", back: backToGfx @@ -271,7 +281,7 @@ var paMenu = { }; -var controlMenu = { +let controlMenu = { "": { title: " ", back: () => {if (backToMenu) E.showMenu(paMenu); @@ -310,7 +320,7 @@ var controlMenu = { }, }; -var speedMenu = { +let speedMenu = { "": { title: " ", back: () => {if (backToMenu) E.showMenu(paMenu); @@ -333,7 +343,7 @@ var speedMenu = { //"Slower" : ()=>{speed-=0.1; speed=((speed<0.1)?0.1:speed); btMsg("service",standardCls,"player.customspeed",{arg1:speed});}, }; -var searchMenu = { +let searchMenu = { "": { title: " ", @@ -356,7 +366,7 @@ var searchMenu = { "Simpler search and play" : searchPlayWOTags, }; -var navigationMenu = { +let navigationMenu = { "": { title: " ", back: () => {if (backToMenu) E.showMenu(paMenu); @@ -372,4 +382,6 @@ var navigationMenu = { Bangle.loadWidgets(); setUI(); +widgetUtils.hide(); gfx(); +} diff --git a/apps/podadrem/metadata.json b/apps/podadrem/metadata.json index 9292697623..3d49dfdbdd 100644 --- a/apps/podadrem/metadata.json +++ b/apps/podadrem/metadata.json @@ -2,7 +2,7 @@ "id": "podadrem", "name": "Podcast Addict Remote", "shortName": "PA Remote", - "version": "0.05", + "version": "0.06", "description": "Control Podcast Addict on your android device.", "readme": "README.md", "type": "app",