Skip to content

Commit

Permalink
Merge pull request #2934 from thyttan/dragboard
Browse files Browse the repository at this point in the history
dragboard: Compat w backswipe on newer firmwares
  • Loading branch information
gfwilliams authored Jul 31, 2023
2 parents 30bca3a + f4c25b9 commit 4061bd2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
3 changes: 3 additions & 0 deletions apps/dragboard/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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.
50 changes: 29 additions & 21 deletions apps/dragboard/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
});
};
2 changes: 1 addition & 1 deletion apps/dragboard/metadata.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 4061bd2

Please sign in to comment.