From 8be9b27f8b83605e72083c9ac99f09a68351817b Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:15:12 -0700 Subject: [PATCH 01/46] Create app.js --- 8Ball/app.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 8Ball/app.js diff --git a/8Ball/app.js b/8Ball/app.js new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/8Ball/app.js @@ -0,0 +1 @@ + From 61feaec8c72e7bc78829fe05e6155f1e30b16d90 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:18:29 -0700 Subject: [PATCH 02/46] Update app.js added the app --- 8Ball/app.js | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/8Ball/app.js b/8Ball/app.js index 8b1378917..86096434d 100644 --- a/8Ball/app.js +++ b/8Ball/app.js @@ -1 +1,130 @@ +try {keyboard = require(keyboard);} catch(e) {keyboard = null;}var keyboard = "textinput"; +var Name = ""; +var WaitTime = 0; +Bangle.setLCDTimeout(0); +var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","I just asked the presedent and they say yes","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no"); +var consonants = new Array("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"); +var vowels = new Array("a","e","i","o","u"); +try {keyboard = require(keyboard);} catch(e) {keyboard = null;} +function generateName() +{ + Name = ""; + var nameLength = Math.round(Math.random()*5); + for(var i = 0; i < nameLength; i++){ + var cosonant = consonants[Math.round(Math.random()*consonants.length/2)]; + var vowel = vowels[Math.round(Math.random()*vowels.length/2)]; + Name = Name + cosonant + vowel; + if(Name == "") + { + generateName(); + } + } +} +generateName(); +function menu() +{ + g.clear(); + E.showMenu(); + menuOpen = 1; + E.showMenu({ + "" : { title : /*LANG*/Name }, + "< Back" : () => menu(), + "Start" : () => { + E.showMenu(); + g.clear(); + menuOpen = 0; + Drawtext("ask " + Name + " a yes or no question"); + }, + "Show name" : () => { + E.showMenu(); + if(Name == null) + { + E.showAlert("No Name Data").then(result => {menu();}); + } + + else + { + E.showAlert(Name).then(result => {menu();}); + } + }, + + "regenerate name" : () => { + E.showMenu(); + generateName(); + E.showAlert("name regenerated as " + Name).then(result => {menu();}); + + + }, + "show answers" : () => { + var menu = new Array(); + for(var i = 0; i < answers.length; i++){ + menu.push({title : answers[i]}); + } + E.showMenu(menu); + + + }, + + "Add answer" : () => { + E.showMenu(); + var result = keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();}); + }, + "Edit name" : () => { + E.showMenu(); + var result = keyboard.input({}).then(result => {Name = result, menu();}); + + }, + "Exit" : () => load(), + }); +} +menu(); + + var answer; +function Drawtext(text) +{ + g.clear(); + //g.setFontAlign(0,0); + g.setFont("Vector", 20); + g.drawString(g.wrapString(text, g.getWidth(), -20).join("\n")); + + +} +function DrawWidgets() +{ + Bangle.loadWidgets(); + Bangle.drawWidgets(); +} +function WriteAnswer() +{ + if (menuOpen == 0) + { + var randomnumber = Math.round(Math.random()*answers.length); + answer = answers[randomnumber]; + var i; + + Drawtext(answer); + setTimeout(function() { + Drawtext("ask " + Name + " a yes or no question"); +}, 3000); + + } + +} +//turns screen timeout off when menu closed +//needs attention +/*if(menuOpen == 1) +{ + Bangle.setLCDTimeout(10); +} +else +{ + Bangle.setLCDTimeout(undefined); +}*/ + +setWatch(function() { + menu(); + +}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true, edge:"falling"}); + + Bangle.on('touch', function(button, xy) { WriteAnswer(); }); From 2b7aac868693668fa38761e982bf62386e24ef26 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:34:12 -0700 Subject: [PATCH 03/46] Create app-icon.js added appicon --- 8Ball/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 8Ball/app-icon.js diff --git a/8Ball/app-icon.js b/8Ball/app-icon.js new file mode 100644 index 000000000..18811535a --- /dev/null +++ b/8Ball/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwIROj/wAod//wECgPgg+AAoIDBA4IFBhwCBuACBjgCBnACD4AICBwPACgVggfwgwFB4AiBgYuB4AHBgYsBGQQDBAooTBAAQTBgIFEBgYFBg4kBApARCwAdE4AFBAgMD8AFJCIRBDwJNHFwRZBCgIFCAQKMCg6gC///UQQFFsACBQYQFLFIoFKSpcBGgIABTYIFD4ArCGYQFFg4RDY4IXECAYAHA==")) From f73cdb7126caac0bc5e6c916bc871cffade6f306 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:41:13 -0700 Subject: [PATCH 04/46] Create metadata.json --- 8Ball/metadata.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 8Ball/metadata.json diff --git a/8Ball/metadata.json b/8Ball/metadata.json new file mode 100644 index 000000000..9cbe91389 --- /dev/null +++ b/8Ball/metadata.json @@ -0,0 +1,15 @@ +{ "id": "8ball", + "name": "Magic 8 ball", + "shortName":"8ball", + "icon": "8ball.png", + "version":"0.01", + "description": "It tells your future! + + Ask the 8ball a question by clicking start and then clicking the screen! Then it will answer you question with a yes or no answer (hint : only ask it yes or no questions, its a little dumb).", + "tags": "Games", + "supports": ["BANGLEJS2"], + "storage": [ + {"name":"8ball.app.js","url":"app.js"}, + {"name":"8ball.img","url":"app-icon.js","evaluate":true} + ] +} From e83129cfa1e16a825a63fa588f0d41f0da221c40 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:42:07 -0700 Subject: [PATCH 05/46] Add files via upload --- 8Ball/8ball.png | Bin 0 -> 983 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 8Ball/8ball.png diff --git a/8Ball/8ball.png b/8Ball/8ball.png new file mode 100644 index 0000000000000000000000000000000000000000..72344261a449d4945cc8c8e7e889bc8b1614e466 GIT binary patch literal 983 zcmV;|11S87P)6>g+VS4QY7+% ziE?@2!7brUZp8zUdBjLzghVdo{=iJR%(%^`>!(;ip{lsgQ#O8=MZchl=- zz*=cUj+wn>Ky}=J?f@G#yO|C)nYy+KxEp8p9#|6P6X~W`!8mUKP64AWbc{{0G>q1H zAd8S08uxxb1ttZcIT?5sw@z{iiQ&KpIWkY6lS{i{z=5E!66{s zgY9Q6*kq&w2j!yz=;33$e+XZba0$@TrQIlCx$M5^_uwQpEr1iUx#GcBv#gWgW1xcv zyE2E+dBcTW2Jk@ri||Qz&E8L7q(|H7z)lUM2H2qm>xMDFFTH-gBGWDnV4n|-8buec z9FlKy<5si*J^^(=wyg*-4H$1>*H=&eBhcE$@jT7IX;Mdt#xTdm_=t=bkvbM@42Nxu zV^JhgJT`UBQ6-_U=oy#wJz+vwJ@B@fJ_jUTNVvRLL^5mAHG?#`>kilQRCraW&wUkT zP8Dbn+>oDvUX1eMGH+8>I3y?&srnNR=j3B-P&bgKuzFH`R{BUb*}zR;ri(~q#^jnl zGP>1FpCZlt2<(|HKcU4xOrqKJd&Xqg zuX?nmtd5#2t&ML$7h93o7H=!jvrWGD`wB6 zR6chT0BsZOZ^LfSgZ%6m`%-XOg`JUlNWUoY45k0Hr+aywJ9!bQM6j75a-w$mC#z~+)g5*`4pw-*#hhzKQ*xA+J z&>Da>UiJZXI_jAfVF8z)pcU$9tIqAQR*vraK~N_oK540S(5Nrgu4 Date: Thu, 20 Jun 2024 09:57:31 -0700 Subject: [PATCH 06/46] Create app.js --- apps/8ball/app.js | 130 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 apps/8ball/app.js diff --git a/apps/8ball/app.js b/apps/8ball/app.js new file mode 100644 index 000000000..86096434d --- /dev/null +++ b/apps/8ball/app.js @@ -0,0 +1,130 @@ +try {keyboard = require(keyboard);} catch(e) {keyboard = null;}var keyboard = "textinput"; +var Name = ""; +var WaitTime = 0; +Bangle.setLCDTimeout(0); + +var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","I just asked the presedent and they say yes","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no"); +var consonants = new Array("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"); +var vowels = new Array("a","e","i","o","u"); +try {keyboard = require(keyboard);} catch(e) {keyboard = null;} +function generateName() +{ + Name = ""; + var nameLength = Math.round(Math.random()*5); + for(var i = 0; i < nameLength; i++){ + var cosonant = consonants[Math.round(Math.random()*consonants.length/2)]; + var vowel = vowels[Math.round(Math.random()*vowels.length/2)]; + Name = Name + cosonant + vowel; + if(Name == "") + { + generateName(); + } + } +} +generateName(); +function menu() +{ + g.clear(); + E.showMenu(); + menuOpen = 1; + E.showMenu({ + "" : { title : /*LANG*/Name }, + "< Back" : () => menu(), + "Start" : () => { + E.showMenu(); + g.clear(); + menuOpen = 0; + Drawtext("ask " + Name + " a yes or no question"); + }, + "Show name" : () => { + E.showMenu(); + if(Name == null) + { + E.showAlert("No Name Data").then(result => {menu();}); + } + + else + { + E.showAlert(Name).then(result => {menu();}); + } + }, + + "regenerate name" : () => { + E.showMenu(); + generateName(); + E.showAlert("name regenerated as " + Name).then(result => {menu();}); + + + }, + "show answers" : () => { + var menu = new Array(); + for(var i = 0; i < answers.length; i++){ + menu.push({title : answers[i]}); + } + E.showMenu(menu); + + + }, + + "Add answer" : () => { + E.showMenu(); + var result = keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();}); + }, + "Edit name" : () => { + E.showMenu(); + var result = keyboard.input({}).then(result => {Name = result, menu();}); + + }, + "Exit" : () => load(), + }); +} +menu(); + + var answer; +function Drawtext(text) +{ + g.clear(); + //g.setFontAlign(0,0); + g.setFont("Vector", 20); + g.drawString(g.wrapString(text, g.getWidth(), -20).join("\n")); + + +} +function DrawWidgets() +{ + Bangle.loadWidgets(); + Bangle.drawWidgets(); +} +function WriteAnswer() +{ + if (menuOpen == 0) + { + var randomnumber = Math.round(Math.random()*answers.length); + answer = answers[randomnumber]; + var i; + + Drawtext(answer); + setTimeout(function() { + Drawtext("ask " + Name + " a yes or no question"); +}, 3000); + + } + +} +//turns screen timeout off when menu closed +//needs attention +/*if(menuOpen == 1) +{ + Bangle.setLCDTimeout(10); +} +else +{ + Bangle.setLCDTimeout(undefined); +}*/ + +setWatch(function() { + menu(); + +}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true, edge:"falling"}); + + Bangle.on('touch', function(button, xy) { WriteAnswer(); }); From 57cb0586419165b23f7196e0af3016b815914ba1 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:41:38 -0700 Subject: [PATCH 07/46] Add files via upload --- apps/8ball/8ball.png | Bin 0 -> 983 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/8ball/8ball.png diff --git a/apps/8ball/8ball.png b/apps/8ball/8ball.png new file mode 100644 index 0000000000000000000000000000000000000000..72344261a449d4945cc8c8e7e889bc8b1614e466 GIT binary patch literal 983 zcmV;|11S87P)6>g+VS4QY7+% ziE?@2!7brUZp8zUdBjLzghVdo{=iJR%(%^`>!(;ip{lsgQ#O8=MZchl=- zz*=cUj+wn>Ky}=J?f@G#yO|C)nYy+KxEp8p9#|6P6X~W`!8mUKP64AWbc{{0G>q1H zAd8S08uxxb1ttZcIT?5sw@z{iiQ&KpIWkY6lS{i{z=5E!66{s zgY9Q6*kq&w2j!yz=;33$e+XZba0$@TrQIlCx$M5^_uwQpEr1iUx#GcBv#gWgW1xcv zyE2E+dBcTW2Jk@ri||Qz&E8L7q(|H7z)lUM2H2qm>xMDFFTH-gBGWDnV4n|-8buec z9FlKy<5si*J^^(=wyg*-4H$1>*H=&eBhcE$@jT7IX;Mdt#xTdm_=t=bkvbM@42Nxu zV^JhgJT`UBQ6-_U=oy#wJz+vwJ@B@fJ_jUTNVvRLL^5mAHG?#`>kilQRCraW&wUkT zP8Dbn+>oDvUX1eMGH+8>I3y?&srnNR=j3B-P&bgKuzFH`R{BUb*}zR;ri(~q#^jnl zGP>1FpCZlt2<(|HKcU4xOrqKJd&Xqg zuX?nmtd5#2t&ML$7h93o7H=!jvrWGD`wB6 zR6chT0BsZOZ^LfSgZ%6m`%-XOg`JUlNWUoY45k0Hr+aywJ9!bQM6j75a-w$mC#z~+)g5*`4pw-*#hhzKQ*xA+J z&>Da>UiJZXI_jAfVF8z)pcU$9tIqAQR*vraK~N_oK540S(5Nrgu4 Date: Sat, 6 Jul 2024 13:45:52 -0700 Subject: [PATCH 09/46] Create app-icon.js --- apps/8ball/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/8ball/app-icon.js diff --git a/apps/8ball/app-icon.js b/apps/8ball/app-icon.js new file mode 100644 index 000000000..399dbef21 --- /dev/null +++ b/apps/8ball/app-icon.js @@ -0,0 +1 @@ +atob("MDCBAAAAAAAAAAAAAAAAAAAAH/AAAAAAf/4AAAAB4AeAAAAHgAHgAAAOAABwAAAcAAA4AAA4AMAcAABwAMAOAABgA/AGAADAAeADAAHAAMADgAGAAAABgAGAAAABgAMAAAAAwAMBAAAAwAMDAAAAwAMHwAAAwAMHwAAAwAMDAACAwAMBAADAwAMAAAPgwAMAAAPgwAMAAADAwAGAAACBgAGAAAABgAHAAAADgADAAAADAADgAAAHAAB////+AAB////+AABgAAAGAABgAAAGAABgAAAGAADAAAADAADAAAADAADAAAADAAGAAAABgAGAAAABgAH/////gAP/////wAYAAAAAYAYAAAAAYAf/////4AP/////wAAAAAAAAAAAAAAAAA==") From d8db65b3e76d36c83f24ba21513b0a9e8938fe90 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:46:19 -0700 Subject: [PATCH 10/46] Create metadata.json --- apps/8ball/metadata.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 apps/8ball/metadata.json diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json new file mode 100644 index 000000000..9cbe91389 --- /dev/null +++ b/apps/8ball/metadata.json @@ -0,0 +1,15 @@ +{ "id": "8ball", + "name": "Magic 8 ball", + "shortName":"8ball", + "icon": "8ball.png", + "version":"0.01", + "description": "It tells your future! + + Ask the 8ball a question by clicking start and then clicking the screen! Then it will answer you question with a yes or no answer (hint : only ask it yes or no questions, its a little dumb).", + "tags": "Games", + "supports": ["BANGLEJS2"], + "storage": [ + {"name":"8ball.app.js","url":"app.js"}, + {"name":"8ball.img","url":"app-icon.js","evaluate":true} + ] +} From 8f4ea698e29862f4260dc2847d38c2f29d415a72 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:46:52 -0700 Subject: [PATCH 11/46] Delete 8Ball directory --- 8Ball/8ball.png | Bin 983 -> 0 bytes 8Ball/app-icon.js | 1 - 8Ball/app.js | 130 -------------------------------------------- 8Ball/metadata.json | 15 ----- 4 files changed, 146 deletions(-) delete mode 100644 8Ball/8ball.png delete mode 100644 8Ball/app-icon.js delete mode 100644 8Ball/app.js delete mode 100644 8Ball/metadata.json diff --git a/8Ball/8ball.png b/8Ball/8ball.png deleted file mode 100644 index 72344261a449d4945cc8c8e7e889bc8b1614e466..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 983 zcmV;|11S87P)6>g+VS4QY7+% ziE?@2!7brUZp8zUdBjLzghVdo{=iJR%(%^`>!(;ip{lsgQ#O8=MZchl=- zz*=cUj+wn>Ky}=J?f@G#yO|C)nYy+KxEp8p9#|6P6X~W`!8mUKP64AWbc{{0G>q1H zAd8S08uxxb1ttZcIT?5sw@z{iiQ&KpIWkY6lS{i{z=5E!66{s zgY9Q6*kq&w2j!yz=;33$e+XZba0$@TrQIlCx$M5^_uwQpEr1iUx#GcBv#gWgW1xcv zyE2E+dBcTW2Jk@ri||Qz&E8L7q(|H7z)lUM2H2qm>xMDFFTH-gBGWDnV4n|-8buec z9FlKy<5si*J^^(=wyg*-4H$1>*H=&eBhcE$@jT7IX;Mdt#xTdm_=t=bkvbM@42Nxu zV^JhgJT`UBQ6-_U=oy#wJz+vwJ@B@fJ_jUTNVvRLL^5mAHG?#`>kilQRCraW&wUkT zP8Dbn+>oDvUX1eMGH+8>I3y?&srnNR=j3B-P&bgKuzFH`R{BUb*}zR;ri(~q#^jnl zGP>1FpCZlt2<(|HKcU4xOrqKJd&Xqg zuX?nmtd5#2t&ML$7h93o7H=!jvrWGD`wB6 zR6chT0BsZOZ^LfSgZ%6m`%-XOg`JUlNWUoY45k0Hr+aywJ9!bQM6j75a-w$mC#z~+)g5*`4pw-*#hhzKQ*xA+J z&>Da>UiJZXI_jAfVF8z)pcU$9tIqAQR*vraK~N_oK540S(5Nrgu4 menu(), - "Start" : () => { - E.showMenu(); - g.clear(); - menuOpen = 0; - Drawtext("ask " + Name + " a yes or no question"); - }, - "Show name" : () => { - E.showMenu(); - if(Name == null) - { - E.showAlert("No Name Data").then(result => {menu();}); - } - - else - { - E.showAlert(Name).then(result => {menu();}); - } - }, - - "regenerate name" : () => { - E.showMenu(); - generateName(); - E.showAlert("name regenerated as " + Name).then(result => {menu();}); - - - }, - "show answers" : () => { - var menu = new Array(); - for(var i = 0; i < answers.length; i++){ - menu.push({title : answers[i]}); - } - E.showMenu(menu); - - - }, - - "Add answer" : () => { - E.showMenu(); - var result = keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();}); - }, - "Edit name" : () => { - E.showMenu(); - var result = keyboard.input({}).then(result => {Name = result, menu();}); - - }, - "Exit" : () => load(), - }); -} -menu(); - - var answer; -function Drawtext(text) -{ - g.clear(); - //g.setFontAlign(0,0); - g.setFont("Vector", 20); - g.drawString(g.wrapString(text, g.getWidth(), -20).join("\n")); - - -} -function DrawWidgets() -{ - Bangle.loadWidgets(); - Bangle.drawWidgets(); -} -function WriteAnswer() -{ - if (menuOpen == 0) - { - var randomnumber = Math.round(Math.random()*answers.length); - answer = answers[randomnumber]; - var i; - - Drawtext(answer); - setTimeout(function() { - Drawtext("ask " + Name + " a yes or no question"); -}, 3000); - - } - -} -//turns screen timeout off when menu closed -//needs attention -/*if(menuOpen == 1) -{ - Bangle.setLCDTimeout(10); -} -else -{ - Bangle.setLCDTimeout(undefined); -}*/ - -setWatch(function() { - menu(); - -}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true, edge:"falling"}); - - Bangle.on('touch', function(button, xy) { WriteAnswer(); }); diff --git a/8Ball/metadata.json b/8Ball/metadata.json deleted file mode 100644 index 9cbe91389..000000000 --- a/8Ball/metadata.json +++ /dev/null @@ -1,15 +0,0 @@ -{ "id": "8ball", - "name": "Magic 8 ball", - "shortName":"8ball", - "icon": "8ball.png", - "version":"0.01", - "description": "It tells your future! - - Ask the 8ball a question by clicking start and then clicking the screen! Then it will answer you question with a yes or no answer (hint : only ask it yes or no questions, its a little dumb).", - "tags": "Games", - "supports": ["BANGLEJS2"], - "storage": [ - {"name":"8ball.app.js","url":"app.js"}, - {"name":"8ball.img","url":"app-icon.js","evaluate":true} - ] -} From 47854f69507783ccb19531f4ea9a5abeae2d2336 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:09:44 -0700 Subject: [PATCH 12/46] Update app.js added clockbackground app functionality --- apps/boxclk/app.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 12c69e789..34ffac1b6 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -4,7 +4,7 @@ * 1. Module dependencies and initial configurations * --------------------------------------------------------------- */ - + let background = require("clockbg"); let storage = require("Storage"); let locale = require("locale"); let widgets = require("widget_utils"); @@ -224,9 +224,7 @@ return function(boxes) { date = new Date(); g.clear(); - if (bgImage) { - g.drawImage(bgImage, 0, 0); - } + background.fillRect(Bangle.appRect); if (boxes.time) { boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); updatePerMinute = isBool(boxes.time.short, true); @@ -412,4 +410,4 @@ widgets.swipeOn(); modSetColor(); setup(); -} \ No newline at end of file +} From bf7eba198f61001649687ae36e4bfa6968df46f2 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:10:37 -0700 Subject: [PATCH 13/46] Update ChangeLog --- apps/boxclk/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/boxclk/ChangeLog b/apps/boxclk/ChangeLog index cc73fbc08..b78eba44c 100644 --- a/apps/boxclk/ChangeLog +++ b/apps/boxclk/ChangeLog @@ -3,3 +3,4 @@ 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 0.05: Fixes step count not resetting after a new day starts +0.06 Added clockbackground app functionality From b9c528214a3d647d3f1512df497335bcc2547bad Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:12:39 -0700 Subject: [PATCH 14/46] Update metadata.json --- apps/8ball/metadata.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 9cbe91389..62c7eb468 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -3,9 +3,7 @@ "shortName":"8ball", "icon": "8ball.png", "version":"0.01", - "description": "It tells your future! - - Ask the 8ball a question by clicking start and then clicking the screen! Then it will answer you question with a yes or no answer (hint : only ask it yes or no questions, its a little dumb).", + "description": "It tells your future!", "tags": "Games", "supports": ["BANGLEJS2"], "storage": [ From 5fcb2a0e70a3d099f0898215a99f293ffeda8656 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:17:48 -0700 Subject: [PATCH 15/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 62c7eb468..beb3a07a9 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -4,7 +4,7 @@ "icon": "8ball.png", "version":"0.01", "description": "It tells your future!", - "tags": "Games", + "tags": "", "supports": ["BANGLEJS2"], "storage": [ {"name":"8ball.app.js","url":"app.js"}, From 6c84343cca30b41fc681d6da42697e71041210f1 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:18:53 -0700 Subject: [PATCH 16/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index beb3a07a9..43f24f385 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -4,7 +4,7 @@ "icon": "8ball.png", "version":"0.01", "description": "It tells your future!", - "tags": "", + "tags": "games", "supports": ["BANGLEJS2"], "storage": [ {"name":"8ball.app.js","url":"app.js"}, From b0874f33b5318dde78c7776db35d59cc3801e8b7 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:20:42 -0700 Subject: [PATCH 17/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 43f24f385..029deebbb 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -4,7 +4,7 @@ "icon": "8ball.png", "version":"0.01", "description": "It tells your future!", - "tags": "games", + "tags": "game", "supports": ["BANGLEJS2"], "storage": [ {"name":"8ball.app.js","url":"app.js"}, From 424d199d60ded91cb48c52c0ca6ab33696425a7f Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:23:34 -0700 Subject: [PATCH 18/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 029deebbb..e8417ecb0 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -4,7 +4,7 @@ "icon": "8ball.png", "version":"0.01", "description": "It tells your future!", - "tags": "game", + "tags": "'game'", "supports": ["BANGLEJS2"], "storage": [ {"name":"8ball.app.js","url":"app.js"}, From 95aa6aebe4421c364c69c0a0972cf88063c17d2f Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:26:05 -0700 Subject: [PATCH 19/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index e8417ecb0..029deebbb 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -4,7 +4,7 @@ "icon": "8ball.png", "version":"0.01", "description": "It tells your future!", - "tags": "'game'", + "tags": "game", "supports": ["BANGLEJS2"], "storage": [ {"name":"8ball.app.js","url":"app.js"}, From 7bf68cd8d10181ea627558df8eb0f6412a65c93e Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:29:28 -0700 Subject: [PATCH 21/46] Delete apps/boxclk/boxclk.space.img --- apps/boxclk/boxclk.space.img | Bin 30979 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/boxclk/boxclk.space.img diff --git a/apps/boxclk/boxclk.space.img b/apps/boxclk/boxclk.space.img deleted file mode 100644 index 1708b5c24248a388661783f446bd86f5a2e4f715..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30979 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 Date: Tue, 9 Jul 2024 14:33:15 -0700 Subject: [PATCH 22/46] Add files via upload --- apps/8ball/screenshot.png | Bin 0 -> 2794 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/8ball/screenshot.png diff --git a/apps/8ball/screenshot.png b/apps/8ball/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..f1f888cf339e202c85206ca66034cfa298fe8fff GIT binary patch literal 2794 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 Date: Tue, 9 Jul 2024 14:33:51 -0700 Subject: [PATCH 23/46] Add files via upload --- apps/8ball/screenshot (1).png | Bin 0 -> 2071 bytes apps/8ball/screenshot (2).png | Bin 0 -> 2159 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/8ball/screenshot (1).png create mode 100644 apps/8ball/screenshot (2).png diff --git a/apps/8ball/screenshot (1).png b/apps/8ball/screenshot (1).png new file mode 100644 index 0000000000000000000000000000000000000000..edf1a4695f9c92a40c3dcc7c32cbde94f2c10ce8 GIT binary patch literal 2071 zcmeH|>sQhT7{?K>(Zx#W;zToVQ_fauO%RJR7h0xP3YDRiI;_Yd1TpjS>!w!Xsm(Pb zR%e}MM-aS}qTr-rTACQGpMpu6Mv@9hDVGeG`yckQ7tiy3^?ma_-_P@uCnew)!#rUS z2xM_wY|Nf{t^aS_T;{i+Fy(K?A_QO&qt=+EK zsl;F-T}Hm&VvPN3BI?g0r(Gx;e3R~dvKfuW$=+iB>1_+dd!hEvv-(1V&9?h3Zuud% zZ`VHoUoCZTUIH{<^1UNjMBKa0366Fe^t>eTf#NnZ3$1fgTX|<<*;aA)Ced@bndM%N zvY-Y|bhm5cvp_0=}PZA%1R632zE~3v`-_+P_S^bxB zs?cJA1XY4{T#am^l?G4SYp%o1!nFkVJk-L+)G9&qH^}l9C-1l_;cG&Wj^eBviqA|B z*iK&9(5T7HM0-#=Cnx%+nU1;d)s^EFa&P8}1BL##wR!w_h0;c$pA?6&u+Bw8xHQg# zW8MrSh<_x?7UvznBjm|v9+Az=xAJO1;Na~>B^s9%jUFB@D(H@$weW! zE^?d}4*1nKe#bOw5N2igbhK3(fuB(auis^MRSPJNY3fF}IpwEO=T7P@s)2m)929rH zjnlF$Y2pfg}-5Z8-oSm;;;}Xu)!GfXiyn3#e0W zGn|dEsQm!9*FM(A%@BDsv-64eF*H8IVz%h!9;GW$8FehJIPXQTMtqo%MIWz@)Xil5 zK7lOj+Db1<-`rLP4v*&roD^QC|h+g@Wg2Q~) zqoBlABA+|xSlJoJs_D6j&iSw|tjzj?1y`8>tmMA!Sc;Ffu5zr-c)y8lj2~GdLIff^ z--W`WEFIZzTA_V`^`Z(*Y(&ATI&XhLT2L@KC>1yi=oJSz+TEgcqXJ$ns*B<8SGigT z5RE&Dt}W0>%0nT|{p=SruBd`xG!!$Yu7WZ;M|)mWFaqZDjcr)~LOomQHQ75&DVzo;=^c8Myf}p_PW%2hf@wcENa( z5<+XNv#g*TEV^YQQ`2u(yXG5T{MO!w8;kN)Z-U;aZ#ejfM ny&S%pz6SBN5&s(+KrtlIcR_q;+Xe6WPY;RvF(HN@edyf3g>8t> literal 0 HcmV?d00001 diff --git a/apps/8ball/screenshot (2).png b/apps/8ball/screenshot (2).png new file mode 100644 index 0000000000000000000000000000000000000000..c5c6070896ac96a610ce639c9272b8d667f05624 GIT binary patch literal 2159 zcmeHJYgZBm05yU%R`U_omKFz1E9kLi&U}DoVo0TBDy5*-N_He)I1~kCW~J_wOdHuT ztqj{b65x@PL{MfA^X+mdNFquT6Ga_IKoOn$6Z_PMd+&$)?Vfwjxg}@APi_V81l!oy zYz@PNM6PT7f3VxM&V1p=_;uNk8F@0;hS%r%$;QTRe^|)zC~Ev{wJuhPfdI#?&`N97 z>*vpVrvAcjNr_ylNZ(_Ms(9*nf7B!t3Yk7@7&Uscc+SDB(U@pzt2Ij`Vd%B-NXA?M zd#yE_q9Jmq;@}+`jviVgWvJ*{AB;y=pHpaG^xu(c$4W+00w@+iq=53@60QOkv@q}r zX6{ilVC)`Oib$(oTjHi_ha&gQzsi?T&>SAw|BJ7XIM!^m{uW!O?`>na7Q3cZ$heE< zLjl1q8{~dGiYn8rP%h`3>1Z2E&}8Yc6iXzB z{ZlB-u4fB}l3R|nc>8vTr`~jiG&C7pKCPOPt0l7$B&&c_qhxWoZ+dbc{)v`3FD+}c zVKJ#(2~s87_`X@{==-ic*UKO1spyoElXgX^%WhvWdVo-Yc2Q599Av(^xKf2O^;Ee4 zueBAbNOzJLMwB@@!U8Ash)b9qE9-fgCq9*kMUAcC7kr5MonTSK2IYeC_Za63Z}ayV zljF`wj%N{W;)WGUT?|c)MZpcSoKU^fX2O8CX|ffs<|yHg)S}m3ZyI;gW6$DRC75op zsGMn6H2@+Q>ZR@xee3~vy3B+iK2paC4P_Lk5`NP;e-)j(<;vENbp#2FGaS##m^2@J zbn|}BC1#oQO8{70_(W^|4gg+BnaUgA1%yy-(ftc4K!{m6U}^WaqvuzVJMLObgJiz3 zV+&JxJ8CJsG6lRl!jij~Hyx4%UKu=qzrX|>ma>a-LBG|$)k3IMihJ&%sVVM)xOT}v z7`$Lx#Xsb@Vp$#+VDhHt6rAkhCNUEjLoixQ>-piz0A*ky zi9EFUtHZQAng=;I=J=Y@Hr59}YD^EOUMuwyM5$GzULFbf4Pl34Aul_N(CVILjrZbJ$@HDf<{``W%S|hWc>c(6 z^aBgl0mNG)z5LPTxL=@gVT%#TfZLAH@Rg(A^~D&dikTB!ScMkcDk zcA6C!iERY^Fp46YbWuatUsVUKaNSZ(UF`7bThlG41^rNVI9;)QV&#xzB#w*qb@R^~ z`JFbXA>BpNS*#fjaVW^xgwt|?sQ70|@?O`#F4`1~*Qf|A3h4hOh|^%gKCyRm*X@+R znRYL}rM+p+_THN&p4NM}r(TIe`&x1mvB`rUx@O7eZ$K$KL8}vf&eX%{AXT>@-~phb z_|_%})oysX9>DjaQ{Sl;+7u%$or18Rw#|ckF8Y3r2`bol>WI_c$I>d+-2x!wSUto& l1Mu1UoW|#F{J(Qp-FSiqi918|(XKxTn=o{E2roGC`oBR3t?mE- literal 0 HcmV?d00001 From 3af47e000eff936d8074fa05c10781620304f48e Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:37:15 -0700 Subject: [PATCH 24/46] Rename screenshot (1).png to screenshot-1.png --- apps/8ball/{screenshot (1).png => screenshot-1.png} | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/8ball/{screenshot (1).png => screenshot-1.png} (100%) diff --git a/apps/8ball/screenshot (1).png b/apps/8ball/screenshot-1.png similarity index 100% rename from apps/8ball/screenshot (1).png rename to apps/8ball/screenshot-1.png From afb2a522419f9fe99d9789046adca3125982ae8a Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:37:32 -0700 Subject: [PATCH 25/46] Rename screenshot (2).png to screenshot-2.png --- apps/8ball/{screenshot (2).png => screenshot-2.png} | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/8ball/{screenshot (2).png => screenshot-2.png} (100%) diff --git a/apps/8ball/screenshot (2).png b/apps/8ball/screenshot-2.png similarity index 100% rename from apps/8ball/screenshot (2).png rename to apps/8ball/screenshot-2.png From 6676acc37fe55276f41e36c16c845c10a2db74c0 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:38:35 -0700 Subject: [PATCH 26/46] Update metadata.json --- apps/8ball/metadata.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 029deebbb..2cdb11002 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -3,6 +3,11 @@ "shortName":"8ball", "icon": "8ball.png", "version":"0.01", + "screenshots": [ + {"url":"screenshot.png"}, + {"url":"screenshot-1.png"}, + {"url":"screenshot-2.png"} + ], "description": "It tells your future!", "tags": "game", "supports": ["BANGLEJS2"], From 408dbf76b1593e5f965b8d715285890843d844bd Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:41:13 -0700 Subject: [PATCH 27/46] Update metadata.json --- apps/8ball/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 2cdb11002..6944bfa2a 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -8,6 +8,7 @@ {"url":"screenshot-1.png"}, {"url":"screenshot-2.png"} ], + "allow_emulator": true, "description": "It tells your future!", "tags": "game", "supports": ["BANGLEJS2"], From 1b714a03503473ff72160197d570ac517ccc5610 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:46:18 -0700 Subject: [PATCH 28/46] Create ChangeLog --- apps/8ball/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/8ball/ChangeLog diff --git a/apps/8ball/ChangeLog b/apps/8ball/ChangeLog new file mode 100644 index 000000000..3bcffb19b --- /dev/null +++ b/apps/8ball/ChangeLog @@ -0,0 +1 @@ +0.01: New App! From 39aeb9f55ae7fff5fd31dcde40f5086d97154b5a Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:55:19 -0700 Subject: [PATCH 29/46] Update metadata.json --- apps/8ball/metadata.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 6944bfa2a..b36cd5afb 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -16,4 +16,7 @@ {"name":"8ball.app.js","url":"app.js"}, {"name":"8ball.img","url":"app-icon.js","evaluate":true} ] + "data": [ + {"name":"8ballAnswers.json","url":"8ballAnswers.json"} + ] } From 9c391a9afd79c0f8fa42c5347b9ee0cfe80f31ac Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:05:55 -0700 Subject: [PATCH 30/46] Update metadata.json --- apps/8ball/metadata.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index b36cd5afb..71a05e014 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -15,8 +15,4 @@ "storage": [ {"name":"8ball.app.js","url":"app.js"}, {"name":"8ball.img","url":"app-icon.js","evaluate":true} - ] - "data": [ - {"name":"8ballAnswers.json","url":"8ballAnswers.json"} - ] } From 32060fb8f6183c678629fd0a78914f97aa1bd1dd Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:06:21 -0700 Subject: [PATCH 31/46] Update metadata.json --- apps/8ball/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 71a05e014..6944bfa2a 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -15,4 +15,5 @@ "storage": [ {"name":"8ball.app.js","url":"app.js"}, {"name":"8ball.img","url":"app-icon.js","evaluate":true} + ] } From 898f997ecc8c9f22901a8b572322102cc04341bf Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:16:58 -0700 Subject: [PATCH 32/46] Update metadata.json --- apps/boxclk/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/boxclk/metadata.json b/apps/boxclk/metadata.json index dd81ac436..79b4c3019 100644 --- a/apps/boxclk/metadata.json +++ b/apps/boxclk/metadata.json @@ -4,6 +4,7 @@ "version": "0.05", "description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background", "icon": "app.png", + "dependencies" : { "clockbg":"module" }, "screenshots": [ {"url":"screenshot.png"}, {"url":"screenshot-1.png"}, From 9956c09339c3b41b47f2820b4d15fd6d458d5f3a Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Fri, 12 Jul 2024 06:56:19 -0700 Subject: [PATCH 33/46] Update app.js --- apps/8ball/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/app.js b/apps/8ball/app.js index 86096434d..581e3e7bc 100644 --- a/apps/8ball/app.js +++ b/apps/8ball/app.js @@ -3,7 +3,7 @@ var Name = ""; var WaitTime = 0; Bangle.setLCDTimeout(0); -var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","I just asked the presedent and they say yes","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no"); +var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no", "uh... can you ask that again? I kinda forgot", "I know I'm a computer, but even I can get bored"); var consonants = new Array("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"); var vowels = new Array("a","e","i","o","u"); try {keyboard = require(keyboard);} catch(e) {keyboard = null;} From 540c68f2c500dc5cd793cab6789ff73f10328952 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Fri, 12 Jul 2024 06:56:58 -0700 Subject: [PATCH 34/46] Update metadata.json --- apps/8ball/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/metadata.json b/apps/8ball/metadata.json index 6944bfa2a..da387d3d6 100644 --- a/apps/8ball/metadata.json +++ b/apps/8ball/metadata.json @@ -9,7 +9,7 @@ {"url":"screenshot-2.png"} ], "allow_emulator": true, - "description": "It tells your future!", + "description": "A very sarcastic magic 8ball", "tags": "game", "supports": ["BANGLEJS2"], "storage": [ From 42b3de082ea2542315ce7d828de2f232da23065e Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:39:01 -0700 Subject: [PATCH 35/46] Update app.js --- apps/8ball/app.js | 49 +++++------------------------------------------ 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/apps/8ball/app.js b/apps/8ball/app.js index 581e3e7bc..5a15e5bca 100644 --- a/apps/8ball/app.js +++ b/apps/8ball/app.js @@ -1,9 +1,8 @@ try {keyboard = require(keyboard);} catch(e) {keyboard = null;}var keyboard = "textinput"; var Name = ""; -var WaitTime = 0; Bangle.setLCDTimeout(0); - -var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no", "uh... can you ask that again? I kinda forgot", "I know I'm a computer, but even I can get bored"); +var menuOpen = 1; +var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no"); var consonants = new Array("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"); var vowels = new Array("a","e","i","o","u"); try {keyboard = require(keyboard);} catch(e) {keyboard = null;} @@ -36,28 +35,12 @@ function menu() menuOpen = 0; Drawtext("ask " + Name + " a yes or no question"); }, - "Show name" : () => { - E.showMenu(); - if(Name == null) - { - E.showAlert("No Name Data").then(result => {menu();}); - } - - else - { - E.showAlert(Name).then(result => {menu();}); - } - }, - "regenerate name" : () => { E.showMenu(); generateName(); - E.showAlert("name regenerated as " + Name).then(result => {menu();}); - - }, "show answers" : () => { - var menu = new Array(); + var menu = new Array([]); for(var i = 0; i < answers.length; i++){ menu.push({title : answers[i]}); } @@ -72,28 +55,18 @@ function menu() }, "Edit name" : () => { E.showMenu(); - var result = keyboard.input({}).then(result => {Name = result, menu();}); - + var result = keyboard.input({}).then(result => {menu(), Name = result;}); }, "Exit" : () => load(), }); } menu(); - - var answer; +var answer; function Drawtext(text) { g.clear(); - //g.setFontAlign(0,0); g.setFont("Vector", 20); g.drawString(g.wrapString(text, g.getWidth(), -20).join("\n")); - - -} -function DrawWidgets() -{ - Bangle.loadWidgets(); - Bangle.drawWidgets(); } function WriteAnswer() { @@ -101,8 +74,6 @@ function WriteAnswer() { var randomnumber = Math.round(Math.random()*answers.length); answer = answers[randomnumber]; - var i; - Drawtext(answer); setTimeout(function() { Drawtext("ask " + Name + " a yes or no question"); @@ -111,16 +82,6 @@ function WriteAnswer() } } -//turns screen timeout off when menu closed -//needs attention -/*if(menuOpen == 1) -{ - Bangle.setLCDTimeout(10); -} -else -{ - Bangle.setLCDTimeout(undefined); -}*/ setWatch(function() { menu(); From d789d37de5d3339f87140fcc7088c94e778ee0f1 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:41:09 -0700 Subject: [PATCH 36/46] Update app.js --- apps/boxclk/app.js | 798 ++++++++++++++++++++++----------------------- 1 file changed, 397 insertions(+), 401 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 34ffac1b6..8c29aac14 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -1,413 +1,409 @@ +let background = require("clockbg"); +Modules.addCached("widget_utils", function() { + exports.hide = function() { + exports.cleanup(); + if (!global.WIDGETS) return; + g.reset(); + for (var w of global.WIDGETS) { + if (w._draw) return; + w._draw = w.draw; + w.draw = () => {}; + w._area = w.area; + w.area = ""; + if (w.x != undefined) g.clearRect(w.x, w.y, w.x + w.width - 1, w.y + 23); + } + }; + exports.show = function() { + exports.cleanup(); + if (!global.WIDGETS) return; + for (var w of global.WIDGETS) { + if (!w._draw) return; + w.draw = w._draw; + w.area = w._area; + delete w._draw; + delete w._area; + w.draw(w); + } + }; + exports.cleanup = function() { + delete exports.autohide; + delete Bangle.appRect; + if (exports.swipeHandler) { + Bangle.removeListener("swipe", exports.swipeHandler); + delete exports.swipeHandler; + } + if (exports.animInterval) { + clearInterval(exports.animInterval); + delete exports.animInterval; + } + if (exports.hideTimeout) { + clearTimeout(exports.hideTimeout); + delete exports.hideTimeout; + } + if (exports.origDraw) { + Bangle.drawWidgets = exports.origDraw; + delete exports.origDraw; + } + } + exports.swipeOn = function(autohide) { + if (process.env.HWVERSION !== 2) return exports.hide(); + exports.cleanup(); + if (!global.WIDGETS) return; + exports.autohide = autohide === undefined ? 2000 : autohide; + Bangle.appRect = { + x: 0, + y: 0, + w: g.getWidth(), + h: g.getHeight(), + x2: g.getWidth() - 1, + y2: g.getHeight() - 1 + }; + let og = Graphics.createArrayBuffer(g.getWidth(), 26, 16, { + msb: true + }); + og.theme = g.theme; + og._reset = og.reset; + og.reset = function() { + return this._reset().setColor(g.theme.fg).setBgColor(g.theme.bg); + }; + og.reset().clearRect(0, 0, og.getWidth(), 23).fillRect(0, 24, og.getWidth(), 25); + let _g = g; + let offset = -24; + + function queueDraw() { + Bangle.appRect.y = offset + 24; + Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y; + if (offset > -24) Bangle.setLCDOverlay(og, 0, offset); + else Bangle.setLCDOverlay(); + } + for (var w of global.WIDGETS) { + if (w._draw) continue; + w._draw = w.draw; + w.draw = function() { + g = og; + this._draw(this); + g = _g; + if (offset > -24) queueDraw(); + }; + w._area = w.area; + if (w.area.startsWith("b")) w.area = "t" + w.area.substr(1); + } + exports.origDraw = Bangle.drawWidgets; + Bangle.drawWidgets = () => { + g = og; + exports.origDraw(); + g = _g; + }; + + function anim(dir, callback) { + if (exports.animInterval) clearInterval(exports.interval); + exports.animInterval = setInterval(function() { + offset += dir; + let stop = false; + if (dir > 0 && offset >= 0) { + stop = true; + offset = 0; + } else if (dir < 0 && offset < -23) { + stop = true; + offset = -24; + } + if (stop) { + clearInterval(exports.animInterval); + delete exports.animInterval; + if (callback) callback(); + } + queueDraw(); + }, 50); + } + exports.swipeHandler = function(lr, ud) { + if (exports.hideTimeout) { + clearTimeout(exports.hideTimeout); + delete exports.hideTimeout; + } + let cb; + if (exports.autohide > 0) cb = function() { + exports.hideTimeout = setTimeout(function() { + anim(-4); + }, exports.autohide); + } + if (ud > 0 && offset < 0) anim(4, cb); + if (ud < 0 && offset > -24) anim(-4); + }; + Bangle.on("swipe", exports.swipeHandler); + Bangle.drawWidgets(); + }; +}); { - /** - * --------------------------------------------------------------- - * 1. Module dependencies and initial configurations - * --------------------------------------------------------------- - */ - let background = require("clockbg"); - let storage = require("Storage"); - let locale = require("locale"); - let widgets = require("widget_utils"); - let date = new Date(); - let bgImage; - let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0; - let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json'; - // Add a condition to check if the file exists, if it does not, default to 'boxclk.json' - if (!storage.read(fileName)) { - fileName = 'boxclk.json'; - } - let boxesConfig = storage.readJSON(fileName, 1) || {}; - let boxes = {}; - let boxPos = {}; - let isDragging = {}; - let wasDragging = {}; - let doubleTapTimer = null; - let g_setColor; - - let saveIcon = require("heatshrink").decompress(atob("mEwwkEogA/AHdP/4AK+gWVDBQWNAAIuVGBAIB+UQdhMfGBAHBCxUAgIXHIwPyCxQwEJAgXB+MAl/zBwQGBn8ggQjBGAQXG+EA/4XI/8gBIQXTGAMPC6n/C6HzkREBC6YACC6QAFC57aHCYIXOOgLsEn4XPABIX/C6vykQAEl6/WgCQBC5imFAAT2BC5gCBI4oUCC5x0IC/4X/C4K8Bl4XJ+TCCC4wKBABkvC4tEEoMQCxcBB4IWEC4XyDBUBFwIXGJAIAOIwowDABoWGGB4uHDBwWJAH4AzA")); - - /** - * --------------------------------------------------------------- - * 2. Graphical and visual configurations - * --------------------------------------------------------------- - */ - - let w = g.getWidth(); - let h = g.getHeight(); - let totalWidth, totalHeight; - let drawTimeout; - - /** - * --------------------------------------------------------------- - * 3. Touchscreen Handlers - * --------------------------------------------------------------- - */ - - let touchHandler; - let dragHandler; - let movementDistance = 0; - - /** - * --------------------------------------------------------------- - * 4. Font loading function - * --------------------------------------------------------------- - */ - - let loadCustomFont = function() { - Graphics.prototype.setFontBrunoAce = function() { - // Actual height 23 (24 - 2) - return this.setFontCustom( - E.toString(require('heatshrink').decompress(atob('ABMHwADBh4DKg4bKgIPDAYUfAYV/AYX/AQMD/gmC+ADBn/AByE/GIU8AYUwLxcfAYX/8AnB//4JIP/FgMP4F+CQQBBjwJBFYRbBAd43DHoJpBh/g/xPEK4ZfDgEEORKDDAY8////wADLfZrTCgITBnhEBAYJMBAYMPw4DCM4QDjhwDCjwDBn0+AYMf/gDBh/4AYMH+ADBLpc4ToK/NGYZfnAYcfL4U/x5fBW4LvB/7vC+LvBgHAsBfIn76Cn4WBcYQDFEgJ+CQQYDyH4L/BAZbHLNYjjCAZc8ngDunycBZ4KkBa4KwBnEHY4UB+BfMgf/ZgMH/4XBc4cf4F/gE+ZgRjwAYcfj5jBM4U4M4RQBM4UA8BjIngDFEYJ8BAYUDAYQvCM4ZxBC4V+AYQvBnkBQ4M8gabBJQPAI4WAAYM/GYQaBAYJKCnqyCn5OCn4aBAYIaBAYJPCU4IABnBhIuDXCFAMD+Z/BY4IDBQwOPwEfv6TDAYUPAcwrDAYQ7BAYY/BI4cD8bLCK4RfEAA0BRYTeDcwIrFn0Pw43Bg4DugYDBjxBBU4SvDMYMH/5QBgP/LAQAP8EHN4UPwADHB4YAHA'))), - 46, - atob("CBEdChgYGhgaGBsaCQ=="), - 32|65536 - ); - }; - }; - - /** - * --------------------------------------------------------------- - * 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); - } else if (key !== 'selectedConfig') { - boxes[key] = Object.assign({}, boxesConfig[key]); + let storage = require("Storage"); + let locale = require("locale"); + let widgets = require("widget_utils"); + let date = new Date(); + let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0; + let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json'; + if (!storage.read(fileName)) { + fileName = 'boxclk.json'; } - } - - let boxKeys = Object.keys(boxes); - - boxKeys.forEach((key) => { - let boxConfig = boxes[key]; - boxPos[key] = { - x: w * boxConfig.boxPos.x, - y: h * boxConfig.boxPos.y + let boxesConfig = storage.readJSON(fileName, 1) || {}; + let boxes = {}; + let boxPos = {}; + let isDragging = {}; + let wasDragging = {}; + let doubleTapTimer = null; + let g_setColor; + let saveIcon = require("heatshrink").decompress(atob("mEwwkEogA/AHdP/4AK+gWVDBQWNAAIuVGBAIB+UQdhMfGBAHBCxUAgIXHIwPyCxQwEJAgXB+MAl/zBwQGBn8ggQjBGAQXG+EA/4XI/8gBIQXTGAMPC6n/C6HzkREBC6YACC6QAFC57aHCYIXOOgLsEn4XPABIX/C6vykQAEl6/WgCQBC5imFAAT2BC5gCBI4oUCC5x0IC/4X/C4K8Bl4XJ+TCCC4wKBABkvC4tEEoMQCxcBB4IWEC4XyDBUBFwIXGJAIAOIwowDABoWGGB4uHDBwWJAH4AzA")); + let w = g.getWidth(); + let h = g.getHeight(); + let totalWidth, totalHeight; + let drawTimeout; + let touchHandler; + let dragHandler; + let movementDistance = 0; + let loadCustomFont = function() { + Graphics.prototype.setFontBrunoAce = function() { + return this.setFontCustom(E.toString(require('heatshrink').decompress(atob('ABMHwADBh4DKg4bKgIPDAYUfAYV/AYX/AQMD/gmC+ADBn/AByE/GIU8AYUwLxcfAYX/8AnB//4JIP/FgMP4F+CQQBBjwJBFYRbBAd43DHoJpBh/g/xPEK4ZfDgEEORKDDAY8////wADLfZrTCgITBnhEBAYJMBAYMPw4DCM4QDjhwDCjwDBn0+AYMf/gDBh/4AYMH+ADBLpc4ToK/NGYZfnAYcfL4U/x5fBW4LvB/7vC+LvBgHAsBfIn76Cn4WBcYQDFEgJ+CQQYDyH4L/BAZbHLNYjjCAZc8ngDunycBZ4KkBa4KwBnEHY4UB+BfMgf/ZgMH/4XBc4cf4F/gE+ZgRjwAYcfj5jBM4U4M4RQBM4UA8BjIngDFEYJ8BAYUDAYQvCM4ZxBC4V+AYQvBnkBQ4M8gabBJQPAI4WAAYM/GYQaBAYJKCnqyCn5OCn4aBAYIaBAYJPCU4IABnBhIuDXCFAMD+Z/BY4IDBQwOPwEfv6TDAYUPAcwrDAYQ7BAYY/BI4cD8bLCK4RfEAA0BRYTeDcwIrFn0Pw43Bg4DugYDBjxBBU4SvDMYMH/5QBgP/LAQAP8EHN4UPwADHB4YAHA'))), 46, atob("CBEdChgYGhgaGBsaCQ=="), 32 | 65536); + }; }; - isDragging[key] = false; - wasDragging[key] = false; - }); - - /** - * --------------------------------------------------------------- - * 6. Text and drawing functions - * --------------------------------------------------------------- - */ - - // Overwrite the setColor function to allow the - // use of (x) in g.theme.x as a string - // in your JSON config ("fg", "bg", "fg2", "bg2", "fgH", "bgH") - let modSetColor = function() { - // Save the original setColor function - g_setColor = g.setColor; - // Overwrite setColor with the new function - g.setColor = function(color) { - if (typeof color === "string" && color in g.theme) { - g_setColor.call(g, g.theme[color]); - } else { - g_setColor.call(g, color); - } + for (let key in boxesConfig) { + if (key === 'bg' && boxesConfig[key].img) { + bgImage = storage.read(boxesConfig[key].img); + } else if (key !== 'selectedConfig') { + boxes[key] = Object.assign({}, boxesConfig[key]); + } + } + let boxKeys = Object.keys(boxes); + boxKeys.forEach((key) => { + let boxConfig = boxes[key]; + boxPos[key] = { + x: w * boxConfig.boxPos.x, + y: h * boxConfig.boxPos.y + }; + isDragging[key] = false; + wasDragging[key] = false; + }); + let modSetColor = function() { + g_setColor = g.setColor; + g.setColor = function(color) { + if (typeof color === "string" && color in g.theme) { + g_setColor.call(g, g.theme[color]); + } else { + g_setColor.call(g, color); + } + }; }; - }; - - let restoreSetColor = function() { - // Restore the original setColor function - if (g_setColor) { - g.setColor = g_setColor; - } - }; - - // Overwrite the drawString function - let g_drawString = g.drawString; - g.drawString = function(box, str, x, y) { - outlineText(box, str, x, y); - g.setColor(box.color); - g_drawString.call(g, str, x, y); - }; - - let outlineText = function(box, str, x, y) { - let px = box.outline; - let dx = [-px, 0, px, -px, px, -px, 0, px]; - let dy = [-px, -px, -px, 0, 0, px, px, px]; - g.setColor(box.outlineColor); - for (let i = 0; i < dx.length; i++) { - g_drawString.call(g, str, x + dx[i], y + dy[i]); - } - }; - - let calcBoxSize = function(boxItem) { - g.reset(); - g.setFontAlign(0,0); - g.setFont(boxItem.font, boxItem.fontSize); - let strWidth = g.stringWidth(boxItem.string) + 2 * boxItem.outline; - let fontHeight = g.getFontHeight() + 2 * boxItem.outline; - totalWidth = strWidth + 2 * boxItem.xPadding; - totalHeight = fontHeight + 2 * boxItem.yPadding; - }; - - let calcBoxPos = function(boxKey) { - return { - x1: boxPos[boxKey].x - totalWidth / 2, - y1: boxPos[boxKey].y - totalHeight / 2, - x2: boxPos[boxKey].x + totalWidth / 2, - y2: boxPos[boxKey].y + totalHeight / 2 + let restoreSetColor = function() { + if (g_setColor) { + g.setColor = g_setColor; + } }; - }; - - let displaySaveIcon = function() { - draw(boxes); - g.drawImage(saveIcon, w / 2 - 24, h / 2 - 24); - // Display save icon for 2 seconds - setTimeout(() => { - g.clearRect(w / 2 - 24, h / 2 - 24, w / 2 + 24, h / 2 + 24); - draw(boxes); - }, 2000); - }; - - /** - * --------------------------------------------------------------- - * 7. String forming helper functions - * --------------------------------------------------------------- - */ - - let isBool = function(val, defaultVal) { - return typeof val !== 'undefined' ? Boolean(val) : defaultVal; - }; - - let getDate = function(short, shortMonth, disableSuffix) { - const date = new Date(); - const dayOfMonth = date.getDate(); - const month = shortMonth ? locale.month(date, 1) : locale.month(date, 0); - const year = date.getFullYear(); - let suffix; - if ([1, 21, 31].includes(dayOfMonth)) { - suffix = "st"; - } else if ([2, 22].includes(dayOfMonth)) { - suffix = "nd"; - } else if ([3, 23].includes(dayOfMonth)) { - suffix = "rd"; - } else { - suffix = "th"; - } - let dayOfMonthStr = disableSuffix ? dayOfMonth : dayOfMonth + suffix; - return month + " " + dayOfMonthStr + (short ? '' : (", " + year)); // not including year for short version - }; - - let getDayOfWeek = function(date, short) { - return locale.dow(date, short ? 1 : 0); - }; - - locale.meridian = function(date, short) { - let hours = date.getHours(); - let meridian = hours >= 12 ? 'PM' : 'AM'; - return short ? meridian[0] : meridian; - }; - - let modString = function(boxItem, data) { - let prefix = boxItem.prefix || ''; - let suffix = boxItem.suffix || ''; - return prefix + data + suffix; - }; - - /** - * --------------------------------------------------------------- - * 8. Main draw function - * --------------------------------------------------------------- - */ - - let draw = (function() { - let updatePerMinute = true; // variable to track the state of time display - - return function(boxes) { - date = new Date(); - g.clear(); - background.fillRect(Bangle.appRect); - if (boxes.time) { - boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); - updatePerMinute = isBool(boxes.time.short, true); - } - if (boxes.meridian) { - boxes.meridian.string = modString(boxes.meridian, locale.meridian(date, isBool(boxes.meridian.short, true))); - } - if (boxes.date) { - boxes.date.string = ( - modString(boxes.date, - getDate(isBool(boxes.date.short, true), - isBool(boxes.date.shortMonth, true), - isBool(boxes.date.disableSuffix, false) - ))); - } - if (boxes.dow) { - boxes.dow.string = modString(boxes.dow, getDayOfWeek(date, isBool(boxes.dow.short, true))); - } - if (boxes.batt) { - boxes.batt.string = modString(boxes.batt, E.getBattery()); - } - if (boxes.step) { - boxes.step.string = modString(boxes.step, Bangle.getHealthStatus("day").steps); - } - boxKeys.forEach((boxKey) => { - let boxItem = boxes[boxKey]; + let g_drawString = g.drawString; + g.drawString = function(box, str, x, y) { + outlineText(box, str, x, y); + g.setColor(box.color); + g_drawString.call(g, str, x, y); + }; + let outlineText = function(box, str, x, y) { + let px = box.outline; + let dx = [-px, 0, px, -px, px, -px, 0, px]; + let dy = [-px, -px, -px, 0, 0, px, px, px]; + g.setColor(box.outlineColor); + for (let i = 0; i < dx.length; i++) { + g_drawString.call(g, str, x + dx[i], y + dy[i]); + } + }; + let calcBoxSize = function(boxItem) { + g.reset(); + g.setFontAlign(0, 0); + g.setFont(boxItem.font, boxItem.fontSize); + let strWidth = g.stringWidth(boxItem.string) + 2 * boxItem.outline; + let fontHeight = g.getFontHeight() + 2 * boxItem.outline; + totalWidth = strWidth + 2 * boxItem.xPadding; + totalHeight = fontHeight + 2 * boxItem.yPadding; + }; + let calcBoxPos = function(boxKey) { + return { + x1: boxPos[boxKey].x - totalWidth / 2, + y1: boxPos[boxKey].y - totalHeight / 2, + x2: boxPos[boxKey].x + totalWidth / 2, + y2: boxPos[boxKey].y + totalHeight / 2 + }; + }; + let displaySaveIcon = function() { + draw(boxes); + g.drawImage(saveIcon, w / 2 - 24, h / 2 - 24); + setTimeout(() => { + g.clearRect(w / 2 - 24, h / 2 - 24, w / 2 + 24, h / 2 + 24); + draw(boxes); + }, 2000); + }; + let isBool = function(val, defaultVal) { + return typeof val !== 'undefined' ? Boolean(val) : defaultVal; + }; + let getDate = function(short, shortMonth, disableSuffix) { + const date = new Date(); + const dayOfMonth = date.getDate(); + const month = shortMonth ? locale.month(date, 1) : locale.month(date, 0); + const year = date.getFullYear(); + let suffix; + if ([1, 21, 31].includes(dayOfMonth)) { + suffix = "st"; + } else if ([2, 22].includes(dayOfMonth)) { + suffix = "nd"; + } else if ([3, 23].includes(dayOfMonth)) { + suffix = "rd"; + } else { + suffix = "th"; + } + let dayOfMonthStr = disableSuffix ? dayOfMonth : dayOfMonth + suffix; + return month + " " + dayOfMonthStr + (short ? '' : (", " + year)); + }; + let getDayOfWeek = function(date, short) { + return locale.dow(date, short ? 1 : 0); + }; + locale.meridian = function(date, short) { + let hours = date.getHours(); + let meridian = hours >= 12 ? 'PM' : 'AM'; + return short ? meridian[0] : meridian; + }; + let modString = function(boxItem, data) { + let prefix = boxItem.prefix || ''; + let suffix = boxItem.suffix || ''; + return prefix + data + suffix; + }; + let draw = (function() { + let updatePerMinute = true; + return function(boxes) { + date = new Date(); + g.clear(); + background.fillRect(Bangle.appRect); + if (boxes.time) { + boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); + updatePerMinute = isBool(boxes.time.short, true); + } + if (boxes.meridian) { + boxes.meridian.string = modString(boxes.meridian, locale.meridian(date, isBool(boxes.meridian.short, true))); + } + if (boxes.date) { + boxes.date.string = (modString(boxes.date, getDate(isBool(boxes.date.short, true), isBool(boxes.date.shortMonth, true), isBool(boxes.date.disableSuffix, false)))); + } + if (boxes.dow) { + boxes.dow.string = modString(boxes.dow, getDayOfWeek(date, isBool(boxes.dow.short, true))); + } + if (boxes.batt) { + boxes.batt.string = modString(boxes.batt, E.getBattery()); + } + if (boxes.step) { + boxes.step.string = modString(boxes.step, Bangle.getHealthStatus("day").steps); + } + boxKeys.forEach((boxKey) => { + let boxItem = boxes[boxKey]; + calcBoxSize(boxItem); + const pos = calcBoxPos(boxKey); + if (isDragging[boxKey]) { + g.setColor(boxItem.border); + g.drawRect(pos.x1, pos.y1, pos.x2, pos.y2); + } + g.drawString(boxItem, boxItem.string, boxPos[boxKey].x + boxItem.xOffset, boxPos[boxKey].y + boxItem.yOffset); + }); + if (!Object.values(isDragging).some(Boolean)) { + if (drawTimeout) clearTimeout(drawTimeout); + let interval = updatePerMinute ? 60000 - (Date.now() % 60000) : 1000; + drawTimeout = setTimeout(() => draw(boxes), interval); + } + }; + })(); + let touchInText = function(e, boxItem, boxKey) { calcBoxSize(boxItem); const pos = calcBoxPos(boxKey); - if (isDragging[boxKey]) { - g.setColor(boxItem.border); - g.drawRect(pos.x1, pos.y1, pos.x2, pos.y2); - } - g.drawString( - boxItem, - boxItem.string, - boxPos[boxKey].x + boxItem.xOffset, - boxPos[boxKey].y + boxItem.yOffset - ); - }); - if (!Object.values(isDragging).some(Boolean)) { - if (drawTimeout) clearTimeout(drawTimeout); - let interval = updatePerMinute ? 60000 - (Date.now() % 60000) : 1000; - drawTimeout = setTimeout(() => draw(boxes), interval); - } + return e.x >= pos.x1 && e.x <= pos.x2 && e.y >= pos.y1 && e.y <= pos.y2; }; - })(); - - /** - * --------------------------------------------------------------- - * 9. Helper function for touch event - * --------------------------------------------------------------- - */ - - let touchInText = function(e, boxItem, boxKey) { - calcBoxSize(boxItem); - const pos = calcBoxPos(boxKey); - return e.x >= pos.x1 && - e.x <= pos.x2 && - e.y >= pos.y1 && - e.y <= pos.y2; - }; - - let deselectAllBoxes = function() { - Object.keys(isDragging).forEach((boxKey) => { - isDragging[boxKey] = false; - }); - restoreSetColor(); - widgets.show(); - widgets.swipeOn(); - modSetColor(); - }; - - /** - * --------------------------------------------------------------- - * 10. Setup function to configure event handlers - * --------------------------------------------------------------- - */ - - let setup = function() { - // ------------------------------------ - // Define the touchHandler function - // ------------------------------------ - touchHandler = function(zone, e) { - wasDragging = Object.assign({}, isDragging); - let boxTouched = false; - boxKeys.forEach((boxKey) => { - if (touchInText(e, boxes[boxKey], boxKey)) { - isDragging[boxKey] = true; - wasDragging[boxKey] = true; - boxTouched = true; - } - }); - if (!boxTouched) { - if (!Object.values(isDragging).some(Boolean)) { // check if no boxes are being dragged - deselectAllBoxes(); - if (doubleTapTimer) { - clearTimeout(doubleTapTimer); - doubleTapTimer = null; - // Save boxesConfig on double tap outside of any box and when no boxes are being dragged - Object.keys(boxPos).forEach((boxKey) => { - boxesConfig[boxKey].boxPos.x = (boxPos[boxKey].x / w).toFixed(3); - boxesConfig[boxKey].boxPos.y = (boxPos[boxKey].y / h).toFixed(3); - }); - storage.write(fileName, JSON.stringify(boxesConfig)); - displaySaveIcon(); - return; - } - } else { - // if any box is being dragged, just deselect all without saving - deselectAllBoxes(); - } - } - if (Object.values(wasDragging).some(Boolean) || !boxTouched) { - draw(boxes); - } - doubleTapTimer = setTimeout(() => { - doubleTapTimer = null; - }, 500); // Increase or decrease this value based on the desired double tap timing - movementDistance = 0; - }; - - // ------------------------------------ - // 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 - if (movementDistance > 1) { - boxKeys.forEach((boxKey) => { - if (isDragging[boxKey]) { - widgets.hide(); - let boxItem = boxes[boxKey]; - calcBoxSize(boxItem); - let newX = boxPos[boxKey].x + e.dx; - let newY = boxPos[boxKey].y + e.dy; - if (newX - totalWidth / 2 >= 0 && - newX + totalWidth / 2 <= w && - newY - totalHeight / 2 >= 0 && - newY + totalHeight / 2 <= h ) { - boxPos[boxKey].x = newX; - boxPos[boxKey].y = newY; - } - const pos = calcBoxPos(boxKey); - g.clearRect(pos.x1, pos.y1, pos.x2, pos.y2); - } + let deselectAllBoxes = function() { + Object.keys(isDragging).forEach((boxKey) => { + isDragging[boxKey] = false; }); - draw(boxes); - } - }; - - Bangle.on('touch', touchHandler); - Bangle.on('drag', dragHandler); - - Bangle.setUI({ - mode : "clock", - remove : function() { - // Remove event handlers, stop draw timer, remove custom font if used - Bangle.removeListener('touch', touchHandler); - Bangle.removeListener('drag', dragHandler); - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = undefined; - delete Graphics.prototype.setFontBrunoAce; - // Restore original drawString function (no outlines) - g.drawString = g_drawString; restoreSetColor(); widgets.show(); - } - }); - loadCustomFont(); - draw(boxes); - }; - - /** - * --------------------------------------------------------------- - * 11. Main execution part - * --------------------------------------------------------------- - */ - - Bangle.loadWidgets(); - widgets.swipeOn(); - modSetColor(); - setup(); + widgets.swipeOn(); + modSetColor(); + }; + let setup = function() { + touchHandler = function(zone, e) { + wasDragging = Object.assign({}, isDragging); + let boxTouched = false; + boxKeys.forEach((boxKey) => { + if (touchInText(e, boxes[boxKey], boxKey)) { + isDragging[boxKey] = true; + wasDragging[boxKey] = true; + boxTouched = true; + } + }); + if (!boxTouched) { + if (!Object.values(isDragging).some(Boolean)) { + deselectAllBoxes(); + if (doubleTapTimer) { + clearTimeout(doubleTapTimer); + doubleTapTimer = null; + Object.keys(boxPos).forEach((boxKey) => { + boxesConfig[boxKey].boxPos.x = (boxPos[boxKey].x / w).toFixed(3); + boxesConfig[boxKey].boxPos.y = (boxPos[boxKey].y / h).toFixed(3); + }); + storage.write(fileName, JSON.stringify(boxesConfig)); + displaySaveIcon(); + return; + } + } else { + deselectAllBoxes(); + } + } + if (Object.values(wasDragging).some(Boolean) || !boxTouched) { + draw(boxes); + } + doubleTapTimer = setTimeout(() => { + doubleTapTimer = null; + }, 500); + movementDistance = 0; + }; + dragHandler = function(e) { + if (!Object.values(isDragging).some(Boolean)) return; + movementDistance += Math.abs(e.dx) + Math.abs(e.dy); + if (movementDistance > 1) { + boxKeys.forEach((boxKey) => { + if (isDragging[boxKey]) { + widgets.hide(); + let boxItem = boxes[boxKey]; + calcBoxSize(boxItem); + let newX = boxPos[boxKey].x + e.dx; + let newY = boxPos[boxKey].y + e.dy; + if (newX - totalWidth / 2 >= 0 && newX + totalWidth / 2 <= w && newY - totalHeight / 2 >= 0 && newY + totalHeight / 2 <= h) { + boxPos[boxKey].x = newX; + boxPos[boxKey].y = newY; + } + const pos = calcBoxPos(boxKey); + g.clearRect(pos.x1, pos.y1, pos.x2, pos.y2); + } + }); + draw(boxes); + } + }; + Bangle.on('touch', touchHandler); + Bangle.on('drag', dragHandler); + Bangle.setUI({ + mode: "clock", + remove: function() { + Bangle.removeListener('touch', touchHandler); + Bangle.removeListener('drag', dragHandler); + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + delete Graphics.prototype.setFontBrunoAce; + g.drawString = g_drawString; + restoreSetColor(); + widgets.show(); + } + }); + loadCustomFont(); + draw(boxes); + }; + Bangle.loadWidgets(); + widgets.swipeOn(); + modSetColor(); + setup(); } From 1a7e4c8e70b9c3a27caff7c0af4d9be376dbbb77 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:51:10 -0700 Subject: [PATCH 37/46] Update app.js --- apps/8ball/app.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/8ball/app.js b/apps/8ball/app.js index 5a15e5bca..59f243f80 100644 --- a/apps/8ball/app.js +++ b/apps/8ball/app.js @@ -27,7 +27,7 @@ function menu() E.showMenu(); menuOpen = 1; E.showMenu({ - "" : { title : /*LANG*/Name }, + "" : { title : Name }, "< Back" : () => menu(), "Start" : () => { E.showMenu(); @@ -36,7 +36,7 @@ function menu() Drawtext("ask " + Name + " a yes or no question"); }, "regenerate name" : () => { - E.showMenu(); + menu(); generateName(); }, "show answers" : () => { @@ -51,17 +51,19 @@ function menu() "Add answer" : () => { E.showMenu(); - var result = keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();}); + keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();}); }, "Edit name" : () => { E.showMenu(); - var result = keyboard.input({}).then(result => {menu(), Name = result;}); + keyboard.input({}).then(result => {if(result != ""){Name = result;} menu();}); + }, "Exit" : () => load(), }); } menu(); -var answer; + + var answer; function Drawtext(text) { g.clear(); @@ -82,7 +84,6 @@ function WriteAnswer() } } - setWatch(function() { menu(); From d6503cfdd80185d8c7b2785ab91e3b674ff9d179 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:51:49 -0700 Subject: [PATCH 38/46] Update app.js --- apps/boxclk/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 8c29aac14..df3457a09 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -165,7 +165,6 @@ Modules.addCached("widget_utils", function() { }; for (let key in boxesConfig) { if (key === 'bg' && boxesConfig[key].img) { - bgImage = storage.read(boxesConfig[key].img); } else if (key !== 'selectedConfig') { boxes[key] = Object.assign({}, boxesConfig[key]); } From f5b91c1bdd0027912623ff334df65d07eb69bebf Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:59:48 -0700 Subject: [PATCH 39/46] Update app.js --- apps/boxclk/app.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index df3457a09..ed8a62b65 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -163,12 +163,6 @@ Modules.addCached("widget_utils", function() { return this.setFontCustom(E.toString(require('heatshrink').decompress(atob('ABMHwADBh4DKg4bKgIPDAYUfAYV/AYX/AQMD/gmC+ADBn/AByE/GIU8AYUwLxcfAYX/8AnB//4JIP/FgMP4F+CQQBBjwJBFYRbBAd43DHoJpBh/g/xPEK4ZfDgEEORKDDAY8////wADLfZrTCgITBnhEBAYJMBAYMPw4DCM4QDjhwDCjwDBn0+AYMf/gDBh/4AYMH+ADBLpc4ToK/NGYZfnAYcfL4U/x5fBW4LvB/7vC+LvBgHAsBfIn76Cn4WBcYQDFEgJ+CQQYDyH4L/BAZbHLNYjjCAZc8ngDunycBZ4KkBa4KwBnEHY4UB+BfMgf/ZgMH/4XBc4cf4F/gE+ZgRjwAYcfj5jBM4U4M4RQBM4UA8BjIngDFEYJ8BAYUDAYQvCM4ZxBC4V+AYQvBnkBQ4M8gabBJQPAI4WAAYM/GYQaBAYJKCnqyCn5OCn4aBAYIaBAYJPCU4IABnBhIuDXCFAMD+Z/BY4IDBQwOPwEfv6TDAYUPAcwrDAYQ7BAYY/BI4cD8bLCK4RfEAA0BRYTeDcwIrFn0Pw43Bg4DugYDBjxBBU4SvDMYMH/5QBgP/LAQAP8EHN4UPwADHB4YAHA'))), 46, atob("CBEdChgYGhgaGBsaCQ=="), 32 | 65536); }; }; - for (let key in boxesConfig) { - if (key === 'bg' && boxesConfig[key].img) { - } else if (key !== 'selectedConfig') { - boxes[key] = Object.assign({}, boxesConfig[key]); - } - } let boxKeys = Object.keys(boxes); boxKeys.forEach((key) => { let boxConfig = boxes[key]; From df89c22a006fe875e00f90543afa1cc79381cd22 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:14:39 -0700 Subject: [PATCH 41/46] Update app.js --- apps/boxclk/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index ed8a62b65..c47f700b0 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -167,8 +167,8 @@ Modules.addCached("widget_utils", function() { boxKeys.forEach((key) => { let boxConfig = boxes[key]; boxPos[key] = { - x: w * boxConfig.boxPos.x, - y: h * boxConfig.boxPos.y + let background = require("clockbg"); + Modules.addCached("widget_utils", function() { }; isDragging[key] = false; wasDragging[key] = false; From e06a8d73fbdb580e160d34fd4f21fc8b889501f6 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:21:58 -0700 Subject: [PATCH 42/46] Update app.js --- apps/8ball/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/8ball/app.js b/apps/8ball/app.js index 59f243f80..8a3ee427e 100644 --- a/apps/8ball/app.js +++ b/apps/8ball/app.js @@ -1,4 +1,4 @@ -try {keyboard = require(keyboard);} catch(e) {keyboard = null;}var keyboard = "textinput"; +var keyboard = "textinput"; var Name = ""; Bangle.setLCDTimeout(0); var menuOpen = 1; From ccee0c647d2a7b39c8708afefbdaee7faebbb118 Mon Sep 17 00:00:00 2001 From: only-meeps <151784194+only-meeps@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:27:01 -0700 Subject: [PATCH 43/46] Update app.js --- apps/boxclk/app.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index c47f700b0..73f4113c0 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -167,8 +167,6 @@ Modules.addCached("widget_utils", function() { boxKeys.forEach((key) => { let boxConfig = boxes[key]; boxPos[key] = { - let background = require("clockbg"); - Modules.addCached("widget_utils", function() { }; isDragging[key] = false; wasDragging[key] = false; From 8de98708504bd9d46e73cae65353e1e65b51841d Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 5 Aug 2024 19:59:24 +0100 Subject: [PATCH 44/46] Revert changes from IDE --- apps/boxclk/app.js | 786 +++++++++++++++++++++++---------------------- 1 file changed, 395 insertions(+), 391 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 73f4113c0..83716fd90 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -1,400 +1,404 @@ -let background = require("clockbg"); -Modules.addCached("widget_utils", function() { - exports.hide = function() { - exports.cleanup(); - if (!global.WIDGETS) return; - g.reset(); - for (var w of global.WIDGETS) { - if (w._draw) return; - w._draw = w.draw; - w.draw = () => {}; - w._area = w.area; - w.area = ""; - if (w.x != undefined) g.clearRect(w.x, w.y, w.x + w.width - 1, w.y + 23); - } - }; - exports.show = function() { - exports.cleanup(); - if (!global.WIDGETS) return; - for (var w of global.WIDGETS) { - if (!w._draw) return; - w.draw = w._draw; - w.area = w._area; - delete w._draw; - delete w._area; - w.draw(w); - } - }; - exports.cleanup = function() { - delete exports.autohide; - delete Bangle.appRect; - if (exports.swipeHandler) { - Bangle.removeListener("swipe", exports.swipeHandler); - delete exports.swipeHandler; - } - if (exports.animInterval) { - clearInterval(exports.animInterval); - delete exports.animInterval; - } - if (exports.hideTimeout) { - clearTimeout(exports.hideTimeout); - delete exports.hideTimeout; - } - if (exports.origDraw) { - Bangle.drawWidgets = exports.origDraw; - delete exports.origDraw; - } - } - exports.swipeOn = function(autohide) { - if (process.env.HWVERSION !== 2) return exports.hide(); - exports.cleanup(); - if (!global.WIDGETS) return; - exports.autohide = autohide === undefined ? 2000 : autohide; - Bangle.appRect = { - x: 0, - y: 0, - w: g.getWidth(), - h: g.getHeight(), - x2: g.getWidth() - 1, - y2: g.getHeight() - 1 - }; - let og = Graphics.createArrayBuffer(g.getWidth(), 26, 16, { - msb: true - }); - og.theme = g.theme; - og._reset = og.reset; - og.reset = function() { - return this._reset().setColor(g.theme.fg).setBgColor(g.theme.bg); - }; - og.reset().clearRect(0, 0, og.getWidth(), 23).fillRect(0, 24, og.getWidth(), 25); - let _g = g; - let offset = -24; - - function queueDraw() { - Bangle.appRect.y = offset + 24; - Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y; - if (offset > -24) Bangle.setLCDOverlay(og, 0, offset); - else Bangle.setLCDOverlay(); - } - for (var w of global.WIDGETS) { - if (w._draw) continue; - w._draw = w.draw; - w.draw = function() { - g = og; - this._draw(this); - g = _g; - if (offset > -24) queueDraw(); - }; - w._area = w.area; - if (w.area.startsWith("b")) w.area = "t" + w.area.substr(1); - } - exports.origDraw = Bangle.drawWidgets; - Bangle.drawWidgets = () => { - g = og; - exports.origDraw(); - g = _g; - }; - - function anim(dir, callback) { - if (exports.animInterval) clearInterval(exports.interval); - exports.animInterval = setInterval(function() { - offset += dir; - let stop = false; - if (dir > 0 && offset >= 0) { - stop = true; - offset = 0; - } else if (dir < 0 && offset < -23) { - stop = true; - offset = -24; - } - if (stop) { - clearInterval(exports.animInterval); - delete exports.animInterval; - if (callback) callback(); - } - queueDraw(); - }, 50); - } - exports.swipeHandler = function(lr, ud) { - if (exports.hideTimeout) { - clearTimeout(exports.hideTimeout); - delete exports.hideTimeout; - } - let cb; - if (exports.autohide > 0) cb = function() { - exports.hideTimeout = setTimeout(function() { - anim(-4); - }, exports.autohide); - } - if (ud > 0 && offset < 0) anim(4, cb); - if (ud < 0 && offset > -24) anim(-4); - }; - Bangle.on("swipe", exports.swipeHandler); - Bangle.drawWidgets(); - }; -}); { - let storage = require("Storage"); - let locale = require("locale"); - let widgets = require("widget_utils"); - let date = new Date(); - let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0; - let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json'; - if (!storage.read(fileName)) { - fileName = 'boxclk.json'; + /** + * --------------------------------------------------------------- + * 1. Module dependencies and initial configurations + * --------------------------------------------------------------- + */ + + let storage = require("Storage"); + let locale = require("locale"); + let widgets = require("widget_utils"); + let date = new Date(); + let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0; + let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json'; + // Add a condition to check if the file exists, if it does not, default to 'boxclk.json' + if (!storage.read(fileName)) { + fileName = 'boxclk.json'; + } + let boxesConfig = storage.readJSON(fileName, 1) || {}; + let boxes = {}; + let boxPos = {}; + let isDragging = {}; + let wasDragging = {}; + let doubleTapTimer = null; + let g_setColor; + + let saveIcon = require("heatshrink").decompress(atob("mEwwkEogA/AHdP/4AK+gWVDBQWNAAIuVGBAIB+UQdhMfGBAHBCxUAgIXHIwPyCxQwEJAgXB+MAl/zBwQGBn8ggQjBGAQXG+EA/4XI/8gBIQXTGAMPC6n/C6HzkREBC6YACC6QAFC57aHCYIXOOgLsEn4XPABIX/C6vykQAEl6/WgCQBC5imFAAT2BC5gCBI4oUCC5x0IC/4X/C4K8Bl4XJ+TCCC4wKBABkvC4tEEoMQCxcBB4IWEC4XyDBUBFwIXGJAIAOIwowDABoWGGB4uHDBwWJAH4AzA")); + + /** + * --------------------------------------------------------------- + * 2. Graphical and visual configurations + * --------------------------------------------------------------- + */ + + let w = g.getWidth(); + let h = g.getHeight(); + let totalWidth, totalHeight; + let drawTimeout; + + /** + * --------------------------------------------------------------- + * 3. Touchscreen Handlers + * --------------------------------------------------------------- + */ + + let touchHandler; + let dragHandler; + let movementDistance = 0; + + /** + * --------------------------------------------------------------- + * 4. Font loading function + * --------------------------------------------------------------- + */ + + let loadCustomFont = function() { + Graphics.prototype.setFontBrunoAce = function() { + // Actual height 23 (24 - 2) + return this.setFontCustom( + E.toString(require('heatshrink').decompress(atob('ABMHwADBh4DKg4bKgIPDAYUfAYV/AYX/AQMD/gmC+ADBn/AByE/GIU8AYUwLxcfAYX/8AnB//4JIP/FgMP4F+CQQBBjwJBFYRbBAd43DHoJpBh/g/xPEK4ZfDgEEORKDDAY8////wADLfZrTCgITBnhEBAYJMBAYMPw4DCM4QDjhwDCjwDBn0+AYMf/gDBh/4AYMH+ADBLpc4ToK/NGYZfnAYcfL4U/x5fBW4LvB/7vC+LvBgHAsBfIn76Cn4WBcYQDFEgJ+CQQYDyH4L/BAZbHLNYjjCAZc8ngDunycBZ4KkBa4KwBnEHY4UB+BfMgf/ZgMH/4XBc4cf4F/gE+ZgRjwAYcfj5jBM4U4M4RQBM4UA8BjIngDFEYJ8BAYUDAYQvCM4ZxBC4V+AYQvBnkBQ4M8gabBJQPAI4WAAYM/GYQaBAYJKCnqyCn5OCn4aBAYIaBAYJPCU4IABnBhIuDXCFAMD+Z/BY4IDBQwOPwEfv6TDAYUPAcwrDAYQ7BAYY/BI4cD8bLCK4RfEAA0BRYTeDcwIrFn0Pw43Bg4DugYDBjxBBU4SvDMYMH/5QBgP/LAQAP8EHN4UPwADHB4YAHA'))), + 46, + atob("CBEdChgYGhgaGBsaCQ=="), + 32|65536 + ); + }; + }; + + /** + * --------------------------------------------------------------- + * 5. Initial settings of boxes and their positions + * --------------------------------------------------------------- + */ + + let boxKeys = Object.keys(boxes); + + boxKeys.forEach((key) => { + let boxConfig = boxes[key]; + boxPos[key] = { + }; + isDragging[key] = false; + wasDragging[key] = false; + }); + + /** + * --------------------------------------------------------------- + * 6. Text and drawing functions + * --------------------------------------------------------------- + */ + + // Overwrite the setColor function to allow the + // use of (x) in g.theme.x as a string + // in your JSON config ("fg", "bg", "fg2", "bg2", "fgH", "bgH") + let modSetColor = function() { + // Save the original setColor function + g_setColor = g.setColor; + // Overwrite setColor with the new function + g.setColor = function(color) { + if (typeof color === "string" && color in g.theme) { + g_setColor.call(g, g.theme[color]); + } else { + g_setColor.call(g, color); + } + }; + }; + + let restoreSetColor = function() { + // Restore the original setColor function + if (g_setColor) { + g.setColor = g_setColor; } - let boxesConfig = storage.readJSON(fileName, 1) || {}; - let boxes = {}; - let boxPos = {}; - let isDragging = {}; - let wasDragging = {}; - let doubleTapTimer = null; - let g_setColor; - let saveIcon = require("heatshrink").decompress(atob("mEwwkEogA/AHdP/4AK+gWVDBQWNAAIuVGBAIB+UQdhMfGBAHBCxUAgIXHIwPyCxQwEJAgXB+MAl/zBwQGBn8ggQjBGAQXG+EA/4XI/8gBIQXTGAMPC6n/C6HzkREBC6YACC6QAFC57aHCYIXOOgLsEn4XPABIX/C6vykQAEl6/WgCQBC5imFAAT2BC5gCBI4oUCC5x0IC/4X/C4K8Bl4XJ+TCCC4wKBABkvC4tEEoMQCxcBB4IWEC4XyDBUBFwIXGJAIAOIwowDABoWGGB4uHDBwWJAH4AzA")); - let w = g.getWidth(); - let h = g.getHeight(); - let totalWidth, totalHeight; - let drawTimeout; - let touchHandler; - let dragHandler; - let movementDistance = 0; - let loadCustomFont = function() { - Graphics.prototype.setFontBrunoAce = function() { - return this.setFontCustom(E.toString(require('heatshrink').decompress(atob('ABMHwADBh4DKg4bKgIPDAYUfAYV/AYX/AQMD/gmC+ADBn/AByE/GIU8AYUwLxcfAYX/8AnB//4JIP/FgMP4F+CQQBBjwJBFYRbBAd43DHoJpBh/g/xPEK4ZfDgEEORKDDAY8////wADLfZrTCgITBnhEBAYJMBAYMPw4DCM4QDjhwDCjwDBn0+AYMf/gDBh/4AYMH+ADBLpc4ToK/NGYZfnAYcfL4U/x5fBW4LvB/7vC+LvBgHAsBfIn76Cn4WBcYQDFEgJ+CQQYDyH4L/BAZbHLNYjjCAZc8ngDunycBZ4KkBa4KwBnEHY4UB+BfMgf/ZgMH/4XBc4cf4F/gE+ZgRjwAYcfj5jBM4U4M4RQBM4UA8BjIngDFEYJ8BAYUDAYQvCM4ZxBC4V+AYQvBnkBQ4M8gabBJQPAI4WAAYM/GYQaBAYJKCnqyCn5OCn4aBAYIaBAYJPCU4IABnBhIuDXCFAMD+Z/BY4IDBQwOPwEfv6TDAYUPAcwrDAYQ7BAYY/BI4cD8bLCK4RfEAA0BRYTeDcwIrFn0Pw43Bg4DugYDBjxBBU4SvDMYMH/5QBgP/LAQAP8EHN4UPwADHB4YAHA'))), 46, atob("CBEdChgYGhgaGBsaCQ=="), 32 | 65536); - }; + }; + + // Overwrite the drawString function + let g_drawString = g.drawString; + g.drawString = function(box, str, x, y) { + outlineText(box, str, x, y); + g.setColor(box.color); + g_drawString.call(g, str, x, y); + }; + + let outlineText = function(box, str, x, y) { + let px = box.outline; + let dx = [-px, 0, px, -px, px, -px, 0, px]; + let dy = [-px, -px, -px, 0, 0, px, px, px]; + g.setColor(box.outlineColor); + for (let i = 0; i < dx.length; i++) { + g_drawString.call(g, str, x + dx[i], y + dy[i]); + } + }; + + let calcBoxSize = function(boxItem) { + g.reset(); + g.setFontAlign(0,0); + g.setFont(boxItem.font, boxItem.fontSize); + let strWidth = g.stringWidth(boxItem.string) + 2 * boxItem.outline; + let fontHeight = g.getFontHeight() + 2 * boxItem.outline; + totalWidth = strWidth + 2 * boxItem.xPadding; + totalHeight = fontHeight + 2 * boxItem.yPadding; + }; + + let calcBoxPos = function(boxKey) { + return { + x1: boxPos[boxKey].x - totalWidth / 2, + y1: boxPos[boxKey].y - totalHeight / 2, + x2: boxPos[boxKey].x + totalWidth / 2, + y2: boxPos[boxKey].y + totalHeight / 2 }; - let boxKeys = Object.keys(boxes); - boxKeys.forEach((key) => { - let boxConfig = boxes[key]; - boxPos[key] = { - }; - isDragging[key] = false; - wasDragging[key] = false; - }); - let modSetColor = function() { - g_setColor = g.setColor; - g.setColor = function(color) { - if (typeof color === "string" && color in g.theme) { - g_setColor.call(g, g.theme[color]); - } else { - g_setColor.call(g, color); - } - }; - }; - let restoreSetColor = function() { - if (g_setColor) { - g.setColor = g_setColor; - } - }; - let g_drawString = g.drawString; - g.drawString = function(box, str, x, y) { - outlineText(box, str, x, y); - g.setColor(box.color); - g_drawString.call(g, str, x, y); - }; - let outlineText = function(box, str, x, y) { - let px = box.outline; - let dx = [-px, 0, px, -px, px, -px, 0, px]; - let dy = [-px, -px, -px, 0, 0, px, px, px]; - g.setColor(box.outlineColor); - for (let i = 0; i < dx.length; i++) { - g_drawString.call(g, str, x + dx[i], y + dy[i]); - } - }; - let calcBoxSize = function(boxItem) { - g.reset(); - g.setFontAlign(0, 0); - g.setFont(boxItem.font, boxItem.fontSize); - let strWidth = g.stringWidth(boxItem.string) + 2 * boxItem.outline; - let fontHeight = g.getFontHeight() + 2 * boxItem.outline; - totalWidth = strWidth + 2 * boxItem.xPadding; - totalHeight = fontHeight + 2 * boxItem.yPadding; - }; - let calcBoxPos = function(boxKey) { - return { - x1: boxPos[boxKey].x - totalWidth / 2, - y1: boxPos[boxKey].y - totalHeight / 2, - x2: boxPos[boxKey].x + totalWidth / 2, - y2: boxPos[boxKey].y + totalHeight / 2 - }; - }; - let displaySaveIcon = function() { - draw(boxes); - g.drawImage(saveIcon, w / 2 - 24, h / 2 - 24); - setTimeout(() => { - g.clearRect(w / 2 - 24, h / 2 - 24, w / 2 + 24, h / 2 + 24); - draw(boxes); - }, 2000); - }; - let isBool = function(val, defaultVal) { - return typeof val !== 'undefined' ? Boolean(val) : defaultVal; - }; - let getDate = function(short, shortMonth, disableSuffix) { - const date = new Date(); - const dayOfMonth = date.getDate(); - const month = shortMonth ? locale.month(date, 1) : locale.month(date, 0); - const year = date.getFullYear(); - let suffix; - if ([1, 21, 31].includes(dayOfMonth)) { - suffix = "st"; - } else if ([2, 22].includes(dayOfMonth)) { - suffix = "nd"; - } else if ([3, 23].includes(dayOfMonth)) { - suffix = "rd"; - } else { - suffix = "th"; - } - let dayOfMonthStr = disableSuffix ? dayOfMonth : dayOfMonth + suffix; - return month + " " + dayOfMonthStr + (short ? '' : (", " + year)); - }; - let getDayOfWeek = function(date, short) { - return locale.dow(date, short ? 1 : 0); - }; - locale.meridian = function(date, short) { - let hours = date.getHours(); - let meridian = hours >= 12 ? 'PM' : 'AM'; - return short ? meridian[0] : meridian; - }; - let modString = function(boxItem, data) { - let prefix = boxItem.prefix || ''; - let suffix = boxItem.suffix || ''; - return prefix + data + suffix; - }; - let draw = (function() { - let updatePerMinute = true; - return function(boxes) { - date = new Date(); - g.clear(); - background.fillRect(Bangle.appRect); - if (boxes.time) { - boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); - updatePerMinute = isBool(boxes.time.short, true); - } - if (boxes.meridian) { - boxes.meridian.string = modString(boxes.meridian, locale.meridian(date, isBool(boxes.meridian.short, true))); - } - if (boxes.date) { - boxes.date.string = (modString(boxes.date, getDate(isBool(boxes.date.short, true), isBool(boxes.date.shortMonth, true), isBool(boxes.date.disableSuffix, false)))); - } - if (boxes.dow) { - boxes.dow.string = modString(boxes.dow, getDayOfWeek(date, isBool(boxes.dow.short, true))); - } - if (boxes.batt) { - boxes.batt.string = modString(boxes.batt, E.getBattery()); - } - if (boxes.step) { - boxes.step.string = modString(boxes.step, Bangle.getHealthStatus("day").steps); - } - boxKeys.forEach((boxKey) => { - let boxItem = boxes[boxKey]; - calcBoxSize(boxItem); - const pos = calcBoxPos(boxKey); - if (isDragging[boxKey]) { - g.setColor(boxItem.border); - g.drawRect(pos.x1, pos.y1, pos.x2, pos.y2); - } - g.drawString(boxItem, boxItem.string, boxPos[boxKey].x + boxItem.xOffset, boxPos[boxKey].y + boxItem.yOffset); - }); - if (!Object.values(isDragging).some(Boolean)) { - if (drawTimeout) clearTimeout(drawTimeout); - let interval = updatePerMinute ? 60000 - (Date.now() % 60000) : 1000; - drawTimeout = setTimeout(() => draw(boxes), interval); - } - }; - })(); - let touchInText = function(e, boxItem, boxKey) { + }; + + let displaySaveIcon = function() { + draw(boxes); + g.drawImage(saveIcon, w / 2 - 24, h / 2 - 24); + // Display save icon for 2 seconds + setTimeout(() => { + g.clearRect(w / 2 - 24, h / 2 - 24, w / 2 + 24, h / 2 + 24); + draw(boxes); + }, 2000); + }; + + /** + * --------------------------------------------------------------- + * 7. String forming helper functions + * --------------------------------------------------------------- + */ + + let isBool = function(val, defaultVal) { + return typeof val !== 'undefined' ? Boolean(val) : defaultVal; + }; + + let getDate = function(short, shortMonth, disableSuffix) { + const date = new Date(); + const dayOfMonth = date.getDate(); + const month = shortMonth ? locale.month(date, 1) : locale.month(date, 0); + const year = date.getFullYear(); + let suffix; + if ([1, 21, 31].includes(dayOfMonth)) { + suffix = "st"; + } else if ([2, 22].includes(dayOfMonth)) { + suffix = "nd"; + } else if ([3, 23].includes(dayOfMonth)) { + suffix = "rd"; + } else { + suffix = "th"; + } + let dayOfMonthStr = disableSuffix ? dayOfMonth : dayOfMonth + suffix; + return month + " " + dayOfMonthStr + (short ? '' : (", " + year)); // not including year for short version + }; + + let getDayOfWeek = function(date, short) { + return locale.dow(date, short ? 1 : 0); + }; + + locale.meridian = function(date, short) { + let hours = date.getHours(); + let meridian = hours >= 12 ? 'PM' : 'AM'; + return short ? meridian[0] : meridian; + }; + + let modString = function(boxItem, data) { + let prefix = boxItem.prefix || ''; + let suffix = boxItem.suffix || ''; + return prefix + data + suffix; + }; + + /** + * --------------------------------------------------------------- + * 8. Main draw function + * --------------------------------------------------------------- + */ + + let draw = (function() { + let updatePerMinute = true; // variable to track the state of time display + + return function(boxes) { + date = new Date(); + g.clear(); + if (bgImage) { + g.drawImage(bgImage, 0, 0); + } + if (boxes.time) { + boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); + updatePerMinute = isBool(boxes.time.short, true); + } + if (boxes.meridian) { + boxes.meridian.string = modString(boxes.meridian, locale.meridian(date, isBool(boxes.meridian.short, true))); + } + if (boxes.date) { + boxes.date.string = ( + modString(boxes.date, + getDate(isBool(boxes.date.short, true), + isBool(boxes.date.shortMonth, true), + isBool(boxes.date.disableSuffix, false) + ))); + } + if (boxes.dow) { + boxes.dow.string = modString(boxes.dow, getDayOfWeek(date, isBool(boxes.dow.short, true))); + } + if (boxes.batt) { + boxes.batt.string = modString(boxes.batt, E.getBattery()); + } + if (boxes.step) { + boxes.step.string = modString(boxes.step, Bangle.getHealthStatus("day").steps); + } + boxKeys.forEach((boxKey) => { + let boxItem = boxes[boxKey]; calcBoxSize(boxItem); const pos = calcBoxPos(boxKey); - return e.x >= pos.x1 && e.x <= pos.x2 && e.y >= pos.y1 && e.y <= pos.y2; + if (isDragging[boxKey]) { + g.setColor(boxItem.border); + g.drawRect(pos.x1, pos.y1, pos.x2, pos.y2); + } + g.drawString( + boxItem, + boxItem.string, + boxPos[boxKey].x + boxItem.xOffset, + boxPos[boxKey].y + boxItem.yOffset + ); + }); + if (!Object.values(isDragging).some(Boolean)) { + if (drawTimeout) clearTimeout(drawTimeout); + let interval = updatePerMinute ? 60000 - (Date.now() % 60000) : 1000; + drawTimeout = setTimeout(() => draw(boxes), interval); + } }; - let deselectAllBoxes = function() { - Object.keys(isDragging).forEach((boxKey) => { - isDragging[boxKey] = false; - }); - restoreSetColor(); - widgets.show(); - widgets.swipeOn(); - modSetColor(); - }; - let setup = function() { - touchHandler = function(zone, e) { - wasDragging = Object.assign({}, isDragging); - let boxTouched = false; - boxKeys.forEach((boxKey) => { - if (touchInText(e, boxes[boxKey], boxKey)) { - isDragging[boxKey] = true; - wasDragging[boxKey] = true; - boxTouched = true; - } - }); - if (!boxTouched) { - if (!Object.values(isDragging).some(Boolean)) { - deselectAllBoxes(); - if (doubleTapTimer) { - clearTimeout(doubleTapTimer); - doubleTapTimer = null; - Object.keys(boxPos).forEach((boxKey) => { - boxesConfig[boxKey].boxPos.x = (boxPos[boxKey].x / w).toFixed(3); - boxesConfig[boxKey].boxPos.y = (boxPos[boxKey].y / h).toFixed(3); - }); - storage.write(fileName, JSON.stringify(boxesConfig)); - displaySaveIcon(); - return; - } - } else { - deselectAllBoxes(); - } - } - if (Object.values(wasDragging).some(Boolean) || !boxTouched) { - draw(boxes); - } - doubleTapTimer = setTimeout(() => { - doubleTapTimer = null; - }, 500); - movementDistance = 0; - }; - dragHandler = function(e) { - if (!Object.values(isDragging).some(Boolean)) return; - movementDistance += Math.abs(e.dx) + Math.abs(e.dy); - if (movementDistance > 1) { - boxKeys.forEach((boxKey) => { - if (isDragging[boxKey]) { - widgets.hide(); - let boxItem = boxes[boxKey]; - calcBoxSize(boxItem); - let newX = boxPos[boxKey].x + e.dx; - let newY = boxPos[boxKey].y + e.dy; - if (newX - totalWidth / 2 >= 0 && newX + totalWidth / 2 <= w && newY - totalHeight / 2 >= 0 && newY + totalHeight / 2 <= h) { - boxPos[boxKey].x = newX; - boxPos[boxKey].y = newY; - } - const pos = calcBoxPos(boxKey); - g.clearRect(pos.x1, pos.y1, pos.x2, pos.y2); - } - }); - draw(boxes); - } - }; - Bangle.on('touch', touchHandler); - Bangle.on('drag', dragHandler); - Bangle.setUI({ - mode: "clock", - remove: function() { - Bangle.removeListener('touch', touchHandler); - Bangle.removeListener('drag', dragHandler); - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = undefined; - delete Graphics.prototype.setFontBrunoAce; - g.drawString = g_drawString; - restoreSetColor(); - widgets.show(); - } - }); - loadCustomFont(); - draw(boxes); - }; - Bangle.loadWidgets(); + })(); + + /** + * --------------------------------------------------------------- + * 9. Helper function for touch event + * --------------------------------------------------------------- + */ + + let touchInText = function(e, boxItem, boxKey) { + calcBoxSize(boxItem); + const pos = calcBoxPos(boxKey); + return e.x >= pos.x1 && + e.x <= pos.x2 && + e.y >= pos.y1 && + e.y <= pos.y2; + }; + + let deselectAllBoxes = function() { + Object.keys(isDragging).forEach((boxKey) => { + isDragging[boxKey] = false; + }); + restoreSetColor(); + widgets.show(); widgets.swipeOn(); modSetColor(); - setup(); + }; + + /** + * --------------------------------------------------------------- + * 10. Setup function to configure event handlers + * --------------------------------------------------------------- + */ + + let setup = function() { + // ------------------------------------ + // Define the touchHandler function + // ------------------------------------ + touchHandler = function(zone, e) { + wasDragging = Object.assign({}, isDragging); + let boxTouched = false; + boxKeys.forEach((boxKey) => { + if (touchInText(e, boxes[boxKey], boxKey)) { + isDragging[boxKey] = true; + wasDragging[boxKey] = true; + boxTouched = true; + } + }); + if (!boxTouched) { + if (!Object.values(isDragging).some(Boolean)) { // check if no boxes are being dragged + deselectAllBoxes(); + if (doubleTapTimer) { + clearTimeout(doubleTapTimer); + doubleTapTimer = null; + // Save boxesConfig on double tap outside of any box and when no boxes are being dragged + Object.keys(boxPos).forEach((boxKey) => { + boxesConfig[boxKey].boxPos.x = (boxPos[boxKey].x / w).toFixed(3); + boxesConfig[boxKey].boxPos.y = (boxPos[boxKey].y / h).toFixed(3); + }); + storage.write(fileName, JSON.stringify(boxesConfig)); + displaySaveIcon(); + return; + } + } else { + // if any box is being dragged, just deselect all without saving + deselectAllBoxes(); + } + } + if (Object.values(wasDragging).some(Boolean) || !boxTouched) { + draw(boxes); + } + doubleTapTimer = setTimeout(() => { + doubleTapTimer = null; + }, 500); // Increase or decrease this value based on the desired double tap timing + movementDistance = 0; + }; + + // ------------------------------------ + // 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 + if (movementDistance > 1) { + boxKeys.forEach((boxKey) => { + if (isDragging[boxKey]) { + widgets.hide(); + let boxItem = boxes[boxKey]; + calcBoxSize(boxItem); + let newX = boxPos[boxKey].x + e.dx; + let newY = boxPos[boxKey].y + e.dy; + if (newX - totalWidth / 2 >= 0 && + newX + totalWidth / 2 <= w && + newY - totalHeight / 2 >= 0 && + newY + totalHeight / 2 <= h ) { + boxPos[boxKey].x = newX; + boxPos[boxKey].y = newY; + } + const pos = calcBoxPos(boxKey); + g.clearRect(pos.x1, pos.y1, pos.x2, pos.y2); + } + }); + draw(boxes); + } + }; + + Bangle.on('touch', touchHandler); + Bangle.on('drag', dragHandler); + + Bangle.setUI({ + mode : "clock", + remove : function() { + // Remove event handlers, stop draw timer, remove custom font if used + Bangle.removeListener('touch', touchHandler); + Bangle.removeListener('drag', dragHandler); + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + delete Graphics.prototype.setFontBrunoAce; + // Restore original drawString function (no outlines) + g.drawString = g_drawString; + restoreSetColor(); + widgets.show(); + } + }); + loadCustomFont(); + draw(boxes); + }; + + /** + * --------------------------------------------------------------- + * 11. Main execution part + * --------------------------------------------------------------- + */ + + Bangle.loadWidgets(); + widgets.swipeOn(); + modSetColor(); + setup(); } From 438c3b83c8414a23fc2abbdaf9e6a3141347b613 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 5 Aug 2024 19:59:44 +0100 Subject: [PATCH 45/46] Revert dropped code --- apps/boxclk/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 83716fd90..cf2e46df3 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -75,6 +75,8 @@ boxKeys.forEach((key) => { let boxConfig = boxes[key]; boxPos[key] = { + x: w * boxConfig.boxPos.x, + y: h * boxConfig.boxPos.y }; isDragging[key] = false; wasDragging[key] = false; From 2c4e52d720051eb958d101fd9d219e8182532a69 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 5 Aug 2024 19:59:57 +0100 Subject: [PATCH 46/46] Apply background/clockbg --- apps/boxclk/app.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index cf2e46df3..548062349 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -5,6 +5,7 @@ * --------------------------------------------------------------- */ + let background = require("clockbg"); let storage = require("Storage"); let locale = require("locale"); let widgets = require("widget_utils"); @@ -215,9 +216,7 @@ return function(boxes) { date = new Date(); g.clear(); - if (bgImage) { - g.drawImage(bgImage, 0, 0); - } + background.fillRect(Bangle.appRect); if (boxes.time) { boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); updatePerMinute = isBool(boxes.time.short, true);