From b52220a070381af0cfd906e269d3071ab4f6c7ff Mon Sep 17 00:00:00 2001 From: stweedo Date: Sun, 25 Jun 2023 04:16:17 -0500 Subject: [PATCH] Only use drag handler if any box isDragging --- apps/boxclk/ChangeLog | 1 + apps/boxclk/app.js | 12 ++++++++++++ apps/boxclk/metadata.json | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/boxclk/ChangeLog b/apps/boxclk/ChangeLog index f35b358197..794203d363 100644 --- a/apps/boxclk/ChangeLog +++ b/apps/boxclk/ChangeLog @@ -1,3 +1,4 @@ 0.01: New App! 0.02: New config options such as step, meridian, short/long formats, custom prefix/suffix 0.03: Allows showing the month in short or long format by setting `"shortMonth"` to true or false +0.04: Improves touchscreen drag handling for background apps such as Pattern Launcher diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 0b0ca8e65c..6321be7c30 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -4,6 +4,7 @@ * 1. Module dependencies and initial configurations * --------------------------------------------------------------- */ + let storage = require("Storage"); let locale = require("locale"); let widgets = require("widget_utils"); @@ -30,6 +31,7 @@ * 2. Graphical and visual configurations * --------------------------------------------------------------- */ + let w = g.getWidth(); let h = g.getHeight(); let totalWidth, totalHeight; @@ -40,6 +42,7 @@ * 3. Touchscreen Handlers * --------------------------------------------------------------- */ + let touchHandler; let dragHandler; let movementDistance = 0; @@ -49,6 +52,7 @@ * 4. Font loading function * --------------------------------------------------------------- */ + let loadCustomFont = function() { Graphics.prototype.setFontBrunoAce = function() { // Actual height 23 (24 - 2) @@ -66,6 +70,7 @@ * 5. Initial settings of boxes and their positions * --------------------------------------------------------------- */ + for (let key in boxesConfig) { if (key === 'bg' && boxesConfig[key].img) { bgImage = storage.read(boxesConfig[key].img); @@ -167,6 +172,7 @@ * 7. String forming helper functions * --------------------------------------------------------------- */ + let isBool = function(val, defaultVal) { return typeof val !== 'undefined' ? Boolean(val) : defaultVal; }; @@ -211,6 +217,7 @@ * 8. Main draw function * --------------------------------------------------------------- */ + let draw = (function() { let updatePerMinute = true; // variable to track the state of time display @@ -272,6 +279,7 @@ * 9. Helper function for touch event * --------------------------------------------------------------- */ + let touchInText = function(e, boxItem, boxKey) { calcBoxSize(boxItem); const pos = calcBoxPos(boxKey); @@ -296,6 +304,7 @@ * 10. Setup function to configure event handlers * --------------------------------------------------------------- */ + let setup = function() { // ------------------------------------ // Define the touchHandler function @@ -343,6 +352,8 @@ // Define the dragHandler function // ------------------------------------ dragHandler = function(e) { + // Check if any box is being dragged + if (!Object.values(isDragging).some(Boolean)) return; // Calculate the movement distance movementDistance += Math.abs(e.dx) + Math.abs(e.dy); // Check if the movement distance exceeds a threshold @@ -396,6 +407,7 @@ * 11. Main execution part * --------------------------------------------------------------- */ + Bangle.loadWidgets(); widgets.swipeOn(); modSetColor(); diff --git a/apps/boxclk/metadata.json b/apps/boxclk/metadata.json index 6717b79d8f..06db0b2fed 100644 --- a/apps/boxclk/metadata.json +++ b/apps/boxclk/metadata.json @@ -1,7 +1,7 @@ { "id": "boxclk", "name": "Box Clock", - "version": "0.03", + "version": "0.04", "description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background", "icon": "app.png", "screenshots": [