diff --git a/apps/boxclk/ChangeLog b/apps/boxclk/ChangeLog index b78eba44c..f7ee41904 100644 --- a/apps/boxclk/ChangeLog +++ b/apps/boxclk/ChangeLog @@ -3,4 +3,5 @@ 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 +0.06: Added clockbackground app functionality +0.07: Allow custom backgrounds per boxclk config and from the clockbg module diff --git a/apps/boxclk/app.js b/apps/boxclk/app.js index 548062349..61edfde7b 100644 --- a/apps/boxclk/app.js +++ b/apps/boxclk/app.js @@ -10,6 +10,7 @@ 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' @@ -71,6 +72,14 @@ * --------------------------------------------------------------- */ + 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) => { @@ -211,14 +220,21 @@ */ let draw = (function() { - let updatePerMinute = true; // variable to track the state of time display + let updatePerMinute = true; return function(boxes) { date = new Date(); g.clear(); - background.fillRect(Bangle.appRect); + + // Always draw background for full screen + if (bgImage) { + g.drawImage(bgImage, 0, 0); + } else { + background.fillRect(0, 0, g.getWidth(), g.getHeight()); + } + if (boxes.time) { - boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0)); + boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0).trim()); updatePerMinute = isBool(boxes.time.short, true); } if (boxes.meridian) { diff --git a/apps/boxclk/boxclk.space.img b/apps/boxclk/boxclk.space.img new file mode 100644 index 000000000..1708b5c24 Binary files /dev/null and b/apps/boxclk/boxclk.space.img differ diff --git a/apps/boxclk/screenshot-2.png b/apps/boxclk/screenshot-2.png index b7a73d66a..568a310b9 100644 Binary files a/apps/boxclk/screenshot-2.png and b/apps/boxclk/screenshot-2.png differ