January, 2016
now browsing by month
I somehow managed to prevent moving of icon in one of my desktops.
I somehow managed to prevent moving of icon in one of my desktops. I can only move them in edit mode. Anybody know what the likely setting was? Thanks
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.
]]>Need help making folders I want to put Google plus gmail and maps in one folder on my homescreen please help
Need help making folders I want to put Google plus gmail and maps in one folder on my homescreen please help
While I am always amazed at the results we can achieve on our home screens (with gerd reuter templates as I don’t…
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.
]]>Can someone help me and explain how to run a notification?
Can someone help me and explain how to run a notification?
Is there a way to fix the size of a folder?
Is there a way to fix the size of a folder? I’m making folders that open to a single row of items and scroll horizontally. The only way I found to do this is to set, under layout, columns to the number of items I want and set rows to Automatic. Then, in order to keep a single row when I arrange the items, I un-check Rearrange Items under Misc. Then when I’m done, I can re-check it.
What I’d like is to have a folder open to a 1×6 cells panel, with each cell being the size of an icon. I want this, no matter how many rows of items I have. If I set the Layout to be 1×6, each cell is stretched to the height of the screen. It doesn’t matter if Use Desktop Size is checked or not. If I set it to automatic with say three rows, it opens to 3×6. And I have to move the items back into a single row.
Does any of this make any sense? 🙂 Thanks!
Pierre Hébert I think it would be good if Lightning launched a background thread when opening the appdrawer, which…
I see two possibilities: query all launcher activities and compare the two sets or query each item intent. I guess the first one is faster, but I haven’t tried.
]]>