====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_appdrawer_toggle_visibility [2014/09/14 15:09] lm13 |
script_appdrawer_toggle_visibility [2016/06/28 12:23] (current) f43nd1r |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== About the script ====== | ====== About the script ====== | ||
* Purpose : This script will toggle the Visibility of all shortcuts in the App Drawer. So on first run you only see the hidden Shortcuts, on the second run you have all your visible shortcuts back | * Purpose : This script will toggle the Visibility of all shortcuts in the App Drawer. So on first run you only see the hidden Shortcuts, on the second run you have all your visible shortcuts back | ||
- | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | + | * Author : F43nd1r |
- | * Current Version : 1.0 | + | * Current Version : 1.1 |
- | * Link : | + | * Link : https://plus.google.com/115366157037831519359/posts/YubDRu2LRLj |
====== Changelog ====== | ====== Changelog ====== | ||
* Version 1.0 (14/9/2014): initial release in wiki | * Version 1.0 (14/9/2014): initial release in wiki | ||
+ | * Version 1.1 (16/9/2014): use of JSON to reduce and simplify code, probably reduces Runtime | ||
Line 20: | Line 21: | ||
====== Script ====== | ====== Script ====== | ||
<sxh javascript;>//import java classes | <sxh javascript;>//import java classes | ||
- | LL.bindClass("java.io.FileReader");LL.bindClass("java.io.BufferedReader");LL.bindClass("java.io.FileWriter"); | + | LL.bindClass("java.io.FileReader"); |
+ | LL.bindClass("java.io.BufferedReader"); | ||
+ | LL.bindClass("java.io.FileWriter"); | ||
LL.bindClass("java.io.File"); | LL.bindClass("java.io.File"); | ||
LL.bindClass("java.lang.System"); | LL.bindClass("java.lang.System"); | ||
Line 35: | Line 38: | ||
if(i.getType()=="Folder")containers.push(i.getContainer().getId()); | if(i.getType()=="Folder")containers.push(i.getContainer().getId()); | ||
} | } | ||
- | + | ||
//create the needed structure | //create the needed structure | ||
var file=new File("data/data/net.pierrox.lightning_launcher_extreme/files/pages/"+containers[y]+"/items");//this file contains item properties | var file=new File("data/data/net.pierrox.lightning_launcher_extreme/files/pages/"+containers[y]+"/items");//this file contains item properties | ||
var r=new BufferedReader(new FileReader(file)); | var r=new BufferedReader(new FileReader(file)); | ||
var s=""; | var s=""; | ||
- | + | ||
//read the file | //read the file | ||
var l=r.readLine(); | var l=r.readLine(); | ||
Line 48: | Line 51: | ||
l=r.readLine(); | l=r.readLine(); | ||
} | } | ||
- | var found=false; | + | //toggle hidden for all shortcuts |
- | + | var data=JSON.parse(s); | |
- | //search through the text | + | for(var a=0;a<data.i.length;a++) |
- | for(var a=s.length-8;a>0;a--) | + | |
{ | { | ||
- | //find the shortcuts | + | if(data.i[a].a=="SHORTCUT") |
- | if(s.slice(a,a+8)=="SHORTCUT")found=true; | + | |
- | //if a shortcut found, toggle its "g" (hidden) property | + | |
- | else if(found&&s.slice(a,a+4)=="\"g\":") | + | |
{ | { | ||
- | if(s[a+4]=="t")s=s.slice(0,a+4)+"false"+s.slice(a+8,s.length); | + | data.i[a].g=!data.i[a].g; |
- | else s=s.slice(0,a+4)+"true"+s.slice(a+9,s.length); | + | |
- | found=false; | + | |
} | } | ||
} | } | ||
- | + | ||
//write the changed stuff back to the file | //write the changed stuff back to the file | ||
var w=new FileWriter(file); | var w=new FileWriter(file); | ||
- | w.write(s); | + | w.write(JSON.stringify(data)); |
w.flush(); | w.flush(); | ||
w.close(); | w.close(); | ||
Line 73: | Line 70: | ||
//restart the launcher | //restart the launcher | ||
System.runFinalization(); | System.runFinalization(); | ||
- | System.exit(2); | + | System.exit(0); |
</sxh> | </sxh> |