java.lang.Object | |
↳ | net.pierrox.lightning_launcher.script.api.Lightning |
Entry point for most Lightning Launcher scripted features.
The Lightning object is the root object in the script context, hence its functions can be called without naming it, unlike with the deprecated LL object.
For instance, instead of using LL.getDesktopByName('d')
, simply use getDesktopByName('d')
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
alert(String message)
Display a message in a dialog box.
| ||||||||||
boolean |
bindClass(String name)
Translate a Java class into a JavaScript object.
| ||||||||||
void |
clearTimeout(int id)
Clear a timeout previously set with #setTimeout
| ||||||||||
boolean |
confirm(String message)
Display a message in a dialog box with Ok/Cancel buttons
| ||||||||||
Screen | createScreen(net.pierrox.lightning_launcher.engine.Screen screen) | ||||||||||
Script |
createScript(String path, String name, String text, int flags)
Create a new script.
| ||||||||||
Script |
createScript(String name, String text, int flags)
This method is deprecated.
use
createScript(String, String, String, int) instead
| ||||||||||
void |
deleteScript(Script script)
Delete a script.
| ||||||||||
Screen |
getActiveScreen()
Retrieve the currently active screen, the one which is displayed to the user.
| ||||||||||
Script[] |
getAllScriptMatching(int flags)
Return the collection of scripts matching some flags.
| ||||||||||
ActivityScreen |
getAppDrawerScreen()
Return the app drawer screen, null if not created yet
| ||||||||||
Screen |
getBackgroundScreen()
Return the background screen.
| ||||||||||
Configuration |
getConfiguration()
Retrieve the configuration object used to get and set launcher general settings.
| ||||||||||
Script |
getCurrentScript()
Retrieve the currently executed script.
| ||||||||||
Event |
getEvent()
Returns the event object associated with this script execution.
| ||||||||||
Screen |
getFloatingScreen()
Return the floating screen, null if not created yet
| ||||||||||
HomeScreen |
getHomeScreen()
Return the home screen, null if not created yet
| ||||||||||
Typeface |
getIconsTypeface()
return the typeface used to draw icons.
| ||||||||||
Screen |
getLiveWallpaperScreen()
Return the live wallpaper screen, null if not created yet
| ||||||||||
ActivityScreen |
getLockScreen()
Return the lock screen, null if not created yet
| ||||||||||
Script |
getScriptById(String id)
Retrieve a script by its unique identifier
| ||||||||||
Script |
getScriptByName(String name)
Retrieve a script by name.
| ||||||||||
Script |
getScriptByPathAndName(String path, String name)
Retrieve a script by its path and name.
| ||||||||||
VariableSet |
getVariables()
Retrieve the whole set of known variables (builtins and user ones).
| ||||||||||
boolean |
isLocked()
Returns true if the screen is currently locked using the Lightning lock screen.
| ||||||||||
String |
loadRawResource(String pkg, String name)
This method is used to load a text from a package raw resource.
| ||||||||||
String |
prompt(String message, String input)
Display a message in a dialog box with an input text area.
| ||||||||||
void |
save()
Persist launcher data now.
| ||||||||||
boolean |
sendTaskerIntent(TaskerIntent intent, boolean synchronous)
Send a tasker intent, optionally waiting for its completion to return.
| ||||||||||
int |
setTimeout(Object function, int delayMillis)
Execute a function later.
| ||||||||||
void |
setVariableBoolean(String name, boolean value)
Set a boolean variable.
| ||||||||||
void |
setVariableFloat(String name, float value)
Set a boolean variable.
| ||||||||||
void |
setVariableInteger(String name, long value)
Set a boolean variable.
| ||||||||||
void |
setVariableString(String name, String value)
Set a string variable.
| ||||||||||
void |
unlock()
Unlock the screen.
| ||||||||||
void |
writeToLogFile(String data, boolean append)
Write data to a file.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Display a message in a dialog box.
message | text to display |
---|
Translate a Java class into a JavaScript object. This is a convenience method that avoid repeated use of fully qualified names while scripting Java.
name | fully qualified class name |
---|
Clear a timeout previously set with #setTimeout
id | identifier returned by #setTimeout |
---|
Display a message in a dialog box with Ok/Cancel buttons
message | text to display |
---|
Create a new script. Use this API wisely. if path is null, "/" is used.
This method is deprecated.
use createScript(String, String, String, int)
instead
Create a new script using the default path "/"
Retrieve the currently active screen, the one which is displayed to the user. Note that this is often the same as Lightning.getEvent().getScreen(), but not always : events and script execution can occur in non active screens.
Return the collection of scripts matching some flags.
flags | see Script#FLAG_* |
---|
Return the background screen. This special screen is used when running background scripts. It can be used to query items and containers, but position and size may not be computed since the screen is not displayed and has no size.
Retrieve the configuration object used to get and set launcher general settings.
Returns the event object associated with this script execution. The event provides contextual data, such as the current desktop, which item has been tapped, and so on.
return the typeface used to draw icons.
Retrieve a script by its unique identifier
id | identifier as given by Script#getId() |
---|
Retrieve a script by name.
name | as given by Script#getName() |
---|
Retrieve a script by its path and name.
path | as given by Script#getPath() |
---|---|
name | as given by Script#getName() |
Retrieve the whole set of known variables (builtins and user ones).
Returns true if the screen is currently locked using the Lightning lock screen.
This method is used to load a text from a package raw resource. Instances of use of this method are:
pkg | package name from which to read resources |
---|---|
name | name of the raw resource. It must not contain the extension of the raw file, this is the Android identifier. |
Display a message in a dialog box with an input text area.
message | text to display |
---|---|
input | initial value in the input text |
Persist launcher data now.
Send a tasker intent, optionally waiting for its completion to return.
intent | an intent built with TaskerIntent (see http://tasker.dinglisch.net/invoketasks.html for samples) |
---|---|
synchronous | when true, Lightning will wait for Tasker task completion before to return, otherwise it will return immediately |
Execute a function later.
function | need to be a function |
---|---|
delayMillis | anything below 0 will be handled as 0 |
Set a boolean variable. This is a shortcut for LL.getVariables().edit().setBoolean(name, value).commit();
. When modifying several at once, consider using the PropertyEditor
object instead for best efficiency.
Set a boolean variable. This is a shortcut for LL.getVariables().edit().setFloat(name, value).commit();
. When modifying several at once, consider using the PropertyEditor
object instead for best efficiency.
Set a boolean variable. This is a shortcut for LL.getVariables().edit().setInteger(name, value).commit();
. When modifying several at once, consider using the PropertyEditor
object instead for best efficiency.
Set a string variable. This is a shortcut for LL.getVariables().edit().setString(name, value).commit();
. When modifying several at once, consider using the PropertyEditor
object instead for best efficiency.
Unlock the screen.
Write data to a file. This is for logging and debug purpose only. The path is not configurable and is:
data | text to write to the file |
---|---|
append | whether to clear the file before to write data, or append data to the existing content |