- first version

pull/3019/head
notEvil 2023-09-16 13:35:50 +02:00
parent df0253f532
commit d9de3d8b3e
4 changed files with 34 additions and 17 deletions

View File

@ -1,3 +1,4 @@
0.01: New app! 0.01: New app!
0.02-0.04: Bug fixes 0.02-0.04: Bug fixes
0.05: Submitted to the app loader 0.05: Submitted to the app loader
0.06: Added setting to show clock after start/resume

View File

@ -1,3 +1,5 @@
g.clear();
Bangle.POMOPLUS_ACTIVE = true; //Prevent the boot code from running. To avoid having to reload on every interaction, we'll control the vibrations from here when the user is in the app. Bangle.POMOPLUS_ACTIVE = true; //Prevent the boot code from running. To avoid having to reload on every interaction, we'll control the vibrations from here when the user is in the app.
const storage = require("Storage"); const storage = require("Storage");
@ -13,32 +15,36 @@ if (
} }
function drawButtons() { function drawButtons() {
let w = g.getWidth();
let h = g.getHeight();
//Draw the backdrop //Draw the backdrop
const BAR_TOP = g.getHeight() - 24; const BAR_TOP = h - 24;
g.setColor(0, 0, 1).setFontAlign(0, -1) g.setColor(0, 0, 1).setFontAlign(0, -1)
.clearRect(0, BAR_TOP, g.getWidth(), g.getHeight()) .clearRect(0, BAR_TOP, w, h)
.fillRect(0, BAR_TOP, g.getWidth(), g.getHeight()) .fillRect(0, BAR_TOP, w, h)
.setColor(1, 1, 1); .setColor(1, 1, 1);
if (!common.state.wasRunning) { //If the timer was never started, only show a play button if (!common.state.wasRunning) { //If the timer was never started, only show a play button
g.drawImage(common.BUTTON_ICONS.play, g.getWidth() / 2, BAR_TOP); g.drawImage(common.BUTTON_ICONS.play, w / 2, BAR_TOP);
} else { } else {
g.drawLine(g.getWidth() / 2, BAR_TOP, g.getWidth() / 2, g.getHeight()); g.drawLine(w / 2, BAR_TOP, w / 2, h);
if (common.state.running) { if (common.state.running) {
g.drawImage(common.BUTTON_ICONS.pause, g.getWidth() / 4, BAR_TOP) g.drawImage(common.BUTTON_ICONS.pause, w / 4, BAR_TOP)
.drawImage(common.BUTTON_ICONS.skip, g.getWidth() * 3 / 4, BAR_TOP); .drawImage(common.BUTTON_ICONS.skip, w * 3 / 4, BAR_TOP);
} else { } else {
g.drawImage(common.BUTTON_ICONS.reset, g.getWidth() / 4, BAR_TOP) g.drawImage(common.BUTTON_ICONS.reset, w / 4, BAR_TOP)
.drawImage(common.BUTTON_ICONS.play, g.getWidth() * 3 / 4, BAR_TOP); .drawImage(common.BUTTON_ICONS.play, w * 3 / 4, BAR_TOP);
} }
} }
} }
function drawTimerAndMessage() { function drawTimerAndMessage() {
let w = g.getWidth();
let h = g.getHeight();
g.reset() g.reset()
.setFontAlign(0, 0) .setFontAlign(0, 0)
.setFont("Vector", 36) .setFont("Vector", 36)
.clearRect(0, 24, 176, 152) .clearRect(w / 2 - 60, h / 2 - 34, w / 2 + 60, h / 2 + 34)
//Draw the timer //Draw the timer
.drawString((() => { .drawString((() => {
@ -53,7 +59,7 @@ function drawTimerAndMessage() {
if (hours >= 1) return `${parseInt(hours)}:${pad(minutes)}:${pad(seconds)}`; if (hours >= 1) return `${parseInt(hours)}:${pad(minutes)}:${pad(seconds)}`;
else return `${parseInt(minutes)}:${pad(seconds)}`; else return `${parseInt(minutes)}:${pad(seconds)}`;
})(), g.getWidth() / 2, g.getHeight() / 2) })(), w / 2, h / 2)
//Draw the phase label //Draw the phase label
.setFont("Vector", 12) .setFont("Vector", 12)
@ -63,7 +69,7 @@ function drawTimerAndMessage() {
else if (currentPhase == common.PHASE_SHORT_BREAK) return `Short break ${numShortBreaks + 1}/${common.settings.numShortBreaks}`; else if (currentPhase == common.PHASE_SHORT_BREAK) return `Short break ${numShortBreaks + 1}/${common.settings.numShortBreaks}`;
else return "Long break!"; else return "Long break!";
})(common.state.phase, common.state.numShortBreaks), })(common.state.phase, common.state.numShortBreaks),
g.getWidth() / 2, g.getHeight() / 2 + 18); w / 2, h / 2 + 18);
//Update phase with vibation if needed //Update phase with vibation if needed
if (common.getTimeLeft() <= 0) { if (common.getTimeLeft() <= 0) {
@ -91,6 +97,7 @@ Bangle.on("touch", (button, xy) => {
}; };
setupTimerInterval(); setupTimerInterval();
drawButtons(); drawButtons();
if (common.settings.showClock) Bangle.showClock();
} else if (common.state.running) { } else if (common.state.running) {
//If we are running, there are two buttons: pause and skip //If we are running, there are two buttons: pause and skip
@ -127,6 +134,7 @@ Bangle.on("touch", (button, xy) => {
drawTimerAndMessage(); drawTimerAndMessage();
setupTimerInterval(); setupTimerInterval();
drawButtons(); drawButtons();
if (common.settings.showClock) Bangle.showClock();
} }
} }
}); });

View File

@ -1,7 +1,7 @@
{ {
"id": "pomoplus", "id": "pomoplus",
"name": "Pomodoro Plus", "name": "Pomodoro Plus",
"version": "0.05", "version": "0.06",
"description": "A configurable pomodoro timer that runs in the background.", "description": "A configurable pomodoro timer that runs in the background.",
"icon": "icon.png", "icon": "icon.png",
"type": "app", "type": "app",

View File

@ -10,7 +10,8 @@ const storage = require("Storage");
longBreak: 900000, //15 minute long break longBreak: 900000, //15 minute long break
numShortBreaks: 3, //3 short breaks for every long break numShortBreaks: 3, //3 short breaks for every long break
pausedTimerExpireTime: 21600000, //If the timer was left paused for >6 hours, reset it on next launch pausedTimerExpireTime: 21600000, //If the timer was left paused for >6 hours, reset it on next launch
widget: false //If a widget is added in the future, whether the user wants it showClock: false, //Show clock after start/resume
widget: false, //If a widget is added in the future, whether the user wants it
}; };
} }
@ -89,6 +90,13 @@ const storage = require("Storage");
else return `${Math.floor(value / 3600000)}h ${(value % 3600000) / 60000}m` else return `${Math.floor(value / 3600000)}h ${(value % 3600000) / 60000}m`
} }
}, },
'Show clock': {
value: settings.showClock,
onchange: function(value) {
settings.showClock = value;
save();
},
},
}; };
E.showMenu(menu) E.showMenu(menu)
}) })