now browsing by category
Hi, I was wondering how to make a link placeholder via a script?
Help: How to set items’ background image by script?
We can set one item’s background image by hand. At the same time, we can set all item’s background image in the desktop/folder just by setting once.
By script, we can set one item’s background image like that:
item.setBoxBackground(image1, “n”); // set a normal bg image to image1.
Then how can we set the background image of all items in the destkop by not iterating all items? Is it not possible? We have to iterate its setting?
]]>/So I deleted my other script and changed some stuff to create this one which gives you more control.
/So I deleted my other script and changed some stuff to create this one which gives you more control. You now have 3 options what to do with the bars. See Screenshot./
//System bar color changer
var defaultColor = 0xffff5722; // LL Orange
var desktop = LL.getCurrentDesktop();
var property = desktop.getProperties();
var editor = property.edit();
var choice = prompt(“1 = Use same color for both bars\n2 = Use different colors for each bar\n3 = Use Lightning Launchers Orange”, “”);
if (choice == 3)
{
editor.setInteger(“statusBarColor”, 0xffff5722);
editor.setInteger(“navigationBarColor”, 0xffff5722);
editor.commit();
Android.makeNewToast(“Excellent choice!”, true).show();
}
if (choice == null)
{
//Android.makeNewToast(“null selected”, true).show();
}
else if ((choice != 1) && (choice != 2) && (choice != 3))
{
Android.makeNewToast(“Use only 1 2 or 3”, true).show();
}
else if (choice == 1)
{
//Android.makeNewToast(“1 selected”, true).show();
var barsColor = LL.pickColor(“Statusbar and Navbar Color”, defaultColor, true);
if (barsColor != null)
{
editor.setInteger(“statusBarColor”, barsColor);
editor.setInteger(“navigationBarColor”, barsColor);
editor.commit();
}
}
else if (choice == 2)
{
Android.makeNewToast(“Statusbar color”, true).show();
var statusColor = LL.pickColor(“Statusbar Color”, defaultColor, true);
if (statusColor != null)
{
Android.makeNewToast(“Navbar color”, true).show();
editor.setInteger(“statusBarColor”, statusColor);
editor.commit();
var navbarColor = LL.pickColor(“Navbarbar Color”, defaultColor, true);
if (navbarColor != null)
{
editor.setInteger(“navigationBarColor”, navbarColor);
editor.commit();
}
}
}
]]>It might be my imagination, but i thought there was a script which had really cool material folder opening and…
Style script editor
Style script editor
This script is a library/tool/helper related to the properties of items (including containers) to get and set them. It supports strings, integers, booleans, boxes and event handlers.
Features:
– Get script code from item B that, when running in item A, will set the same properties of the item B. This can be useful when creating a script that creates an item, and you need that item with specific properties.
– The same as before but without copy/pasteing (it is saved in the script tag to apply).
– A class available to any script (you need to run this script at least once when the app loads) to perform any of those actions.
Instructions:
– Run the script from an item from long tap. The class will be initialized and a dialog with options will be shown.
– Choose get and save from item/container (if available) to display the code (the one that contains all the properties of the item/container)
– Choose apply to item/container (if available) to set the saved properties (from the previous run) to that item.
Important: although you can apply properties from items with different types, some of them won’t work and can make others don’t work too. This may change in future lighting versions.
]]>Hack for closing all folders on launching an app
In a situation like that a folder has sub-folders and panels, and its sub-folders/panels which have shortcuts or so, if user taps an shorcut(in folder/panel) to launch , then all opened folders will be closed.
01 // Desktop’s onPaused event handler
02 if (LL.getEvent().getContainer().getView().hasWindowFocus()) {
02 if (LL.getEvent().getContainer().getView().getAlpha() == 1) {
03 LL.runAction(EventHandler.CLOSE_ALL_FOLDERS);
04 }
Line 02 is a hack.
When user enters into edit mode, and then add items by using “All apps”, desktop’s onPaused event is called. If line 02 doesnt exist, to-be-added apps wil be added to desktop, not to a folder/panel where user wanted to add.
]]>Minigame time! It is not Breakout, sorry, but a more launcher-involved game.
Minigame time! It is not Breakout, sorry, but a more launcher-involved game.
Find the items
This will hide a custom number of items (they are small with the lightning’s icon) inside all containers of your desktop/desktops (If you have a simple one it will be very easy. The more folders/panels you have, the funnier it will be! )
When hidden you simply need to find and click them. When all are found you can start a new game.
It can be useful to help you remember your setup, you need to open and search in all places. Maybe there is a hidden folder you don’t remember about!
Because sometimes the items are really well hidden (or even where you doesn’t expect an item can be) launching the script while there are hidden items, shows the position of a random one.
Instructions when no game is on: Run the script, select whether to use all desktops or only the current one, and the number of items to hide.
Note: items are randomly placed inside the reachable containers and always inside the bounding box. However due to lightning’s loading process, sometimes items are placed at 0,0.
Another note: When launching the script it checks that the hidden items are still in the launcher, so if a hidden item is deleted, the script won’t tell you it is still hidden.
Have fun!
]]>About the ‘how to have a ➕ desktop’
About the ‘how to have a ➕ desktop’
As Lukas said implementing this from a script can be tricky and will result in a long and complex script due to the personalization the launcher has.
However I though a way to implement this with a relatively very short script that has limitations and very specific instructions that you must follow, but If you follow them (and they are not so strange) it should work correctly. It can be also a start point in case someone want to improve it and make it more ‘universal’
The instructions are:
Set the script to run in the position change event of a container.
Place items that will be the ‘prohibited’ zones (in the video the red ones) that need to have those properties:
Properties of the barrier items:
Label set to “barrier” (this can be changed from script if necessary).
Scale set to 1,1 and skew and rotation to 0.
[Note that it is not necessary to have a red background, but it helps visualizing].
Caveats:
If you enable diagonal scrolling it won’t slide when touching a barrier, it will simply stop. Consider not using diagonal scrolling.
If you enter exit edit mode while a barrier is on view it will jump to the previous saved position, or not move at all if there is no saved one. Consider exiting edit mode always in a ‘valid’ position.
If there are a lot of items in the container it may lag.
With seamless mode it won’t necessarily work as expected. Consider duplicating the barriers yourself if necessary.
Improvements that can be made (for scripters)
Save the barrier’s rects instead of calculating them each time.
Slide instead of stopping when diagonal scrolling is on.
Use also the scale of barriers and maybe even rotation and skew.
Make it valid with seamless mode.
]]>Class for playing sound using local file or scripted data.
1. Class definition
========================================================
function SoundPlayer(scriptNameForSounds) {
LL.bindClass(‘java.io.File’);
LL.bindClass(‘java.io.FileInputStream’);
LL.bindClass(‘java.io.FileOutputStream’);
LL.bindClass(‘android.os.Environment’);
LL.bindClass(‘android.media.MediaPlayer’);
LL.bindClass(‘android.util.Base64’);
this.SCRIPT_NAME_FOR_SOUNDS = scriptNameForSounds;
this.PATH_SOUNDS = Environment.getExternalStorageDirectory() + ‘/LightningLauncher/Sounds’;
new File(this.PATH_SOUNDS).mkdir();
// Use one MediaPlayer for several instance of SoundPlayer.
if (self.mediaPlayer) {
this.mediaPlayer = self.mediaPlayer;
}
else {
this.mediaPlayer = self.mediaPlayer = new MediaPlayer();
}
SoundPlayer.prototype.play = function(name) {
try {
if (!name) {
throw ‘Error(SoundPlayer.play): No sound name entered.’;
}
var soundFile = new File(this.PATH_SOUNDS, name);
if (!soundFile.exists() || soundFile.length() == 0) {
if (!this.SCRIPT_NAME_FOR_SOUNDS) {
return; // No script for sounds and no file in
}
var scriptSounds = LL.getScriptByName(this.SCRIPT_NAME_FOR_SOUNDS);
if (!scriptSounds) { throw ‘Error(SoundPlayer.play): No ‘ + this.SCRIPT_NAME_FOR_SOUNDS + ‘ script’; }
var sounds = eval(scriptSounds.getText());
if (!sounds[name]) { throw ‘Error(SoundPlayer.play): No ‘ + name + ‘ in ‘ + this.SCRIPT_NAME_FOR_SOUNDS + ‘ script’; }
var fos = new FileOutputStream(soundFile);
fos.write(Base64.decode(sounds[name], Base64.DEFAULT));
fos.close();
}
var mp = this.mediaPlayer;
mp.reset();
mp.setDataSource(new FileInputStream(soundFile).getFD());
mp.prepare();
mp.start();
}
catch(e) {
// for debug. normally ignore all errors/exceptions silently.
// Android.makeNewToast(e, true).show();
}
}
}
========================================================
2. How to play local sound file (for normal end users)
– Place any sound files under ~LightningLauncher/Sounds folder.
In your script,
var player = new SoundPlayer();
player.play(‘click1.mp3’); // plays ~LL…/Sounds/click1.mp3
========================================================
3. How to play scripted sound file (for developers who want to distribute their own sound clips or open-sourced ones within scripts)
– Prepare sound clip.
– Encode it to MP3, or OGG for a small size. I use http://media.io site.
– Encode MP3/OGG.. to base64 form I use http://base64-encoding.online-domain-tools.com
– Create
// my_sounds_script_name
(function() {
return {
SOUND_NAME : ‘BASE64 String…’,
‘click2.mp3’ : ‘ZFSAACSD … =’,
‘click3.ogg’ : ‘DSDSW.ds … =’
};
})();
You can embed as many as BASE64’ed sound clip in script.
—
In your script using sounds,
var player = new SoundPlayer(SOUND_SCRIPT_NAME);
player.play(SOUND_NAME);
ie.
var player = new SoundPlayer(‘my_sounds_script_name’);
player.play(‘click1.mp3’);
player.play(‘click3.ogg’);
// If ~LL…/Sounds/click1.mp3 exists, then play that file.
// If not, it creates ‘click1.mp3’ file using
If you’ are to use sounds in several scripts, you had better cache SoundPlayer object, for example:
if (!self.mySoundPlayer) {
self.mySoundPlayer = new SoundPlayer(‘my_sound_script’);
}
self.mySoundPlayer.play(‘click.mp3’);
========================================================
Using this method, you can use sound effects and distribute them only using LL’s script feature.
]]>widget columns
widget columns
Maybe you remember a video of my home screen one year ago. There I showed this script in action, however it had a workaround for a problem lightning had in the past, you couldn’t specify a custom bounding box.
Since one or two version before the current one, this is now possible. I planned to release this some months ago, but in the end I encounter another problem, and I couldn’t post it.
Now it’s time to do so.
The instructions to set it up are relatively simple: in a container (I recommend a panel) with the widgets detached, run the script from items/events specifying those script data:
zoom – to decrease the number of columns
unzoom – to increase the number of columns
1 (or any other positive integer) – to set exactly that number of columns
0 (or any other negative number) – to recalculate without changing the current number of columns
Don’t specify a data and it will update only the bounding box
I recommend to run the script from the resumed event of the container without data. This will ensure the bounding box is always the good one.
Notes:
Only widgets will be moved, if you need to change this edit the script.
The script has a little borders configuration that you can modify to your needs (in the video I have borders set)
You can also specify the velocity and frequency of the animation.
]]>