diff --git a/apps/backswipe/ChangeLog b/apps/backswipe/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/backswipe/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/backswipe/app.png b/apps/backswipe/app.png new file mode 100644 index 000000000..582cb2e08 Binary files /dev/null and b/apps/backswipe/app.png differ diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js new file mode 100644 index 000000000..c45acd4c8 --- /dev/null +++ b/apps/backswipe/boot.js @@ -0,0 +1,33 @@ +(function () { + // Overrride the default setUI method, so we can save the back button callback + var setUI = Bangle.setUI; + Bangle.setUI = function (mode, cb) { + var options = {}; + if ("object"==typeof mode) { + options = mode; + } + + print("Setting UI"); + if(global.BACK) delete global.BACK; + if (options && options.back) { + print("Saving back callback"); + global.BACK = options.back; + } + setUI(mode, cb); + }; + + function goBack(lr, ud) { + // if it is a left to right swipe + if (lr === 1) { + print("Back swipe detected"); + // if we're in an app that has a back button, run the callback for it + if (global.BACK) { + print("Running back callback"); + global.BACK(); + } + } + } + + // Listen to left to right swipe + Bangle.on("swipe", goBack); +})(); diff --git a/apps/backswipe/metadata.json b/apps/backswipe/metadata.json new file mode 100644 index 000000000..6b7eea3d8 --- /dev/null +++ b/apps/backswipe/metadata.json @@ -0,0 +1,13 @@ +{ "id": "backswipe", + "name": "Back Swipe", + "shortName":"BackSwipe", + "version":"0.01", + "description": "Service that allows you to use an app's back button using left to right swipe gesture", + "icon": "app.png", + "tags": "back,gesture,swipe", + "supports" : ["BANGLEJS2"], + "type": "bootloader", + "storage": [ + {"name":"backswipe.boot.js","url":"boot.js"} + ] +}