Fix for issue where launcher would fast-load back to clock even if the clock didn't have widgets

master
Gordon Williams 2022-11-01 14:21:27 +00:00
parent 18510d4583
commit 779b16b671
6 changed files with 20 additions and 15 deletions

View File

@ -57,3 +57,4 @@
Remove support for 2v11 and earlier firmware Remove support for 2v11 and earlier firmware
0.51: Remove patches for 2v10 firmware (BEEPSET and setUI) 0.51: Remove patches for 2v10 firmware (BEEPSET and setUI)
Add patch to ensure that compass heading is corrected Add patch to ensure that compass heading is corrected
Ensure clock is only fast-loaded if it doesn't contain widgets

View File

@ -1,5 +1,10 @@
// This runs after a 'fresh' boot // This runs after a 'fresh' boot
var s = require("Storage").readJSON("setting.json",1)||{}; 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); var _clkApp = require("Storage").read(s.clock);
if (!_clkApp) { if (!_clkApp) {
_clkApp = require("Storage").list(/\.info$/) _clkApp = require("Storage").list(/\.info$/)
@ -13,7 +18,8 @@ if (!_clkApp) {
.sort((a, b) => a.sortorder - b.sortorder)[0]; .sort((a, b) => a.sortorder - b.sortorder)[0];
if (_clkApp){ if (_clkApp){
s.clock = _clkApp.src; 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); require("Storage").writeJSON("setting.json", s);
} }
} }

View File

@ -66,7 +66,7 @@ E.showScroller({
}); });
g.flip(); // force a render before widgets have finished drawing g.flip(); // force a render before widgets have finished drawing
function returnToClock() { let returnToClock = function() {
// unload everything manually // unload everything manually
// ... or we could just call `load();` but it will be slower // ... or we could just call `load();` but it will be slower
Bangle.setUI(); // remove scroller's handling Bangle.setUI(); // remove scroller's handling
@ -85,7 +85,7 @@ if (process.env.HWVERSION==2) {
// 10s of inactivity goes back to clock // 10s of inactivity goes back to clock
Bangle.setLocked(false); // unlock initially Bangle.setLocked(false); // unlock initially
let lockTimeout; let lockTimeout;
function lockHandler(locked) { let lockHandler = function(locked) {
if (lockTimeout) clearTimeout(lockTimeout); if (lockTimeout) clearTimeout(lockTimeout);
lockTimeout = undefined; lockTimeout = undefined;
if (locked) if (locked)

View File

@ -57,4 +57,4 @@
0.50: Add Bangle.js 2 touchscreen calibration - for 2v16 or 2v15 cutting edge builds 0.50: Add Bangle.js 2 touchscreen calibration - for 2v16 or 2v15 cutting edge builds
0.51: Add setting for configuring a launcher 0.51: Add setting for configuring a launcher
0.52: Add option for left-handed users 0.52: Add option for left-handed users
0.53: Ensure that when clock is set, clockHasWidgets is set correctly too

View File

@ -1,7 +1,7 @@
{ {
"id": "setting", "id": "setting",
"name": "Settings", "name": "Settings",
"version": "0.52", "version": "0.53",
"description": "A menu for setting up Bangle.js", "description": "A menu for setting up Bangle.js",
"icon": "settings.png", "icon": "settings.png",
"tags": "tool,system", "tags": "tool,system",

View File

@ -39,6 +39,7 @@ function resetSettings() {
timezone: 0, // Set the timezone for the device timezone: 0, // Set the timezone for the device
HID: false, // BLE HID mode, off by default HID: false, // BLE HID mode, off by default
clock: null, // a string for the default clock's name 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? "12hour" : false, // 12 or 24 hour clock?
firstDayOfWeek: 0, // 0 -> Sunday (default), 1 -> Monday firstDayOfWeek: 0, // 0 -> Sunday (default), 1 -> Monday
brightness: 1, // LCD brightness from 0 to 1 brightness: 1, // LCD brightness from 0 to 1
@ -674,11 +675,10 @@ function showClockMenu() {
label = "* " + label; label = "* " + label;
} }
clockMenu[label] = () => { clockMenu[label] = () => {
if (settings.clock !== app.src) { settings.clock = app.src;
settings.clock = app.src; settings.clockHasWidgets = require("Storage").read(app.src).includes("Bangle.loadWidgets");
updateSettings(); updateSettings();
showMainMenu(); showMainMenu();
}
}; };
}); });
if (clockApps.length === 0) { if (clockApps.length === 0) {
@ -703,11 +703,9 @@ function showLauncherMenu() {
label = "* " + label; label = "* " + label;
} }
launcherMenu[label] = () => { launcherMenu[label] = () => {
if (settings.launcher !== app.src) { settings.launcher = app.src;
settings.launcher = app.src; updateSettings();
updateSettings(); showMainMenu();
showMainMenu();
}
}; };
}); });
if (launcherApps.length === 0) { if (launcherApps.length === 0) {