gbmusic: remove date+time

master
Richard de Boer 2022-02-13 16:49:28 +01:00
parent 60cae6bc84
commit 32273ed158
No known key found for this signature in database
GPG Key ID: 8721727971871937
7 changed files with 12 additions and 52 deletions

View File

@ -8,3 +8,4 @@
0.08: Fix scrolling title background color 0.08: Fix scrolling title background color
0.09: Move event listener from widget to boot code, stops music from showing up in messages 0.09: Move event listener from widget to boot code, stops music from showing up in messages
0.10: Simplify touch events 0.10: Simplify touch events
Remove date+time

View File

@ -15,7 +15,6 @@ Download the [latest Gadgetbridge for Android here](https://f-droid.org/packages
* Dynamic colors based on Track/Artist/Album name * Dynamic colors based on Track/Artist/Album name
* Scrolling display for long titles * Scrolling display for long titles
* Automatic start when music plays * Automatic start when music plays
* Time and date display
## Settings ## Settings

View File

@ -10,15 +10,15 @@ const BANGLE2 = process.env.HWVERSION===2;
/** /**
* @param {string} text * @param {string} text
* @return {number} Maximum font size to make text fit on screen * @param {number} w Width to fit text in
* @return {number} Maximum font size to make text fit
*/ */
function fitText(text) { function fitText(text, w) {
if (!text.length) { if (!text.length) {
return Infinity; return Infinity;
} }
// make a guess, then shrink/grow until it fits // make a guess, then shrink/grow until it fits
const w = Bangle.appRect.w, const test = (s) => g.setFont("Vector", s).stringWidth(text);
test = (s) => g.setFont("Vector", s).stringWidth(text);
let best = Math.floor(100*w/test(100)); let best = Math.floor(100*w/test(100));
if (test(best)===w) { // good guess! if (test(best)===w) { // good guess!
return best; return best;
@ -106,7 +106,7 @@ function rTitle(l) {
rScroller(l); // already scrolling rScroller(l); // already scrolling
return; return;
} }
let size = fitText(l.label); let size = fitText(l.label, l.w);
if (size<l.h/2) { if (size<l.h/2) {
// the title is too long: start the scroller // the title is too long: start the scroller
scrollStart(); scrollStart();
@ -119,7 +119,7 @@ function rTitle(l) {
* @param l * @param l
*/ */
function rInfo(l) { function rInfo(l) {
let size = fitText(l.label); let size = fitText(l.label, l.w);
if (size>l.h) { if (size>l.h) {
size = l.h; size = l.h;
} }
@ -182,21 +182,17 @@ function makeUI() {
type: "v", c: [ type: "v", c: [
{ {
type: "h", fillx: 1, c: [ type: "h", fillx: 1, c: [
{id: "time", type: "txt", label: "88:88", valign: -1, halign: -1, font: "8%", bgCol: g.theme.bg},
{fillx: 1}, {fillx: 1},
{id: "num", type: "txt", label: "88:88", valign: -1, halign: 1, font: "12%", bgCol: g.theme.bg}, {id: "num", type: "txt", label: "", valign: -1, halign: -1, font: "12%", bgCol: g.theme.bg},
BANGLE2 ? {} : {id: "up", type: "txt", label: " +", font: "6x8:2"}, BANGLE2 ? {} : {id: "up", type: "txt", label: " +", halign: 1, font: "6x8:2"},
], ],
}, },
{id: "title", type: "custom", label: "", fillx: 1, filly: 2, offset: null, font: "Vector:20%", render: rTitle, bgCol: g.theme.bg}, {id: "title", type: "custom", label: "", fillx: 1, filly: 2, offset: null, font: "Vector:20%", render: rTitle, bgCol: g.theme.bg},
{id: "artist", type: "custom", label: "", fillx: 1, filly: 1, size: 30, render: rInfo, bgCol: g.theme.bg}, {id: "artist", type: "custom", label: "", fillx: 1, filly: 1, size: 30, render: rInfo, bgCol: g.theme.bg},
{id: "album", type: "custom", label: "", fillx: 1, filly: 1, size: 20, render: rInfo, bgCol: g.theme.bg},
{height: 10},
{ {
type: "h", c: [ type: "h", c: [
{width: 3}, {id: "album", type: "custom", label: "", fillx: 1, filly: 1, size: 20, render: rInfo, bgCol: g.theme.bg},
{id: "date", type: "txt", halign: 0, valign: 1, label: "", font: "8%", fillx: 1, bgCol: g.theme.bg}, BANGLE2 ? {} : {id: "down", type: "txt", label: " -", font: "6x8:2"},
BANGLE2 ? {width: 3} : {id: "down", type: "txt", label: " -", font: "6x8:2"},
], ],
}, },
{height: 10}, {height: 10},
@ -209,20 +205,6 @@ function makeUI() {
// Self-repeating timeouts // Self-repeating timeouts
/////////////////////// ///////////////////////
// Clock
let tock = -1;
function tick() {
if (!BANGLE2 && !Bangle.isLCDOn()) {
return;
}
const now = new Date();
if (now.getHours()*60+now.getMinutes()!==tock) {
drawDateTime();
tock = now.getHours()*60+now.getMinutes();
}
setTimeout(tick, 1000); // we only show minute precision anyway
}
// Fade out while paused and auto closing // Fade out while paused and auto closing
let fade = null; let fade = null;
function fadeOut() { function fadeOut() {
@ -269,28 +251,6 @@ function scrollStop() {
//////////////////// ////////////////////
// Drawing functions // Drawing functions
//////////////////// ////////////////////
/**
* Draw date and time
*/
function drawDateTime() {
const now = new Date();
const l = require("locale");
const is12 = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
if (is12) {
const d12 = new Date(now.getTime());
const hour = d12.getHours();
if (hour===0) {
d12.setHours(12);
} else if (hour>12) {
d12.setHours(hour-12);
}
layout.time.label = l.time(d12, true)+l.meridian(now);
} else {
layout.time.label = l.time(now, true);
}
layout.date.label = require("locale").date(now, true);
layout.render();
}
function drawControls() { function drawControls() {
if (BANGLE2) return; if (BANGLE2) return;
@ -331,6 +291,7 @@ function info(info) {
layout.album.col = infoColor("album"); layout.album.col = infoColor("album");
layout.artist.col = infoColor("artist"); layout.artist.col = infoColor("artist");
layout.num.label = formatNum(info); layout.num.label = formatNum(info);
layout.update();
layout.render(); layout.render();
rTitle(layout.title); // force redraw of title, or scroller might break rTitle(layout.title); // force redraw of title, or scroller might break
// reset auto exit interval // reset auto exit interval
@ -557,7 +518,6 @@ function startWatches() {
function start() { function start() {
makeUI(); makeUI();
startWatches(); startWatches();
tick();
startEmulator(); startEmulator();
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB