Skip to content

Commit be85c63

Browse files
authored
Merge pull request #4090 from RKBoss6/taglaunchupates
[TagLaunch] Add three optional app shortcuts at the top for quicker access to essential apps
2 parents d10a8b0 + 742d518 commit be85c63

File tree

6 files changed

+141
-19
lines changed

6 files changed

+141
-19
lines changed

apps/taglaunch/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
0.06: Fixed a crash if an app has no tags (app.tags is undefined)
88
0.07: Clear cached app list when updating showClocks setting
99
0.08: Add haptic feedback option when selecting app or category in menu, increase vector size limit in settings
10+
0.09: Add option to set up to 3 shortcut apps that you can access straight from the tag menu for quicker access

apps/taglaunch/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
Tag Launcher
22
========
33

4-
Based on the default launcher but puts all applications in a submenu by their tag.
4+
Based on the default launcher but puts all applications in a submenu by their tag. There are three customizable spots at the top of the launcher for quicker access to your favorite apps.
5+
56
With many applications installed this can result in a faster applications selection than the linear access of the default launcher.
67

78
Currently the following tags are supported: clock, game, tool, bluetooth, outdoors, health and misc.
89

910
Settings
1011
--------
11-
12+
- `Shortcuts` - Change the app shortcuts at the top of the launcher. If no apps are set as the shortcut, the launcher will not have a section at the top, instead beginning with the first tag. (Default: No shortcuts)
1213
- `Font` - The font used (`4x6`, `6x8`, `12x20`, `6x15` or `Vector`). Default `12x20`.
1314
- `Vector Font Size` - The size of the font if `Font` is set to `Vector`. Default `10`.
1415
- `Haptic Feedback` - Whether or not to vibrate slightly when selecting an app or category in the launcher. Default `No`.

