forked from FOSS/BangleApps
extension adding an extra screen to launch on swipes from
change type to app add placeholder JS iconmaster
parent
716af7c18b
commit
4534eae73f
|
@ -7,3 +7,5 @@
|
|||
0.07: Revert version 0.06. This version is the same as 0.05.
|
||||
0.08: Respect appRect on touch events
|
||||
0.09: Do not react if clkinfo is focused
|
||||
0.10: Extend the functionality via a quicklaunch app that can be launched
|
||||
with quicklaunch itself.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("lEoxH+AB8WAAwYQEaQrdEp4pWEyYoRC49kxGs2fX6+z1mIsgpUCQtAxAjCAA+zxFAFCAQFxAkJAAuIFBxMF1oeHgEABI+sFBomEORInJPgJ7EEyonLFAJQJBIh0IE5x6GE47CME5nXsgnGOojmME5p5HJyAnO6+IE5LEKE6JQEE4lkC5gnPUIh2SE6B4EAAesC5oAP1gnHTxpPDAQIAFeJQACH5wnP64nWAA3CBJB3WAA203fQBAp3IY4plENQ4HC2gABkjHNxAnX2nJBYeIEYf+AYVkE5oDGE4e0UgdkEwYnDUAITEACikBTwgnFxAnZFAJ2FE4lAJ7dAE4pQFY6yfCToYmDE4kW1jvX1geEE4YoF2YfFABRzD67EEEwqiGFCAmETg5QJPQYAMTQJ0GE5AoGshSPYQgmKFA72BFJWzxBzEExgoIKYOI1grC2esxBLGExwpKABolPFCwmSFKQlVFZoXP"))
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
const storage = require("Storage");
|
||||
let settings = storage.readJSON("quicklaunch.json", true) || {};
|
||||
let wu =require("widget_utils");
|
||||
|
||||
let reset = function(name){
|
||||
if (!settings[name]) settings[name] = {"name":"(none)"};
|
||||
if (!storage.read(settings[name].src)) settings[name] = {"name":"(none)"};
|
||||
storage.write("quicklaunch.json", settings);
|
||||
};
|
||||
|
||||
let touchHandler = (_,e) => {
|
||||
let R = Bangle.appRect;
|
||||
if (e.x < R.x || e.x > R.x2 || e.y < R.y || e.y > R.y2 ) return;
|
||||
if (settings.exttapapp.src){ if (settings.exttapapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.exttapapp.src)) reset("exttapapp"); else load(settings.exttapapp.src); }
|
||||
};
|
||||
|
||||
let swipeHandler = (lr,ud) => {
|
||||
if (lr == -1 && settings.extleftapp && settings.extleftapp.src){ if (settings.extleftapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.extleftapp.src)) reset("extleftapp"); else load(settings.extleftapp.src); }
|
||||
if (lr == 1 && settings.extrightapp && settings.extrightapp.src){ if (settings.extrightapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.extrightapp.src)) reset("extrightapp"); else load(settings.extrightapp.src); }
|
||||
if (ud == -1 && settings.extupapp && settings.extupapp.src){ if (settings.extupapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.extupapp.src)) reset("extupapp"); else load(settings.extupapp.src); }
|
||||
if (ud == 1 && settings.extdownapp && settings.extdownapp.src){ if (settings.extdownapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.extdownapp.src)) reset("extdownapp"); else load(settings.extdownapp.src); }
|
||||
};
|
||||
|
||||
Bangle.setUI({
|
||||
mode: "custom",
|
||||
touch: touchHandler,
|
||||
swipe : swipeHandler,
|
||||
remove: ()=>{}
|
||||
});
|
||||
|
||||
Bangle.loadWidgets();
|
||||
wu.hide();
|
||||
g.clear();
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
let settings = require("Storage").readJSON("quicklaunch.json", true) || {};
|
||||
const storage = require("Storage");
|
||||
let settings = storage.readJSON("quicklaunch.json", true) || {};
|
||||
|
||||
let reset = function(name){
|
||||
if (!settings[name]) settings[name] = {"name":"(none)"};
|
||||
if (!require("Storage").read(settings[name].src)) settings[name] = {"name":"(none)"};
|
||||
if (!storage.read(settings[name].src)) settings[name] = {"name":"(none)"};
|
||||
storage.write("quicklaunch.json", settings);
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
if (Bangle.CLKINFO_FOCUS) return;
|
||||
let R = Bangle.appRect;
|
||||
if (e.x < R.x || e.x > R.x2 || e.y < R.y || e.y > R.y2 ) return;
|
||||
if (settings.tapapp.src){ if (!storage.read(settings.tapapp.src)) reset("tapapp"); else load(settings.tapapp.src); }
|
||||
if (settings.tapapp.src){ if (settings.tapapp.name == "Show Launcher") Bangle.showLauncher(); else if (!storage.read(settings.tapapp.src)) reset("tapapp"); else load(settings.tapapp.src); }
|
||||
});
|
||||
|
||||
Bangle.on("swipe", (lr,ud) => {
|
||||
|
|
|
@ -2,14 +2,35 @@
|
|||
"id": "quicklaunch",
|
||||
"name": "Quick Launch",
|
||||
"icon": "app.png",
|
||||
"version":"0.09",
|
||||
"version": "0.10",
|
||||
"description": "Tap or swipe left/right/up/down on your clock face to launch up to five apps of your choice. Configurations can be accessed through Settings->Apps.",
|
||||
"type": "bootloader",
|
||||
"type": "app",
|
||||
"tags": "tools, system",
|
||||
"supports": ["BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"quicklaunch.settings.js","url":"settings.js"},
|
||||
{"name":"quicklaunch.boot.js","url":"boot.js"}
|
||||
"supports": [
|
||||
"BANGLEJS2"
|
||||
],
|
||||
"data": [{"name":"quicklaunch.json"}]
|
||||
"storage": [
|
||||
{
|
||||
"name": "quicklaunch.settings.js",
|
||||
"url": "settings.js"
|
||||
},
|
||||
{
|
||||
"name": "quicklaunch.boot.js",
|
||||
"url": "boot.js"
|
||||
},
|
||||
{
|
||||
"name": "quicklaunch.app.js",
|
||||
"url": "app.js"
|
||||
},
|
||||
{
|
||||
"name": "quicklaunch.img",
|
||||
"url": "app-icon.js",
|
||||
"evaluate": true
|
||||
}
|
||||
],
|
||||
"data": [
|
||||
{
|
||||
"name": "quicklaunch.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
(function(back) {
|
||||
var settings = Object.assign(require("Storage").readJSON("quicklaunch.json", true) || {});
|
||||
var storage = require("Storage");
|
||||
var settings = Object.assign(storage.readJSON("quicklaunch.json", true) || {});
|
||||
|
||||
for (let c of ["leftapp","rightapp","upapp","downapp","tapapp"]){
|
||||
for (let c of ["leftapp","rightapp","upapp","downapp","tapapp","extleftapp","extrightapp","extupapp","extdownapp","exttapapp"]){
|
||||
if (!settings[c]) settings[c] = {"name":"(none)"};
|
||||
}
|
||||
|
||||
var apps = require("Storage").list(/\.info$/).map(app=>{var a=require("Storage").readJSON(app,1);return a&&{name:a.name,type:a.type,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="launch" || app.type=="clock" || !app.type));
|
||||
var apps = storage.list(/\.info$/).map(app=>{var a=storage.readJSON(app,1);return a&&{name:a.name,type:a.type,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="launch" || app.type=="clock" || !app.type));
|
||||
|
||||
// Add psuedo app to trigger Bangle.showLauncher later
|
||||
apps.push({
|
||||
"name": "Show Launcher",
|
||||
"type": undefined, "sortorder": -10,
|
||||
"src": "no sorce"
|
||||
"src": "no source"
|
||||
});
|
||||
|
||||
apps.sort((a,b)=>{
|
||||
|
@ -24,11 +25,11 @@ apps.sort((a,b)=>{
|
|||
|
||||
function save(key, value) {
|
||||
settings[key] = value;
|
||||
require("Storage").write("quicklaunch.json",settings);
|
||||
storage.write("quicklaunch.json",settings);
|
||||
}
|
||||
|
||||
// Quick Launch menu
|
||||
function showMainMenu() {
|
||||
// Quick Launch menu
|
||||
var mainmenu = {
|
||||
"" : { "title" : "Quick Launch" },
|
||||
"< Back" : ()=>{load();}
|
||||
|
@ -40,6 +41,7 @@ function showMainMenu() {
|
|||
mainmenu["Up: "+settings.upapp.name] = function() { E.showMenu(upmenu); };
|
||||
mainmenu["Down: "+settings.downapp.name] = function() { E.showMenu(downmenu); };
|
||||
mainmenu["Tap: "+settings.tapapp.name] = function() { E.showMenu(tapmenu); };
|
||||
mainmenu["Extend Quick Launch"] = showExtMenu;
|
||||
|
||||
return E.showMenu(mainmenu);
|
||||
}
|
||||
|
@ -129,5 +131,107 @@ apps.forEach((a)=>{
|
|||
};
|
||||
});
|
||||
|
||||
function showExtMenu() {
|
||||
// Extend Quick Launch menu
|
||||
var extmenu = {
|
||||
"" : { "title" : "Extend Quick Launch" },
|
||||
"< Back" : ()=>{showMainMenu();}
|
||||
};
|
||||
|
||||
//List all selected apps
|
||||
extmenu["Left: "+settings.extleftapp.name] = function() { E.showMenu(extleftmenu); };
|
||||
extmenu["Right: "+settings.extrightapp.name] = function() { E.showMenu(extrightmenu); };
|
||||
extmenu["Up: "+settings.extupapp.name] = function() { E.showMenu(extupmenu); };
|
||||
extmenu["Down: "+settings.extdownapp.name] = function() { E.showMenu(extdownmenu); };
|
||||
extmenu["Tap: "+settings.exttapapp.name] = function() { E.showMenu(exttapmenu); };
|
||||
|
||||
return E.showMenu(extmenu);
|
||||
}
|
||||
|
||||
//Extension Left swipe menu
|
||||
var extleftmenu = {
|
||||
"" : { "title" : "Extension Left Swipe" },
|
||||
"< Back" : showExtMenu
|
||||
};
|
||||
|
||||
extleftmenu["(none)"] = function() {
|
||||
save("extleftapp", {"name":"(none)"});
|
||||
showExtMenu();
|
||||
};
|
||||
apps.forEach((a)=>{
|
||||
extleftmenu[a.name] = function() {
|
||||
save("extleftapp", a);
|
||||
showExtMenu();
|
||||
};
|
||||
});
|
||||
|
||||
//Extension Right swipe menu
|
||||
var extrightmenu = {
|
||||
"" : { "title" : "Extension Right Swipe" },
|
||||
"< Back" : showExtMenu
|
||||
};
|
||||
|
||||
extrightmenu["(none)"] = function() {
|
||||
save("extrightapp", {"name":"(none)"});
|
||||
showExtMenu();
|
||||
};
|
||||
apps.forEach((a)=>{
|
||||
extrightmenu[a.name] = function() {
|
||||
save("extrightapp", a);
|
||||
showExtMenu();
|
||||
};
|
||||
});
|
||||
|
||||
//Extension Up swipe menu
|
||||
var extupmenu = {
|
||||
"" : { "title" : "Extension Up Swipe" },
|
||||
"< Back" : showExtMenu
|
||||
};
|
||||
|
||||
extupmenu["(none)"] = function() {
|
||||
save("extupapp", {"name":"(none)"});
|
||||
showExtMenu();
|
||||
};
|
||||
apps.forEach((a)=>{
|
||||
extupmenu[a.name] = function() {
|
||||
save("extupapp", a);
|
||||
showExtMenu();
|
||||
};
|
||||
});
|
||||
|
||||
//Extension Down swipe menu
|
||||
var extdownmenu = {
|
||||
"" : { "title" : "Extension Down Swipe" },
|
||||
"< Back" : showExtMenu
|
||||
};
|
||||
|
||||
downmenu["(none)"] = function() {
|
||||
save("extdownapp", {"name":"(none)"});
|
||||
showExtMenu();
|
||||
};
|
||||
apps.forEach((a)=>{
|
||||
extdownmenu[a.name] = function() {
|
||||
save("extdownapp", a);
|
||||
showExtMenu();
|
||||
};
|
||||
});
|
||||
|
||||
//Extension Tap menu
|
||||
var exttapmenu = {
|
||||
"" : { "title" : "Extension Tap" },
|
||||
"< Back" : showExtMenu
|
||||
};
|
||||
|
||||
exttapmenu["(none)"] = function() {
|
||||
save("exttapapp", {"name":"(none)"});
|
||||
showExtMenu();
|
||||
};
|
||||
apps.forEach((a)=>{
|
||||
exttapmenu[a.name] = function() {
|
||||
save("exttapapp", a);
|
||||
showExtMenu();
|
||||
};
|
||||
});
|
||||
|
||||
showMainMenu();
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue