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

View File

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

View File

@ -21,3 +21,4 @@
0.19: Fix regression after back button added (returnToClock was called twice!) 0.19: Fix regression after back button added (returnToClock was called twice!)
0.20: Use Bangle.showClock for changing to clock 0.20: Use Bangle.showClock for changing to clock
0.21: Make the "App source not found" warning less buggy 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

@ -1,16 +1,17 @@
{ // must be inside our own scope here so that when we are unloaded everything disappears { // must be inside our own scope here so that when we are unloaded everything disappears
let s = require("Storage"); let s = require("Storage");
// handle customised launcher // handle customised launcher
let scaleval = 1; let scaleval = 1;
let vectorval = 20; let vectorval = 20;
let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
let settings = Object.assign({ if (g.getFonts().includes("22")) font="22"; // 2v26+
let settings = Object.assign({
showClocks: true, showClocks: true,
fullscreen: false fullscreen: false
}, s.readJSON("launch.json", true) || {}); }, s.readJSON("launch.json", true) || {});
if ("vectorsize" in settings) if ("vectorsize" in settings)
vectorval = parseInt(settings.vectorsize); vectorval = parseInt(settings.vectorsize);
if ("font" in settings){ if ("font" in settings){
if(settings.font == "Vector"){ if(settings.font == "Vector"){
scaleval = vectorval/20; scaleval = vectorval/20;
font = "Vector"+(vectorval).toString(); font = "Vector"+(vectorval).toString();
@ -18,11 +19,11 @@ if ("font" in settings){
font = settings.font; font = settings.font;
scaleval = (font.split("x")[1])/20; scaleval = (font.split("x")[1])/20;
} }
} }
// cache app list so launcher loads more quickly // cache app list so launcher loads more quickly
let launchCache = s.readJSON("launch.cache.json", true)||{}; let launchCache = s.readJSON("launch.cache.json", true)||{};
let launchHash = require("Storage").hash(/\.info/); let launchHash = require("Storage").hash(/\.info/);
if (launchCache.hash!=launchHash) { if (launchCache.hash!=launchHash) {
launchCache = { launchCache = {
hash : launchHash, hash : launchHash,
apps : s.list(/\.info$/) apps : s.list(/\.info$/)
@ -36,23 +37,22 @@ if (launchCache.hash!=launchHash) {
return 0; return 0;
}) }; }) };
s.writeJSON("launch.cache.json", launchCache); s.writeJSON("launch.cache.json", launchCache);
} }
let apps = launchCache.apps; let apps = launchCache.apps;
// Now apps list is loaded - render // Now apps list is loaded - render
if (!settings.fullscreen) if (!settings.fullscreen)
Bangle.loadWidgets(); Bangle.loadWidgets();
const drawMenu = () => { const drawMenu = () => {
E.showScroller({ E.showScroller({
h : 64*scaleval, c : apps.length, h : 50*scaleval, c : apps.length,
draw : (i, r) => { draw : (i, r) => {
var app = apps[i]; var app = apps[i];
if (!app) return; if (!app) return;
g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1)); 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));
g.setFont(font).setFontAlign(-1,0).drawString(app.name,64*scaleval,r.y+(32*scaleval));
if (app.icon) { if (app.icon) {
if (!app.img) app.img = s.read(app.icon); // load icon if it wasn't loaded 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 => { select : i => {
@ -85,9 +85,9 @@ const drawMenu = () => {
lockTimeout = setTimeout(Bangle.showClock, 10000); lockTimeout = setTimeout(Bangle.showClock, 10000);
} }
Bangle.on("lock", lockHandler); Bangle.on("lock", lockHandler);
}; };
drawMenu(); drawMenu();
if (!settings.fullscreen) // finally draw widgets if (!settings.fullscreen) // finally draw widgets
Bangle.drawWidgets(); Bangle.drawWidgets();
} }

View File

@ -2,7 +2,7 @@
"id": "launch", "id": "launch",
"name": "Launcher", "name": "Launcher",
"shortName": "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.", "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", "readme": "README.md",
"icon": "app.png", "icon": "app.png",