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.09: Move event listener from widget to boot code, stops music from showing up in messages
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
* Scrolling display for long titles
* Automatic start when music plays
* Time and date display
## Settings

View File

@ -10,15 +10,15 @@ const BANGLE2 = process.env.HWVERSION===2;
/**
* @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) {
return Infinity;
}
// make a guess, then shrink/grow until it fits
const w = Bangle.appRect.w,
test = (s) => g.setFont("Vector", s).stringWidth(text);
const test = (s) => g.setFont("Vector", s).stringWidth(text);
let best = Math.floor(100*w/test(100));
if (test(best)===w) { // good guess!
return best;
@ -106,7 +106,7 @@ function rTitle(l) {
rScroller(l); // already scrolling
return;
}
let size = fitText(l.label);
let size = fitText(l.label, l.w);
if (size<l.h/2) {
// the title is too long: start the scroller
scrollStart();
@ -119,7 +119,7 @@ function rTitle(l) {
* @param l
*/
function rInfo(l) {
let size = fitText(l.label);
let size = fitText(l.label, l.w);
if (size>l.h) {
size = l.h;
}
@ -182,21 +182,17 @@ function makeUI() {
type: "v", 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},
{id: "num", type: "txt", label: "88:88", valign: -1, halign: 1, font: "12%", bgCol: g.theme.bg},
BANGLE2 ? {} : {id: "up", type: "txt", label: " +", font: "6x8:2"},
{id: "num", type: "txt", label: "", valign: -1, halign: -1, font: "12%", bgCol: g.theme.bg},
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: "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: [
{width: 3},
{id: "date", type: "txt", halign: 0, valign: 1, label: "", font: "8%", fillx: 1, bgCol: g.theme.bg},
BANGLE2 ? {width: 3} : {id: "down", type: "txt", label: " -", font: "6x8:2"},
{id: "album", type: "custom", label: "", fillx: 1, filly: 1, size: 20, render: rInfo, bgCol: g.theme.bg},
BANGLE2 ? {} : {id: "down", type: "txt", label: " -", font: "6x8:2"},
],
},
{height: 10},
@ -209,20 +205,6 @@ function makeUI() {
// 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
let fade = null;
function fadeOut() {
@ -269,28 +251,6 @@ function scrollStop() {
////////////////////
// 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() {
if (BANGLE2) return;
@ -331,6 +291,7 @@ function info(info) {
layout.album.col = infoColor("album");
layout.artist.col = infoColor("artist");
layout.num.label = formatNum(info);
layout.update();
layout.render();
rTitle(layout.title); // force redraw of title, or scroller might break
// reset auto exit interval
@ -557,7 +518,6 @@ function startWatches() {
function start() {
makeUI();
startWatches();
tick();
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