Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

voldisp: new app that displays volume change on Android device #3780

Merged
merged 9 commits into from
Mar 25, 2025
Prev Previous commit
Next Next commit
Revert "voldisp: some optimization"
This reverts commit 500296a.
  • Loading branch information
thyttan committed Mar 21, 2025
commit 108a932a581bb8cbbaf792663b21638ba2b62594
59 changes: 29 additions & 30 deletions apps/voldisp/boot.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{
const WIDGET_UTILS_HIDE = function() {
//exports.cleanup();
if (!global.WIDGETS) return;
g.reset(); // reset colors
for (var w of global.WIDGETS) {
if (w._draw) return; // already hidden
w._draw = w.draw;
w.draw = () => {};
w._area = w.area;
w.area = "";
if (w.x!=undefined) g.clearRect(w.x,w.y,w.x+w.width-1,w.y+23);
}
};
/// Show any hidden widgets
const WIDGET_UTILS_SHOW = function() {
//exports.cleanup();
if (!global.WIDGETS) return;
for (var w of global.WIDGETS) {
if (!w._draw) return; // not hidden
w.draw = w._draw;
w.area = w._area;
delete w._draw;
delete w._area;
w.draw(w);
}
};

let timeout;
let onMusicVolume = (volPercent)=>{
if (timeout) {clearTimeout(timeout);}
if (timeout) {clearTimeout(timeout); timeout=undefined;}

if (Bangle.CLOCK) {

const WIDGET_UTILS_HIDE = function() {
//exports.cleanup();
if (!global.WIDGETS) return;
g.reset(); // reset colors
for (var w of global.WIDGETS) {
if (w._draw) return; // already hidden
w._draw = w.draw;
w.draw = () => {};
w._area = w.area;
w.area = "";
if (w.x!=undefined) g.clearRect(w.x,w.y,w.x+w.width-1,w.y+23);
}
};
/// Show any hidden widgets
const WIDGET_UTILS_SHOW = function() {
//exports.cleanup();
if (!global.WIDGETS) return;
for (var w of global.WIDGETS) {
if (!w._draw) return; // not hidden
w.draw = w._draw;
w.area = w._area;
delete w._draw;
delete w._area;
w.draw(w);
}
};

let isAllWidgetsHidden = true;
if (global.WIDGETS) {
for (var w of global.WIDGETS) {
@@ -41,7 +41,7 @@
}
}
}
if (!timeout) {WIDGET_UTILS_HIDE();}
WIDGET_UTILS_HIDE();
let barWidth = g.getWidth()*volPercent/100;
g.
setColor(0x0000).fillRect(0,0,g.getWidth(),24).
@@ -58,7 +58,6 @@
} else {
Bangle.load();
}
timeout = undefined;
};
timeout = setTimeout(goAway, 3*1000);
}