From 6cc8ef8918a6fff210b8a232448fcf33b31f6c50 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 30 Jan 2023 18:27:21 +0100 Subject: [PATCH 1/2] qcenter - Add setting for a timeout --- apps/qcenter/app.js | 12 ++++++++++++ apps/qcenter/settings.js | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/apps/qcenter/app.js b/apps/qcenter/app.js index be28db3b6..f012fdda8 100644 --- a/apps/qcenter/app.js +++ b/apps/qcenter/app.js @@ -110,6 +110,7 @@ let layout = new Layout({ }, { remove: ()=>{ Bangle.removeListener("swipe", onSwipe); + Bangle.removeListener("touch", updateTimeout); delete Graphics.prototype.setFont8x12; } }); @@ -117,6 +118,16 @@ g.clear(); layout.render(); Bangle.drawWidgets(); +let timeout; +const updateTimeout = function(){ +if (settings.timeout){ + if (timeout) clearTimeout(timeout); + timeout = setTimeout(Bangle.showClock,settings.timeout*1000); + } +}; + +updateTimeout(); + // swipe event listener for exit gesture let onSwipe = function (lr, ud) { if(exitGesture == "swipeup" && ud == -1) Bangle.showClock(); @@ -126,4 +137,5 @@ let onSwipe = function (lr, ud) { } Bangle.on("swipe", onSwipe); +Bangle.on("touch", updateTimeout); } diff --git a/apps/qcenter/settings.js b/apps/qcenter/settings.js index 2c97f8a5f..5d38b079e 100644 --- a/apps/qcenter/settings.js +++ b/apps/qcenter/settings.js @@ -49,6 +49,11 @@ E.showMenu(exitGestureMenu); }; + // Set Timeout + mainmenu["Timeout: " + (settings.timeout ? (settings.timeout+"s") : "Off")] = function () { + E.showMenu(timeoutMenu); + }; + //List all pinned apps, redirecting to menu with options to unpin and reorder pinnedApps.forEach((app, i) => { mainmenu[app.name] = function () { @@ -129,5 +134,22 @@ showMainMenu(); }; + // menu for setting timeout + var timeoutMenu = { + "": { title: "Timeout", back: showMainMenu } + }; + timeoutMenu["Off"] = function () { + save("timeout", 0); + showMainMenu(); + }; + let timeoutvalues = [10,20,30,60]; + for (c in timeoutvalues){ + let v = timeoutvalues[c]; + timeoutMenu[v+"s"] = function () { + save("timeout", v); + showMainMenu(); + }; + } + showMainMenu(); }); From 46790eb67fc8b3092930f2c5d2e53d3dc15c92af Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 30 Jan 2023 18:27:37 +0100 Subject: [PATCH 2/2] qcenter - Bump version --- apps/qcenter/ChangeLog | 1 + apps/qcenter/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/qcenter/ChangeLog b/apps/qcenter/ChangeLog index 900b9017c..366b0ff86 100644 --- a/apps/qcenter/ChangeLog +++ b/apps/qcenter/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Fix fast loading on swipe to clock +0.03: Adds a setting for going back to clock on a timeout diff --git a/apps/qcenter/metadata.json b/apps/qcenter/metadata.json index a325de10f..630fd2bef 100644 --- a/apps/qcenter/metadata.json +++ b/apps/qcenter/metadata.json @@ -2,7 +2,7 @@ "id": "qcenter", "name": "Quick Center", "shortName": "QCenter", - "version": "0.02", + "version": "0.03", "description": "An app for quickly launching your favourite apps, inspired by the control centres of other watches.", "icon": "app.png", "tags": "",