Skip to content

Commit dbcfe8b

Browse files
author
thyttan
committed
Merge branch 'launch' into app-loader
2 parents 8c559e3 + c9c1c15 commit dbcfe8b

File tree

15 files changed

+473
-423
lines changed

15 files changed

+473
-423
lines changed

apps/iconlaunch/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
0.18: Better performance
2626
0.19: Remove 'jit' keyword as 'for(..of..)' is not supported (fix #2937)
2727
0.20: Use '28' font if installed (2v26+) and put it inside a rounded rect in the current theme
28-
Ensure 'oneClickExit' is the default
28+
Ensure 'oneClickExit' is the default
29+
0.21: Display placeholder icons at start and render line by line to the screen to make loading seem faster

apps/iconlaunch/app.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
} else { // for fast-load, if we had widgets then we should hide them
1717
require("widget_utils").hide();
1818
}
19+
20+
let selectedItem = -1;
21+
const R = Bangle.appRect;
22+
const iconSize = 48;
23+
const appsN = Math.floor(R.w / iconSize);
24+
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
25+
const iconYoffset = Math.floor(whitespace/4)-1;
26+
const itemSize = iconSize + whitespace;
27+
28+
// show some grey blocks as a loading screen
29+
g.clearRect(Bangle.appRect).setColor("#888");
30+
for (var y=R.y+whitespace/2;y<R.h;y+=itemSize)
31+
for (var x=R.x+whitespace/2;x<R.w;x+=itemSize)
32+
g.drawRect(x+16,y+16,x+32,y+32);
33+
g.flip();
34+
1935
let launchCache = s.readJSON("iconlaunch.cache.json", true)||{};
2036
let launchHash = s.hash(/\.info/);
2137
if (launchCache.hash!=launchHash) {
@@ -38,13 +54,7 @@
3854
const ICON_MISSING = s.read("iconlaunch.na.img");
3955
let count = 0;
4056

41-
let selectedItem = -1;
42-
const R = Bangle.appRect;
43-
const iconSize = 48;
44-
const appsN = Math.floor(R.w / iconSize);
45-
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
46-
const iconYoffset = Math.floor(whitespace/4)-1;
47-
const itemSize = iconSize + whitespace;
57+
4858

4959
launchCache.items = {};
5060
for (let c of launchCache.apps){
@@ -82,8 +92,9 @@
8292
drawText(itemI, r.y, selectedApp);
8393
texted=itemI;
8494
}
95+
if (firstRun) g.flip(); // at startup
8596
};
86-
97+
let firstRun = true;
8798
let drawText = function(i, appY, selectedApp) {
8899
const idy = (selectedItem - (selectedItem % 3)) / 3;
89100
if (i != idy) return;
@@ -150,10 +161,11 @@
150161
}
151162

152163
let scroller = E.showScroller(options);
164+
firstRun = false; // this stops us flipping the screen after each line we draw
153165

154166
let timeout;
155167
const updateTimeout = function(){
156-
if (settings.timeOut!="Off"){
168+
if (settings.timeOut!="Off"){
157169
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
158170
if (timeout) clearTimeout(timeout);
159171
timeout = setTimeout(Bangle.showClock,time*1000);

apps/iconlaunch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "iconlaunch",
33
"name": "Icon Launcher",
44
"shortName" : "Icon launcher",
5-
"version": "0.20",
5+
"version": "0.21",
66
"icon": "app.png",
77
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",
88
"tags": "tool,system,launcher",

apps/launch/ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
0.19: Fix regression after back button added (returnToClock was called twice!)
2222
0.20: Use Bangle.showClock for changing to clock
2323
0.21: Make the "App source not found" warning less buggy
24-
0.22: Add less padding between launcher items, use new font if available in 2v26+
24+
0.22: Add less padding between launcher items, use new font if available in 2v26+
25+
0.23: Draw a placeholder screen right at the start to speed up apparent boot time
26+
0.24: Fix fullscreen when fastloading the launcher. (TODO:fix back btn flicker)
27+
Fix respecting the showClocks setting.

apps/launch/app.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{ // must be inside our own scope here so that when we are unloaded everything disappears
22
let s = require("Storage");
33
// handle customised launcher
4-
let scaleval = 1;
5-
let vectorval = 20;
6-
let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
7-
if (g.getFonts().includes("22")) font="22"; // 2v26+
4+
let scaleval = 1, vectorval = 20, fonts = g.getFonts();
5+
let font = fonts.includes("12x20") ? "12x20" : "6x8:2";
6+
if (fonts.includes("22")) font="22"; // 2v26+
87
let settings = Object.assign({
98
showClocks: true,
109
fullscreen: false
@@ -20,6 +19,22 @@
2019
scaleval = (font.split("x")[1])/20;
2120
}
2221
}
22+
let height = 50*scaleval;
23+
24+
// Now apps list is loaded - render
25+
if (!settings.fullscreen) {
26+
Bangle.loadWidgets();
27+
} else if (global.WIDGETS) {
28+
require("widget_utils").hide();
29+
}
30+
let R = Bangle.appRect;
31+
g.reset().clearRect(R).setColor("#888");
32+
for (var y=R.y;y<R.y2;y+=height) {
33+
g.drawRect(5*scaleval,y+5*scaleval,49*scaleval,y+49*scaleval) // image
34+
.drawRect(54*scaleval,y+20*scaleval,R.y2-16,y+34*scaleval); // text
35+
}
36+
g.flip();
37+
2338
// cache app list so launcher loads more quickly
2439
let launchCache = s.readJSON("launch.cache.json", true)||{};
2540
let launchHash = require("Storage").hash(/\.info/);
@@ -28,7 +43,7 @@
2843
hash : launchHash,
2944
apps : s.list(/\.info$/)
3045
.map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};})
31-
.filter(app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || !app.type))
46+
.filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type))
3247
.sort((a,b)=>{
3348
var n=(0|a.sortorder)-(0|b.sortorder);
3449
if (n) return n; // do sortorder first
@@ -38,14 +53,12 @@
3853
}) };
3954
s.writeJSON("launch.cache.json", launchCache);
4055
}
41-
let apps = launchCache.apps;
42-
// Now apps list is loaded - render
43-
if (!settings.fullscreen)
44-
Bangle.loadWidgets();
56+
let apps = launchCache.apps.filter(app=>app.type!="clock" || settings.showClocks);
57+
4558

4659
const drawMenu = () => {
47-
E.showScroller({
48-
h : 50*scaleval, c : apps.length,
60+
let scroller = E.showScroller({
61+
h : height, c : apps.length,
4962
draw : (i, r) => {
5063
var app = apps[i];
5164
if (!app) return;
@@ -71,8 +84,14 @@
7184
// cleanup the timeout to not leave anything behind after being removed from ram
7285
if (lockTimeout) clearTimeout(lockTimeout);
7386
Bangle.removeListener("lock", lockHandler);
87+
// Restore widgets if they were hidden by fullscreen setting
88+
if (global.WIDGETS) require("widget_utils").show();
7489
}
7590
});
91+
if (settings.fullscreen) {
92+
require("widget_utils").hide();
93+
scroller.draw(); // FIX: The red back button will flicker before the widget is hidden and scroller redrawn.
94+
}
7695
g.flip(); // force a render before widgets have finished drawing
7796

7897
// 10s of inactivity goes back to clock
@@ -90,4 +109,4 @@
90109

91110
if (!settings.fullscreen) // finally draw widgets
92111
Bangle.drawWidgets();
93-
}
112+
}

apps/launch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "launch",
33
"name": "Launcher",
44
"shortName": "Launcher",
5-
"version": "0.22",
5+
"version": "0.24",
66
"description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
77
"readme": "README.md",
88
"icon": "app.png",

apps/recorder/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@
5454
0.42: Minor code improvements
5555
0.43: Fix interaction on clocks without widgets
5656
0.44: List tracks in reverse chronological order.
57+
0.45: Move recorder from widget into library
58+
Improve recorder ClockInfo icons

apps/recorder/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Some apps like the [Run app](https://banglejs.com/apps/?id=run) are able to auto
2727

2828
**Note:** It is possible for other apps to record information using this app
2929
as well. They need to define a `foobar.recorder.js` file - see the `getRecorders`
30-
function in `widget.js` for more information.
30+
function in `lib.js` for more information.
3131

3232
## Graphing
3333

@@ -46,11 +46,13 @@ You can also view some information on the watch.
4646

4747
## Usage in code
4848

49-
As long as widgets are loaded, you can:
49+
You can do:
5050

51-
* Call `WIDGETS["recorder"].setRecording(true)` to start recording (it returns a promise, and may show a menu)
52-
* Call `WIDGETS["recorder"].setRecording(true, {force:"new"/"append"/"overwrite")` to start recording (it returns a promise, and will not show a menu)
53-
* Call `WIDGETS["recorder"].setRecording(false)` to stop recording
51+
* Call `require("recorder").setRecording(true)` to start recording (it returns a promise, and may show a menu)
52+
* Call `require("recorder").setRecording(true, {force:"new"/"append"/"overwrite")` to start recording (it returns a promise, and will not show a menu)
53+
* Call `require("recorder").setRecording(false)` to stop recording
54+
55+
And check `require("recorder").isRecording()` to see if we're recording or not.
5456

5557
### Recording new items
5658

apps/recorder/app.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ loadSettings();
2626

2727
function updateSettings() {
2828
require("Storage").writeJSON("recorder.json", settings);
29-
if (WIDGETS["recorder"])
30-
WIDGETS["recorder"].reload();
29+
require("recorder").reload();
3130
}
3231

3332
function getTrackNumber(filename) {
@@ -56,7 +55,7 @@ function showMainMenu() {
5655
onchange: v => {
5756
setTimeout(function() {
5857
E.showMenu();
59-
WIDGETS["recorder"].setRecording(v).then(function() {
58+
require("recorder").setRecording(v).then(function() {
6059
//print("Record start Complete");
6160
loadSettings();
6261
//print("Recording: "+settings.recording);
@@ -80,7 +79,7 @@ function showMainMenu() {
8079
}
8180
}
8281
};
83-
var recorders = WIDGETS["recorder"].getRecorders();
82+
var recorders = require("recorder").getRecorders();
8483
Object.keys(recorders).forEach(id=>{
8584
mainmenu[/*LANG*/"Log "+recorders[id]().name] = menuRecord(id);
8685
});
@@ -172,7 +171,7 @@ function viewTrack(filename, info) {
172171
'': { 'title': /*LANG*/'Track '+info.fn }
173172
};
174173
if (info.time)
175-
menu[info.time.toISOString().substr(0,16).replace("T"," ")] = {};
174+
menu[info.time.toISOString().substr(0,16).replace("T"," ")] = {value:""};
176175
menu["Duration"] = { value : asTime(info.duration)};
177176
menu["Records"] = { value : ""+info.records };
178177
if (info.fields.includes("Latitude"))

apps/recorder/boot.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
if ((require("Storage").readJSON("recorder.json",1)||{}).recording) require("recorder"); // just requiring causes it to reload

0 commit comments

Comments
 (0)