apps/taglaunch/app.js

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{ // must be inside our own scope here so that when we are unloaded everything disappears
22
let s = require("Storage");
3-
43
// TODO: Allow to change sortorder in settings
54
let tags = {"clock": {name: /*LANG*/"Clocks", icon: () => atob("MDCEBERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERESIiIiIREREREREREREREREREREREREiIiIiIiIiIhERERERERERERERERERESIiIiIiIiIiIiIREREREREREREREREREiIiIiIiIiIiIiIhERERERERERERERESIiIiIgz//8ziIiIiIREREREREREREREiIiIg////////ziIiIhERERERERERERIiIiD//////////84iIiERERERERERESIiIg/////8A/////ziIiIRERERERERESIiI//////8A//////+IiIREREREREREiIiP//////8A///////4iIhERERERERIiIg///////8A///////ziIiERERERERIiIP///////8A////////OIiERERERESIiI////////8A////////+IiIRERERESIiD////////8A////////84iIRERERESIiP////////8A/////////4iIRERERESIiP////////8A/////////4iIREREREiIg/////////8A/////////ziIhEREREiIg/////////IAL////////ziIhEREREiIj////////yAAAv////////iIhEREREiIgiIv/////wCIAP/////yIiiIhEREREiIgiIv/////wCIAP/////yIiiIhEREREiIj////////yAAAD////////iIhEREREiIg/////////IAABP//////ziIhEREREiIg///////////IAE//////ziIhERERESIiP//////////8gAT/////4iIRERERESIiP///////////yABP////4iIRERERESIiD////////////IAL///84iIRERERESIiI////////////8i////+IiIRERERERIiIP/////////////////OIiERERERERIiIg////////////////ziIiEREREREREiIiP///////////////4iIhERERERERESIiI//////////////+IiIRERERERERESIiIg/////8i/////ziIiIRERERERERERIiIiD////8i////84iIiEREREREREREREiIiIg///8i///ziIiIhERERERERERERESIiIiIgz8i8ziIiIiIREREREREREREREREiIiIiIiIiIiIiIhERERERERERERERERESIiIiIiIiIiIiIREREREREREREREREREREiIiIiIiIiIhERERERERERERERERERERERESIiIiIRERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==")},
65
"game": {name: /*LANG*/"Games", sortorder: 1, icon: () => atob("MDCEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzMzMzMzMzMzMzMzMzMzMzMwAAAAAAAAAzMzMzMzMzMzMzMzMzMzMzMwAAAAAAAAAzIiIiIiIiIiIiIiIiIiIiMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzIiIi////IiIi////IiIiMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi///yMwAAAAAAAAAzL///IiIi////IiIi8R/xERABEAAAAAAzL///IiIi////IiIi8R/xERABEAAAAAAzL///IiIi////IiIi8R/xERABEAAAAAAzL///IiIi////IiIi8RMxERABEAAAAAAzIiIi////IiIi////IREREREREAAAAAAzIiIi////IiIi////IREREREREAAAAAAzIiIi////IiIi////IREREREREAAAAAAzIiIi////IiIi////IhERERERAAAAAAAzIiIi////IiIi////IiMzMzMwAAAAAAAzIiIi////IiIi////IiMzMzMwAAAAAAAzL///IiIi////IiIi///xERAAAAAAAAAzL///IiIi////IiIi//8xERAAAAAAAAAzL///IiIi////IiIi//8hEREAAAAAAAAzL///IiIi////IiIi//8REREAAAAAAAAzL///IiIi////IiIi//MREREAAAAAAAAzIiIiIiIiIiIiIiIiIzMzMzMzMAAAAAAzMzMzMzMzMzMzMzMzMzMzMzMzMAAAAAAzMzMzMzMzMzMzMzMzMhEREREREAAAAAAAAAAAAAAAAAAAAAAAEREREREREQAAAAAAAAAAAAAAAAAAAAAAEREREREREQAAAAAAAAAAAAAAAAAAAAAAEREREREREQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==")},
@@ -18,7 +17,8 @@ let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
1817
let settings = Object.assign({
1918
showClocks: true,
2019
fullscreen: false,
21-
buzz:false
20+
buzz:false,
21+
shortcuts:["","",""]
2222
}, s.readJSON("taglaunch.json", true) || {});
2323
if ("vectorsize" in settings)
2424
vectorval = parseInt(settings.vectorsize);
@@ -84,6 +84,15 @@ const unload = () => {
8484
Bangle.removeListener("lock", lockHandler);
8585
};
8686

87+
let shortcuts=settings.shortcuts;
88+
let noShortcuts=shortcuts[0]==""&&shortcuts[1]==""&&shortcuts[2]=="";
89+
90+
let loadShortcut=function(idx){
91+
if(shortcuts[idx]!=""){
92+
const p = settings.buzz ? Bangle.buzz(25) : Promise.resolve();
93+
p.then(() => load(shortcuts[idx]+".app.js"));
94+
}
95+
};
8796
// 10s of inactivity goes back to clock
8897
Bangle.setLocked(false); // unlock initially
8998
let lockTimeout;
@@ -137,21 +146,46 @@ let showTagMenu = (tag) => {
137146

138147
let showMainMenu = () => {
139148
E.showScroller({
140-
h : 64*scaleval, c : tagKeys.length,
149+
h : 64*scaleval, c : noShortcuts ? tagKeys.length : tagKeys.length+1,
141150
draw : (i, r) => {
142-
let tag = tagKeys[i];
143151
g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1));
144-
g.setFont(font).setFontAlign(-1,0).drawString(tags[tag].name,64*scaleval,r.y+(32*scaleval));
152+
153+
if(!noShortcuts)i-=1;
154+
if(i==-1){
155+
for(let j=0;j<3;j++){
156+
const img = s.read(shortcuts[j]+".img");
157+
if (img) {
158+
try {
159+
g.drawImage(img,8*scaleval+((g.getWidth()/3)*j), r.y+(8*scaleval), {scale: scaleval});}
160+
catch(e){}
161+
}
162+
}
163+
164+
165+
}else{
166+
let tag = tagKeys[i]; g.setFont(font).setFontAlign(-1,0).drawString(tags[tag].name,64*scaleval,r.y+(32*scaleval));
145167

146-
const img = tags[tag].icon ? tags[tag].icon() : s.read("taglaunch." + tag + ".img");
147-
if (img) {
148-
try {g.drawImage(img,8*scaleval, r.y+(8*scaleval), {scale: scaleval});} catch(e){}
168+
const img = tags[tag].icon ? tags[tag].icon() : s.read("taglaunch." + tag + ".img");
169+
if (img) {
170+
try {g.drawImage(img,8*scaleval, r.y+(8*scaleval), {scale: scaleval});} catch(e){}
171+
}
149172
}
150173
},
151-
select : i => {
152-
if(settings.buzz)Bangle.buzz(25);
153-
let tag = tagKeys[i];
154-
showTagMenu(tag);
174+
select : (i,e) => {
175+
if(!noShortcuts)i-=1;
176+
if(i==-1){
177+
if(e.x<g.getWidth()/3){
178+
loadShortcut(0)
179+
}else if(e.x<(g.getWidth()/3)*2){
180+
loadShortcut(1)
181+
}else{
182+
loadShortcut(2)
183+
}
184+
}else{
185+
if(settings.buzz)Bangle.buzz(25);
186+
let tag = tagKeys[i];
187+
showTagMenu(tag);
188+
}
155189
},
156190
back : Bangle.showClock, // button press or tap in top left shows clock now
157191
remove : unload

apps/taglaunch/metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"id": "taglaunch",
33
"name": "Tag Launcher",
44
"shortName": "Taglauncher",
5-
"version": "0.08",
5+
"version": "0.09",
66
"author": "nxdefiant",
7-
"description": "Launcher that puts all applications into submenus based on their tag. With many applications installed this can result in a faster application selection than the linear access from the default launcher.",
7+
"description": "Launcher that puts all applications into submenus based on their tag, with three customizable app shortcuts at the top. With many applications installed this can result in a faster application selection than the linear access from the default launcher.",
88
"readme": "README.md",
99
"icon": "app.png",
1010
"type": "launch",
1111
"tags": "tool,system,launcher",
1212
"supports": ["BANGLEJS2"],
13-
"screenshots": [ {"url":"screenshot.png"} ],
13+
"screenshots": [ {"url":"screenshot.png"},{"url":"screenshot2.png"} ],
1414
"storage": [
1515
{"name":"taglaunch.app.js","url":"app.js"},
1616
{"name":"taglaunch.settings.js","url":"settings.js"}

apps/taglaunch/screenshot2.png

5.36 KB
Loading

apps/taglaunch/settings.js

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,105 @@
11
// make sure to enclose the function in parentheses
22
(function(back) {
3+
4+
let launchCache;
35
let settings = Object.assign({
46
showClocks: true,
57
fullscreen: false,
6-
buzz:false
8+
buzz:false,
9+
shortcuts:["","",""]
710
}, require("Storage").readJSON("taglaunch.json", true) || {});
8-
911
let fonts = g.getFonts();
1012
function save(key, value) {
1113
settings[key] = value;
1214
require("Storage").write("taglaunch.json",settings);
1315
}
16+
17+
function setShortcut(id,spot,bk){
18+
let shortcuts=settings.shortcuts;
19+
shortcuts[spot]=id;
20+
save("shortcuts",shortcuts);
21+
bk();
22+
}
23+
24+
function showAppList(spot,bk){
25+
//make sure cache is present
26+
launchCache=require("Storage").readJSON("taglaunch.cache.json");
27+
if (!launchCache || !launchCache.appsByTag) {
28+
E.showAlert("Caching apps, returning to launcher","Loading").then(function(v){
29+
Bangle.load("taglaunch.app.js");
30+
});
31+
} else {
32+
var appsByTag = launchCache.appsByTag;
33+
var appsById = {};
34+
for (var tag in appsByTag) {
35+
var list = appsByTag[tag];
36+
for (var i = 0; i < list.length; i++) {
37+
var app = list[i];
38+
// Use app.id as key to deduplicate
39+
if (!appsById[app.id]) {
40+
appsById[app.id] = {
41+
name: app.name,
42+
src: app.src || app.name,
43+
id: app.id
44+
};
45+
}
46+
}
47+
}
48+
var apps = Object.values(appsById);
49+
50+
var menu = {};
51+
var spotText="";
52+
if(spot==0)spotText+="Left ";
53+
if(spot==1)spotText+="Center ";
54+
if(spot==2)spotText+="Right ";
55+
spotText+="App";
56+
menu[""] = { "title" : spotText }; // Title for the menu
57+
58+
menu["None"] = function(){
59+
60+
E.showPrompt("Remove the "+spotText+" shortcut?",{
61+
title:"Confirm",
62+
buttons: {"Cancel":false,"Ok":true}
63+
}).then(function(v){
64+
if(v)setShortcut("",spot,bk);
65+
else showAppList(spot,bk)
66+
})
67+
}
68+
apps.forEach(a => {
69+
menu[a.name] = function(){
70+
E.showPrompt("Set "+a.name+" as the "+spotText+"?",{
71+
title:"Confirm",
72+
buttons: {"Cancel":false,"Ok":true}
73+
}).then(function(v){
74+
if(v)setShortcut(a.id,spot,bk);
75+
else showAppList(spot,bk)
76+
})
77+
}
78+
});
79+
menu["< Back"] = bk;
80+
81+
// Show it
82+
E.showMenu(menu);
83+
}
84+
}
85+
86+
function showSpotMenu(){
87+
E.showMenu({
88+
"":{ "title" : "Select Spot"}, // Title for the menu
89+
"< Back":function(){
90+
eval(require("Storage").read("taglaunch.settings.js"))(()=>load());
91+
},
92+
"Left": function() { showAppList(0,showSpotMenu); },
93+
"Center": function() { showAppList(1,showSpotMenu); },
94+
"Right": function() { showAppList(2,showSpotMenu);}
95+
})
96+
}
1497
const appMenu = {
1598
"": { "title": /*LANG*/"Tag Launcher" },
1699
"< Back": back,
100+
/*LANG*/"Shortcuts": function(){
101+
showSpotMenu()
102+
},
17103
/*LANG*/"Font": {
18104
value: fonts.includes(settings.font)? fonts.indexOf(settings.font) : fonts.indexOf("12x20"),
19105
min:0, max:fonts.length-1, step:1,wrap:true,

0 commit comments

Comments
 (0)