Skip to content

Commit 638d5cb

Browse files
committed
clkinfo: allow filtering of installed clockinfos
1 parent e63a25e commit 638d5cb

File tree

6 files changed

+52
-7
lines changed

6 files changed

+52
-7
lines changed

apps/boot/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@
7676
Bangle.loadWidgets overwritten with fast version on success
7777
Refuse to work on firmware <2v16 and remove old polyfills
7878
0.65: Only display interpreter errors if log is nonzero
79-
0.66: Ensure __FILE__ is set even after a fresh boot (fix #3857)
79+
0.66: Ensure __FILE__ is set even after a fresh boot (fix #3857)
80+
0.67: When generating .clkinfocache, apply configured exclusions

apps/boot/bootupdate.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ delete widget,widgetPost,widgetFiles;
192192
// ================================================== .clkinfocache for clockinfos
193193
let ciFiles = require("Storage").list(/\.clkinfo\.js$/);
194194
let ci = `// Made by bootupdate.js\n`;
195+
let ci_exclude = (require("Storage").readJSON("clock_info.json", 1) || {}).exclude;
195196
if (DEBUG) ci+="var _tm=Date.now();";
196197
outputFileComplete = (dst,fn) => {
198+
if (ci_exclude && ci_exclude[fn]) return;
197199
outputFile(dst,fn,"try{let fn=",`;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${E.toJS(fn)},e,e.stack)}\n`);
198200
};
199201
fileOffset = ci.length;

apps/boot/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "boot",
33
"name": "Bootloader",
4-
"version": "0.66",
4+
"version": "0.67",
55
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
66
"icon": "bootloader.png",
77
"type": "bootloader",

apps/clock_info/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
0.22: Tapping on step counter now disable step counting on 2v29+ firmwares
2525
0.23: Use filter function for better image borders if it exists (2v22)
2626
0.24: Only save settings once (not once per clockinfo)
27-
Add .setFocus function to allow a clockinfo to be focused without faking a click on it
27+
Add .setFocus function to allow a clockinfo to be focused without faking a click on it
28+
0.25: Add ability to filter-out installed clockinfos

apps/clock_info/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ "id": "clock_info",
22
"name": "Clock Info Module",
33
"shortName": "Clock Info",
4-
"version":"0.24",
4+
"version":"0.25",
55
"description": "A library used by clocks to provide extra information on the clock face (Altitude, BPM, etc)",
66
"icon": "app.png",
77
"type": "module",

apps/clock_info/settings.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
let settings = require("clock_info").loadSettings();
33

44
function save(key, value) {
5-
settings[key] = value;
5+
if (key)
6+
settings[key] = value;
67
require('Storage').write("clock_info.json", settings);
78
}
89

9-
let menu ={
10+
let menu = {
1011
'': { 'title': 'Clock Info' },
1112
/*LANG*/'< Back': back,
1213
/*LANG*/'Defocus on Lock': {
@@ -28,7 +29,47 @@
2829
/*LANG*/'Haptics': {
2930
value: !!settings.haptics,
3031
onchange: x => save('haptics', x),
31-
}
32+
},
33+
/*LANG*/'Filtering': () => {
34+
let filterMenu = {
35+
'': { 'title': 'Exclude clkinfos' },
36+
'< Back': () => E.showMenu(menu)
37+
};
38+
39+
const re = /\.clkinfo\.js$/;
40+
require("Storage")
41+
.list(re)
42+
.forEach(file => {
43+
const name = file.replace(re, "");
44+
45+
filterMenu[name] = {
46+
value: !!(settings.exclude && settings.exclude[file]),
47+
format: v => v ? "hide" : "show",
48+
onchange: v => {
49+
if (v) {
50+
if (!settings.exclude)
51+
settings.exclude = {};
52+
settings.exclude[file] = true;
53+
} else {
54+
if (settings.exclude)
55+
delete settings.exclude[file];
56+
}
57+
save();
58+
},
59+
};
60+
});
61+
62+
// clean up stale entries
63+
Object
64+
.keys(settings.exclude)
65+
.filter(k => !(k.replace(re, "") in filterMenu))
66+
.forEach(k => {
67+
delete settings.exclude[k];
68+
});
69+
70+
E.showMenu(filterMenu);
71+
},
3272
};
73+
3374
E.showMenu(menu);
3475
})

0 commit comments

Comments
 (0)