update icon and default launcher to use the new 2v26 fonts if available

master
Gordon Williams 2025-03-07 17:07:30 +00:00
parent f01bfd5972
commit ca95ce03dd
6 changed files with 108 additions and 116 deletions

View File

@ -24,3 +24,4 @@
0.17: fix fullscreen with oneClickExit
0.18: Better performance
0.19: Remove 'jit' keyword as 'for(..of..)' is not supported (fix #2937)
0.20: Use '28' font if installed (2v26+) and put it inside a rounded rect in the current theme

View File

@ -8,6 +8,7 @@
swipeExit: false,
timeOut:"Off"
}, s.readJSON("iconlaunch.json", true) || {});
let font = g.getFonts().includes("28") ? "28" : "12x20";
if (!settings.fullscreen) {
Bangle.loadWidgets();
@ -56,12 +57,7 @@
let texted;
let drawItem = function(itemI, r) {
let x = whitespace;
let i = itemI * appsN - 1;
let selectedApp;
let c;
let selectedRect;
let item = launchCache.items[itemI];
let x = whitespace, i = itemI * appsN - 1, selectedApp, c, selectedRect, item = launchCache.items[itemI];
if (texted == itemI){
g.clearRect(r.x, r.y, r.x + r.w - 1, r.y + r.h - 1);
texted = undefined;
@ -89,20 +85,20 @@
};
let drawText = function(i, appY, selectedApp) {
"jit";
const idy = (selectedItem - (selectedItem % 3)) / 3;
if (i != idy) return;
appY = appY + itemSize/2;
g.setFontAlign(0, 0, 0);
g.setFont("12x20");
g.setFontAlign(0, 0, 0).setFont(font);
const rect = g.stringMetrics(selectedApp.name);
g.clearRect(
R.w / 2 - rect.width / 2 - 2,
appY - rect.height / 2 - 2,
R.w / 2 + rect.width / 2 + 1,
appY + rect.height / 2 + 1
);
g.drawString(selectedApp.name, R.w / 2, appY);
let r = {
x : (R.w - rect.width) / 2 - 7,
y : appY - rect.height / 2 - 6,
w : rect.width + 15,
h : rect.height + 10,
r : 4
};
g.setBgColor(g.theme.bgH).clearRect(r);
g.setBgColor(g.theme.bg2).clearRect({x:r.x+2, y:r.y+2, w:r.w-4, h:r.h-4, r:3}).drawString(selectedApp.name, R.w / 2, appY).reset();
};
let selectItem = function(id, e) {
@ -146,21 +142,15 @@
};
//work both the fullscreen and the oneClickExit
if( settings.fullscreen && settings.oneClickExit)
{
if( settings.fullscreen && settings.oneClickExit) {
idWatch=setWatch(function(e) {
Bangle.showClock();
}, BTN, {repeat:false, edge:'rising' });
}
else if( settings.oneClickExit )
{
} else if( settings.oneClickExit ) {
options.back=Bangle.showClock;
}
let scroller = E.showScroller(options);
let timeout;

View File

@ -2,7 +2,7 @@
"id": "iconlaunch",
"name": "Icon Launcher",
"shortName" : "Icon launcher",
"version": "0.19",
"version": "0.20",
"icon": "app.png",
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",
"tags": "tool,system,launcher",

View File

@ -21,3 +21,4 @@
0.19: Fix regression after back button added (returnToClock was called twice!)
0.20: Use Bangle.showClock for changing to clock
0.21: Make the "App source not found" warning less buggy
0.22: Add less padding between launcher items, use new font if available in 2v26+

View File

@ -4,6 +4,7 @@ let s = require("Storage");
let scaleval = 1;
let vectorval = 20;
let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
if (g.getFonts().includes("22")) font="22"; // 2v26+
let settings = Object.assign({
showClocks: true,
fullscreen: false
@ -44,15 +45,14 @@ if (!settings.fullscreen)
const drawMenu = () => {
E.showScroller({
h : 64*scaleval, c : apps.length,
h : 50*scaleval, c : apps.length,
draw : (i, r) => {
var app = apps[i];
if (!app) return;
g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1));
g.setFont(font).setFontAlign(-1,0).drawString(app.name,64*scaleval,r.y+(32*scaleval));
g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1)).setFont(font).setFontAlign(-1,0).drawString(app.name,54*scaleval,r.y+(27*scaleval));
if (app.icon) {
if (!app.img) app.img = s.read(app.icon); // load icon if it wasn't loaded
try {g.drawImage(app.img,8*scaleval, r.y+(8*scaleval), {scale: scaleval});} catch(e){}
try {g.drawImage(app.img,3*scaleval, r.y+(3*scaleval), {scale: scaleval});} catch(e){}
}
},
select : i => {

View File

@ -2,7 +2,7 @@
"id": "launch",
"name": "Launcher",
"shortName": "Launcher",
"version": "0.21",
"version": "0.22",
"description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
"readme": "README.md",
"icon": "app.png",