Launchers: Only store relevant app data (saves RAM when many apps)

pull/309/head^2
Gordon Williams 2020-04-16 09:16:37 +01:00
parent 078a3e6d5f
commit e0a3b9ae3e
5 changed files with 11 additions and 8 deletions

View File

@ -41,7 +41,7 @@
"name": "Default Launcher",
"shortName":"Launcher",
"icon": "app.png",
"version":"0.01",
"version":"0.02",
"description": "This is needed by Bangle.js to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
"tags": "tool,system,launcher",
"type":"launch",
@ -1050,7 +1050,7 @@
"name": "Touch Launcher",
"shortName":"Menu",
"icon": "app.png",
"version":"0.05",
"version":"0.06",
"description": "Touch enable left to right launcher.",
"tags": "tool,system,launcher",
"type":"launch",

2
apps/launch/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.01: New App!
0.02: Only store relevant app data (saves RAM when many apps)

View File

@ -1,5 +1,5 @@
var s = require("Storage");
var apps = s.list(/\.info$/).map(app=>s.readJSON(app,1)||{name:"DEAD: "+app.substr(1)}).filter(app=>app.type=="app" || app.type=="clock" || !app.type);
var apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src}}).filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type));
apps.sort((a,b)=>{
var n=(0|a.sortorder)-(0|b.sortorder);
if (n) return n; // do sortorder first

View File

@ -2,4 +2,5 @@
0.02: Add swipe support and doucle tap to run application
0.03: Close launcher when lcd turn off
0.04: Complete rewrite to add animation and loop ( issue #210 )
0.05: Improve perf
0.05: Improve perf
0.06: Only store relevant app data (saves RAM when many apps)

View File

@ -5,8 +5,8 @@ g.flip();
const Storage = require("Storage");
function getApps(){
return Storage.list(/\.info$/).filter(app => app.endsWith('.info')).map(app => Storage.readJSON(app,1) || { name: "DEAD: "+app.substr(1) })
.filter(app=>app.type=="app" || app.type=="clock" || !app.type)
return Storage.list(/\.info$/).map(app=>{var a=Storage.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src,version:a.version}})
.filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type))
.sort((a,b)=>{
var n=(0|a.sortorder)-(0|b.sortorder);
if (n) return n; // do sortorder first
@ -19,7 +19,7 @@ function getApps(){
const HEIGHT = g.getHeight();
const WIDTH = g.getWidth();
const HALF = WIDTH/2;
const ANIMATION_FRAME = 4;
const ANIMATION_FRAME = 4;
const ANIMATION_STEP = HALF / ANIMATION_FRAME;
function getPosition(index){
@ -192,4 +192,4 @@ Bangle.on('swipe', dir => {
// close launcher when lcd is off
Bangle.on('lcdPower', on => {
if(!on) return load();
});
});