Skip to content

Commit

Permalink
Fix for issue where launcher would fast-load back to clock even if th…
Browse files Browse the repository at this point in the history
…e clock didn't have widgets
  • Loading branch information
gfwilliams committed Nov 1, 2022
1 parent 18510d4 commit 779b16b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/boot/ChangeLog
Expand Up @@ -57,3 +57,4 @@
Remove support for 2v11 and earlier firmware
0.51: Remove patches for 2v10 firmware (BEEPSET and setUI)
Add patch to ensure that compass heading is corrected
Ensure clock is only fast-loaded if it doesn't contain widgets
8 changes: 7 additions & 1 deletion apps/boot/bootloader.js
@@ -1,5 +1,10 @@
// This runs after a 'fresh' boot
var s = require("Storage").readJSON("setting.json",1)||{};
/* If were being called from JS code in order to load the clock quickly (eg from a launcher)
and the clock in question doesn't have widgets, force a normal 'load' as this will then
reset everything and remove the widgets. */
if (global.__FILE__ && !s.clockHasWidgets) {load();throw "Clock has no widgets, can't fast load";}
// Otherwise continue to try and load the clock
var _clkApp = require("Storage").read(s.clock);
if (!_clkApp) {
_clkApp = require("Storage").list(/\.info$/)
Expand All @@ -13,7 +18,8 @@ if (!_clkApp) {
.sort((a, b) => a.sortorder - b.sortorder)[0];
if (_clkApp){
s.clock = _clkApp.src;
_clkApp = require("Storage").read(_clkApp.src);
_clkApp = require("Storage").read(_clkApp.src);
s.clockHasWidgets = _clkApp.includes("Bangle.loadWidgets");
require("Storage").writeJSON("setting.json", s);
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/launch/app.js
Expand Up @@ -66,7 +66,7 @@ E.showScroller({
});
g.flip(); // force a render before widgets have finished drawing

function returnToClock() {
let returnToClock = function() {
// unload everything manually
// ... or we could just call `load();` but it will be slower
Bangle.setUI(); // remove scroller's handling
Expand All @@ -85,7 +85,7 @@ if (process.env.HWVERSION==2) {
// 10s of inactivity goes back to clock
Bangle.setLocked(false); // unlock initially
let lockTimeout;
function lockHandler(locked) {
let lockHandler = function(locked) {
if (lockTimeout) clearTimeout(lockTimeout);
lockTimeout = undefined;
if (locked)
Expand Down
2 changes: 1 addition & 1 deletion apps/setting/ChangeLog
Expand Up @@ -57,4 +57,4 @@
0.50: Add Bangle.js 2 touchscreen calibration - for 2v16 or 2v15 cutting edge builds
0.51: Add setting for configuring a launcher
0.52: Add option for left-handed users

0.53: Ensure that when clock is set, clockHasWidgets is set correctly too
2 changes: 1 addition & 1 deletion apps/setting/metadata.json
@@ -1,7 +1,7 @@
{
"id": "setting",
"name": "Settings",
"version": "0.52",
"version": "0.53",
"description": "A menu for setting up Bangle.js",
"icon": "settings.png",
"tags": "tool,system",
Expand Down
18 changes: 8 additions & 10 deletions apps/setting/settings.js
Expand Up @@ -39,6 +39,7 @@ function resetSettings() {
timezone: 0, // Set the timezone for the device
HID: false, // BLE HID mode, off by default
clock: null, // a string for the default clock's name
// clockHasWidgets: false, // Does the clock in 'clock' contain the string 'Bangle.loadWidgets'
"12hour" : false, // 12 or 24 hour clock?
firstDayOfWeek: 0, // 0 -> Sunday (default), 1 -> Monday
brightness: 1, // LCD brightness from 0 to 1
Expand Down Expand Up @@ -674,11 +675,10 @@ function showClockMenu() {
label = "* " + label;
}
clockMenu[label] = () => {
if (settings.clock !== app.src) {
settings.clock = app.src;
updateSettings();
showMainMenu();
}
settings.clock = app.src;
settings.clockHasWidgets = require("Storage").read(app.src).includes("Bangle.loadWidgets");
updateSettings();
showMainMenu();
};
});
if (clockApps.length === 0) {
Expand All @@ -703,11 +703,9 @@ function showLauncherMenu() {
label = "* " + label;
}
launcherMenu[label] = () => {
if (settings.launcher !== app.src) {
settings.launcher = app.src;
updateSettings();
showMainMenu();
}
settings.launcher = app.src;
updateSettings();
showMainMenu();
};
});
if (launcherApps.length === 0) {
Expand Down

0 comments on commit 779b16b

Please sign in to comment.