====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_dim_bg [2015/01/16 16:55] lm13 Added spoiler |
script_dim_bg [2015/07/25 12:19] (current) lm13 |
||
---|---|---|---|
Line 2: | Line 2: | ||
* Purpose : This script will dim all other stuff if you open a folder | * Purpose : This script will dim all other stuff if you open a folder | ||
* Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | ||
- | * Current Version : 2.3 | ||
* Link : https://plus.google.com/115366157037831519359/posts/24AHYbCWrXn | * Link : https://plus.google.com/115366157037831519359/posts/24AHYbCWrXn | ||
* Video : https://plus.google.com/115366157037831519359/posts/3ZY4BWnZbmp | * Video : https://plus.google.com/115366157037831519359/posts/3ZY4BWnZbmp | ||
- | * Download avialable! (Check repository) | + | * Download available! (Check repository) |
- | + | ||
- | ====== Changelog ====== | + | |
- | * Version 2.0 (28/5/2014): initial release in wiki | + | |
- | * Version 2.1 (18/7/2014): auto create item | + | |
- | * Version 2.2 (16/11/2014): bugfix, apk version contains UI | + | |
- | * Version 2.3 (4/12/2014): bugfix | + | |
====== How to use the script ====== | ====== How to use the script ====== | ||
- | * in the folder: set the dim script to paused and resumed event | + | * see Play Store |
- | * set up configuration if you don't like the standard values | + | |
- | * Note: this is the manual way, you won't need the setup script for this way | + | |
- | + | ||
- | Or: Simply load the apk in that folder | + | |
====== Issues and hints ====== | ====== Issues and hints ====== | ||
Line 36: | Line 25: | ||
LL.bindClass("android.text.InputType"); | LL.bindClass("android.text.InputType"); | ||
- | var MY_PKG="net.pierrox.lightning_launcher.llscript.dimbackground"; | + | var MY_PKG="com.faendir.lightning_launcher.dimbackground"; |
// install (or update) a script given its id in the package, and its clear name in the launcher data | // install (or update) a script given its id in the package, and its clear name in the launcher data | ||
function installScript(id,name){ | function installScript(id,name){ | ||
Line 67: | Line 56: | ||
var c=LL.getEvent().getContainer(); | var c=LL.getEvent().getContainer(); | ||
- | if(c.getType()!="Container"||c.getOpener().getType()!="Folder")text("This Script doesn't work outside of Folders.\nLoad it in a Folder!","Error"); | + | if(c.getType()!="Container"||c.getOpener()==null||c.getOpener().getType()!="Folder")text("This Script doesn't work outside of Folders.\nLoad it in a Folder!","Error"); |
else | else | ||
{ | { | ||
c.getOpener().close(); | c.getOpener().close(); | ||
+ | var data=JSON.parse(LL.getEvent().getContainer().getTag("dim"))||new Object(); | ||
var script=installScript("dimbackground","DimBackground"); | var script=installScript("dimbackground","DimBackground"); | ||
LL.runScript(script.getName(),null); | LL.runScript(script.getName(),null); | ||
Line 81: | Line 71: | ||
speedInput.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT)); | speedInput.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
speedInput.setInputType(InputType.TYPE_CLASS_NUMBER); | speedInput.setInputType(InputType.TYPE_CLASS_NUMBER); | ||
- | speedInput.setText("10"); | + | speedInput.setText(data.speed||"10"); |
root.addView(speedInput); | root.addView(speedInput); | ||
var dimHint=new TextView(LL.getContext()); | var dimHint=new TextView(LL.getContext()); | ||
Line 89: | Line 79: | ||
dimInput.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT)); | dimInput.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
dimInput.setInputType(InputType.TYPE_CLASS_NUMBER); | dimInput.setInputType(InputType.TYPE_CLASS_NUMBER); | ||
- | dimInput.setText("200"); | + | dimInput.setText(data.dim||"200"); |
root.addView(dimInput); | root.addView(dimInput); | ||
+ | var barBox = new CheckBox(LL.getContext()); | ||
+ | barBox.setText("Tint System Bars"); | ||
+ | barBox.setChecked(data.bars||true); | ||
+ | root.addView(barBox); | ||
var fixBox=new CheckBox(LL.getContext()); | var fixBox=new CheckBox(LL.getContext()); | ||
fixBox.setText("Orientationfix (Fixes bug when changing orientation while folder opened, but may break desktop boundings)"); | fixBox.setText("Orientationfix (Fixes bug when changing orientation while folder opened, but may break desktop boundings)"); | ||
+ | fixBox.setChecked(data.fix||false); | ||
root.addView(fixBox); | root.addView(fixBox); | ||
var builder=new AlertDialog.Builder(LL.getContext()); | var builder=new AlertDialog.Builder(LL.getContext()); | ||
Line 122: | Line 117: | ||
data.dim=dim; | data.dim=dim; | ||
data.fix=fixBox.isChecked(); | data.fix=fixBox.isChecked(); | ||
+ | data.bars=barBox.isChecked(); | ||
c.setTag("dim",JSON.stringify(data)); | c.setTag("dim",JSON.stringify(data)); | ||
c.getProperties().edit().setEventHandler("resumed",EventHandler.RUN_SCRIPT,script.getId()).setEventHandler("paused",EventHandler.RUN_SCRIPT,script.getId()).commit(); | c.getProperties().edit().setEventHandler("resumed",EventHandler.RUN_SCRIPT,script.getId()).setEventHandler("paused",EventHandler.RUN_SCRIPT,script.getId()).commit(); | ||
Line 138: | Line 134: | ||
var dim=data.dim||150;//0 for nothing, 255 for solid black | var dim=data.dim||150;//0 for nothing, 255 for solid black | ||
var orientationfix=data.fix;//true if you want to switch screen orientation while folder open | var orientationfix=data.fix;//true if you want to switch screen orientation while folder open | ||
+ | var tintBars=data.bars; | ||
var d=LL.getCurrentDesktop(); | var d=LL.getCurrentDesktop(); | ||
+ | var dp=d.getProperties(); | ||
var i=d.getItemByLabel("bg")||d.addShortcut("bg",new Intent(),0,0); | var i=d.getItemByLabel("bg")||d.addShortcut("bg",new Intent(),0,0); | ||
var p=i.getProperties(); | var p=i.getProperties(); | ||
- | if(LL.getEvent().getSource()=="C_RESUMED"&&LL.getOpenFolders().length==0) | + | if(LL.getEvent().getSource()=="C_RESUMED"&&LL.getOpenFolders().length==1) |
{ | { | ||
d.setItemZIndex(i.getId(),d.getItems().getLength()-1); | d.setItemZIndex(i.getId(),d.getItems().getLength()-1); | ||
Line 152: | Line 150: | ||
if(orientationfix){ | if(orientationfix){ | ||
var s=Math.max( d.getWidth(),d.getHeight())*1.1; | var s=Math.max( d.getWidth(),d.getHeight())*1.1; | ||
- | i.setSize(s,s);} | + | i.setSize(s,s); |
+ | } | ||
else i.setSize( d.getWidth(),d.getHeight()); | else i.setSize( d.getWidth(),d.getHeight()); | ||
i.setPosition(0,0); | i.setPosition(0,0); | ||
Line 168: | Line 167: | ||
x++; | x++; | ||
p.edit().setInteger("i.alpha",x*dim/speed).commit(); | p.edit().setInteger("i.alpha",x*dim/speed).commit(); | ||
+ | if(tintBars)dp.edit().setInteger("statusBarColor",Color.argb(x*dim/speed,0,0,0)).setInteger("navigationBarColor",Color.argb(x*dim/speed,0,0,0)).commit(); | ||
if(x<speed)setTimeout(a,0); | if(x<speed)setTimeout(a,0); | ||
} | } | ||
Line 176: | Line 176: | ||
x--; | x--; | ||
p.edit().setInteger("i.alpha",x*dim/speed).commit(); | p.edit().setInteger("i.alpha",x*dim/speed).commit(); | ||
+ | if(tintBars)dp.edit().setInteger("statusBarColor",Color.argb(x*dim/speed,0,0,0)).setInteger("navigationBarColor",Color.argb(x*dim/speed,0,0,0)).commit(); | ||
if(x>0)setTimeout(b,0); | if(x>0)setTimeout(b,0); | ||
else d.removeItem(i); | else d.removeItem(i); | ||
} | } | ||
</sxh></spoiler> | </sxh></spoiler> |