Skip to content

Commit

Permalink
Merge pull request #2837 from stweedo/boxclk
Browse files Browse the repository at this point in the history
[boxclk] - v0.04 Update
  • Loading branch information
gfwilliams committed Jun 26, 2023
2 parents b4ef227 + b52220a commit 2ac8660
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/boxclk/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.01: New App!
0.02: New config options such as step, meridian, short/long formats, custom prefix/suffix
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
12 changes: 12 additions & 0 deletions apps/boxclk/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 1. Module dependencies and initial configurations
* ---------------------------------------------------------------
*/

let storage = require("Storage");
let locale = require("locale");
let widgets = require("widget_utils");
Expand All @@ -30,6 +31,7 @@
* 2. Graphical and visual configurations
* ---------------------------------------------------------------
*/

let w = g.getWidth();
let h = g.getHeight();
let totalWidth, totalHeight;
Expand All @@ -40,6 +42,7 @@
* 3. Touchscreen Handlers
* ---------------------------------------------------------------
*/

let touchHandler;
let dragHandler;
let movementDistance = 0;
Expand All @@ -49,6 +52,7 @@
* 4. Font loading function
* ---------------------------------------------------------------
*/

let loadCustomFont = function() {
Graphics.prototype.setFontBrunoAce = function() {
// Actual height 23 (24 - 2)
Expand All @@ -66,6 +70,7 @@
* 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);
Expand Down Expand Up @@ -167,6 +172,7 @@
* 7. String forming helper functions
* ---------------------------------------------------------------
*/

let isBool = function(val, defaultVal) {
return typeof val !== 'undefined' ? Boolean(val) : defaultVal;
};
Expand Down Expand Up @@ -211,6 +217,7 @@
* 8. Main draw function
* ---------------------------------------------------------------
*/

let draw = (function() {
let updatePerMinute = true; // variable to track the state of time display

Expand Down Expand Up @@ -272,6 +279,7 @@
* 9. Helper function for touch event
* ---------------------------------------------------------------
*/

let touchInText = function(e, boxItem, boxKey) {
calcBoxSize(boxItem);
const pos = calcBoxPos(boxKey);
Expand All @@ -296,6 +304,7 @@
* 10. Setup function to configure event handlers
* ---------------------------------------------------------------
*/

let setup = function() {
// ------------------------------------
// Define the touchHandler function
Expand Down Expand Up @@ -343,6 +352,8 @@
// 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
Expand Down Expand Up @@ -396,6 +407,7 @@
* 11. Main execution part
* ---------------------------------------------------------------
*/

Bangle.loadWidgets();
widgets.swipeOn();
modSetColor();
Expand Down
2 changes: 1 addition & 1 deletion apps/boxclk/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "boxclk",
"name": "Box Clock",
"version": "0.03",
"version": "0.04",
"description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background",
"icon": "app.png",
"screenshots": [
Expand Down

0 comments on commit 2ac8660

Please sign in to comment.