From f4c25b9db3964880386782405fcfd9ba7efb61cc Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Mon, 31 Jul 2023 19:46:44 +0200 Subject: [PATCH] dragboard: Compat w backswipe on newer firmwares --- apps/dragboard/ChangeLog | 3 +++ apps/dragboard/lib.js | 50 +++++++++++++++++++++--------------- apps/dragboard/metadata.json | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/apps/dragboard/ChangeLog b/apps/dragboard/ChangeLog index faf3d2d33..86b13f288 100644 --- a/apps/dragboard/ChangeLog +++ b/apps/dragboard/ChangeLog @@ -5,3 +5,6 @@ 0.05: Now scrolls text when string gets longer than screen width. 0.06: The code is now more reliable and the input snappier. Widgets will be drawn if present. 0.07: Settings for display colors +some characters. +0.08: Catch and discard swipe events on fw2v19 and up (as well as some cutting + edge 2v18 ones), allowing compatability with the Back Swipe app. diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index 83aae5f14..66b296ffc 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -103,26 +103,7 @@ exports.input = function(options) { initDraw(); //setTimeout(initDraw, 0); // So Bangle.appRect reads the correct environment. It would draw off to the side sometimes otherwise. - function changeCase(abcHL) { - if (settings.uppercase) return; - g.setColor(BGCOLOR); - g.setFontAlign(-1, -1, 0); - g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); - if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) ABC = ABC.toLowerCase(); - else ABC = ABC.toUpperCase(); - g.setColor(ABCCOLOR); - g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); - } - return new Promise((resolve,reject) => { - // Interpret touch input - Bangle.setUI({ - mode: 'custom', - back: ()=>{ - Bangle.setUI(); - g.clearRect(Bangle.appRect); - resolve(text); - }, - drag: function(event) { + let dragHandlerDB = function(event) { "ram"; // ABCDEFGHIJKLMNOPQRSTUVWXYZ // Choose character by draging along red rectangle at bottom of screen @@ -243,7 +224,34 @@ exports.input = function(options) { } } } - } + }; + + let catchSwipe = (_,__)=>{ + E.stopEventPropagation&&E.stopEventPropagation(); + }; + + function changeCase(abcHL) { + if (settings.uppercase) return; + g.setColor(BGCOLOR); + g.setFontAlign(-1, -1, 0); + g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); + if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) ABC = ABC.toLowerCase(); + else ABC = ABC.toUpperCase(); + g.setColor(ABCCOLOR); + g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); + } + return new Promise((resolve,reject) => { + // Interpret touch input + Bangle.setUI({ + mode: 'custom', + back: ()=>{ + Bangle.setUI(); + Bangle.prependListener&&Bangle.removeListener('swipe', catchSwipe); // Remove swipe lister if it was added with `Bangle.prependListener()` (fw2v19 and up). + g.clearRect(Bangle.appRect); + resolve(text); + }, + drag: dragHandlerDB, }); + Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares. }); }; diff --git a/apps/dragboard/metadata.json b/apps/dragboard/metadata.json index 58de5153c..5c52d9389 100644 --- a/apps/dragboard/metadata.json +++ b/apps/dragboard/metadata.json @@ -1,6 +1,6 @@ { "id": "dragboard", "name": "Dragboard", - "version":"0.07", + "version":"0.08", "description": "A library for text input via swiping keyboard", "icon": "app.png", "type":"textinput",