Merge pull request #2576 from thyttan/quicklaunch
[quicklaunch] extension adding an extra screen to launch on swipes frommaster
commit
eadb7264fd
|
|
@ -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.js file that can be launched
|
||||
with quicklaunch itself.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Tap or swipe left/right/up/down on your clock face to launch up to five apps of your choice. The Quick Launch Extension (included) can be chosen as one of the apps, in turn providing fast access to up to five additional apps. Configurations can be accessed through Settings->Apps.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
const storage = require("Storage");
|
||||
let settings = storage.readJSON("quicklaunch.json", true) || {};
|
||||
|
||||
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: ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);} // Compatability with Fastload Utils.
|
||||
});
|
||||
|
||||
g.clearRect(Bangle.appRect);
|
||||
Bangle.loadWidgets(); // Compatability with Fastload Utils.
|
||||
|
||||
// taken from Icon Launcher with some alterations
|
||||
let timeoutToClock;
|
||||
const updateTimeoutToClock = function(){
|
||||
let time = 1000; // milliseconds
|
||||
if (timeoutToClock) clearTimeout(timeoutToClock);
|
||||
timeoutToClock = setTimeout(load,time);
|
||||
};
|
||||
updateTimeoutToClock();
|
||||
}
|
||||
|
|
@ -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,15 @@
|
|||
"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",
|
||||
"tags": "tools, system",
|
||||
"supports": ["BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"quicklaunch.settings.js","url":"settings.js"},
|
||||
{"name":"quicklaunch.boot.js","url":"boot.js"}
|
||||
{"name":"quicklaunch.boot.js","url":"boot.js"},
|
||||
{"name":"quicklaunch.app.js","url":"app.js"}
|
||||
],
|
||||
"data": [{"name":"quicklaunch.json"}]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
(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"
|
||||
"type": undefined,
|
||||
"sortorder": -12,
|
||||
"src": "no source"
|
||||
});
|
||||
|
||||
// Add the Quick Launch extension app
|
||||
apps.push({
|
||||
"name": "Quick Launch Extension",
|
||||
"type": "app",
|
||||
"sortorder": -11,
|
||||
"src": "quicklaunch.app.js"
|
||||
});
|
||||
|
||||
apps.sort((a,b)=>{
|
||||
|
|
@ -24,11 +34,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 +50,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 +140,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