Skip to content

Commit 37e7bba

Browse files
author
thyttan
committed
Merge remote-tracking branch 'bobrippling/feat/run-ui-opt' into app-loader
2 parents 0495c7d + edb0cf2 commit 37e7bba

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

apps/runplus/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ Write to correct settings file, fixing settings not working.
2929
0.26: Add ability to zoom in on a single stat by tapping it
3030
0.27: Allow setting to alway resume an activity
3131
0.28: Add vibration feedback on start/stop
32+
0.29: Optimise UI: only redraw if we showed a recorder menu and correctly
33+
track screen state
34+
35+
36+

apps/runplus/app.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ function onStartStop() {
9090
// an overwrite before we start tracking exstats
9191
if (settings.record && WIDGETS["recorder"]) {
9292
if (running) {
93-
screen = "menu";
9493
promise = promise.
95-
then(() => WIDGETS["recorder"].setRecording(true, { force : shouldResume?"append":undefined })).
9694
then(() => {
95+
screen = "menu";
96+
return WIDGETS["recorder"].setRecording(true, { force : shouldResume?"append":undefined });
97+
}).then(() => {
9798
screen = "main";
98-
layout.setUI(); // grab our input handling again
99-
layout.forgetLazyState();
100-
layout.render();
99+
if(!shouldResume){
100+
// setRecording might have rendered - need to grab UI
101+
layout.setUI(); // grab our input handling again
102+
layout.forgetLazyState();
103+
layout.render();
104+
}
101105
});
102106
} else {
103107
promise = promise.then(
@@ -146,7 +150,7 @@ function zoom(statID) {
146150
.clearRect(R)
147151
.setFontAlign(0, 0);
148152

149-
layout.render(layout.bottom);
153+
tick();
150154

151155
const value = exs.state.active ? stat.getString() : "____";
152156

@@ -220,6 +224,20 @@ Bangle.on("GPS", function(fix) {
220224
}
221225
});
222226

227+
const tick = () => {
228+
layout.clock.label = locale.time(new Date(),1);
229+
switch (screen) {
230+
case "main":
231+
layout.render();
232+
break;
233+
case "zoom":
234+
layout.render(layout.bottom);
235+
break;
236+
case "menu":
237+
break;
238+
}
239+
};
240+
223241
function setScreen(to) {
224242
if (screen === "karvonen") {
225243
require("runplus_karvonen").stop();
@@ -238,12 +256,8 @@ function setScreen(to) {
238256
layout.render();
239257
layout.lazy = true;
240258
// We always call ourselves once a second to update
241-
if (!runInterval){
242-
runInterval = setInterval(function() {
243-
layout.clock.label = locale.time(new Date(),1);
244-
if (screen !== "menu") layout.render();
245-
}, 1000);
246-
}
259+
if (!runInterval)
260+
runInterval = setInterval(tick, 1000);
247261
break;
248262

249263
case "karvonen":

apps/runplus/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "runplus",
33
"name": "Run+",
4-
"version": "0.28",
4+
"version": "0.29",
55
"description": "Displays distance, time, steps, cadence, pace and more for runners. Based on the Run app, but extended with additional screens for heart rate interval training and individual stat focus.",
66
"icon": "app.png",
77
"tags": "run,running,fitness,outdoors,gps,karvonen,karvonnen",

0 commit comments

Comments
 (0)