From 95c5fd8bcff453f80096a5f755b9767e0ff205d1 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Wed, 30 Nov 2022 21:10:06 +0100 Subject: [PATCH] only load widgets if fastload is installed --- apps/torch/ChangeLog | 3 ++- apps/torch/app.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/torch/ChangeLog b/apps/torch/ChangeLog index 9c8521265..a3665a562 100644 --- a/apps/torch/ChangeLog +++ b/apps/torch/ChangeLog @@ -8,4 +8,5 @@ 0.08: Force background of widget field to the torch colour 0.09: Change code taking FW tweaks into account 0.10: Introduce fast switching. -0.11: Make compatible with Fastload Utils by loading widgets. +0.11: Make compatible with Fastload Utils by loading widgets. No change if +Fastload Utils is not installed. diff --git a/apps/torch/app.js b/apps/torch/app.js index a10943794..a65a2ff49 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -1,14 +1,15 @@ { const SETTINGS_FILE = "torch.json"; let settings; + let s = require("Storage"); let loadSettings = function() { - settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#FFFFFF', 'color': 'White'}; + settings = s.readJSON(SETTINGS_FILE,1)|| {'bg': '#FFFFFF', 'color': 'White'}; }; loadSettings(); - let brightnessBackup = require("Storage").readJSON('setting.json').brightness; + let brightnessBackup = s.readJSON('setting.json').brightness; let optionsBackup = Bangle.getOptions(); Bangle.setLCDBrightness(1); Bangle.setLCDPower(1); @@ -18,7 +19,8 @@ g.setTheme({bg:settings.bg,fg:"#000"}); g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); - Bangle.loadWidgets(); + // if Fastload Utils is installed, make Torch compatible with it. + if (s.readJSON('fastload.info') != undefined) Bangle.loadWidgets(); Bangle.setUI({ mode : 'custom', back : Bangle.showClock, // B2: SW back button to exit