java.lang.Object | |
↳ | net.pierrox.lightning_launcher.script.api.LL |
This class is deprecated.
use Lightning
instead.
The main object to access Lightning Launcher features. The LL object gives access to desktops, items or give contextual data on the event.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
bindClass(String name)
Translate a Java class into a JavaScript object.
| ||||||||||
ImageAnimation |
createAnimation(int width, int height, int count, int duration, int loopCount)
Create a blank animation: frames are created fully transparent and need to be drawn.
| ||||||||||
ImageBitmap |
createImage(int width, int height)
Create a blank new image of the specified size.
| ||||||||||
Image |
createImage(String path)
Create an image from the specified file.
| ||||||||||
Image |
createImage(String pkg, String name)
Create an image from a package and a resource name.
| ||||||||||
ImageScript |
createImage(Scriptable object, int width, int height)
Create an image whose content is drawn using a script.
| ||||||||||
Script |
createScript(String name, String text, int flags)
Create a new script.
| ||||||||||
ImageBitmap |
cropImage(ImageBitmap image, boolean full_size)
Request the user to select an area in the image.
| ||||||||||
void |
deleteScript(Script script)
Delete a script.
| ||||||||||
Array |
getAllDesktops()
Returns an array of desktop identifiers.
| ||||||||||
Array |
getAllScriptMatching(int flags)
Return the collection of scripts matching some flags.
| ||||||||||
Container |
getContainerById(int id)
This method is deprecated.
use
getContainerById(int)
| ||||||||||
Context |
getContext()
Return the Android Context this script is linked with (an activity context).
| ||||||||||
Desktop |
getCurrentDesktop()
Returns the currently displayed desktop.
| ||||||||||
Script |
getCurrentScript()
Retrieve the currently executed script.
| ||||||||||
Desktop |
getDesktopByName(String name)
Returns a desktop by its name, as set in the "Configure desktop" screen.
| ||||||||||
Event |
getEvent()
This method is deprecated.
use
getEvent()
| ||||||||||
Desktop |
getFloatingDesktop()
Returns the desktop used as the floating desktop, or null if not set.
| ||||||||||
Desktop |
getHomeDesktop()
Returns the home desktop.
| ||||||||||
Item |
getItemById(int id)
This method is deprecated.
use
getItemById(int)
| ||||||||||
Desktop |
getLockscreenDesktop()
Returns the desktop used as the lock screen, or null if not set.
| ||||||||||
Array |
getOpenFolders()
Returns the list of currently open folders.
| ||||||||||
Script |
getScriptById(String id)
Retrieve a script by its unique identifier
| ||||||||||
Script |
getScriptByName(String name)
Retrieve a script by name
| ||||||||||
String |
getScriptTag()
This method is deprecated.
use Script#getTag() instead
| ||||||||||
VariableSet |
getVariables()
Retrieve the whole set of known variables (builtins and user ones).
| ||||||||||
void |
goToDesktop(int id)
Go to a specified desktop, without changing the current position in this desktop.
| ||||||||||
void |
goToDesktopPosition(int id, float x, float y)
Go to a specified desktop and set the current absolute position in this desktop, setting a scale of 1 and using animations.
| ||||||||||
void |
goToDesktopPosition(int id, float x, float y, float scale, boolean animate)
Go to a specified desktop and set the current absolute position in this desktop.
| ||||||||||
boolean |
isLocked()
Returns true if the screen is currently locked using the Lightning lock screen.
| ||||||||||
boolean |
isPaused()
Returns whether the current context is paused.
| ||||||||||
String |
loadRawResource(String pkg, String name)
This method is used to load a text from a package raw resource.
| ||||||||||
int |
pickColor(String title, int color, boolean hasAlpha)
Request the user to pick a color.
| ||||||||||
Image |
pickImage(int maxPixels)
Request the user to pick an image through the Lightning image picker screen.
| ||||||||||
float |
pickNumericValue(String title, float value, String valueType, float min, float max, float interval, String unit)
Request the user to enter a numeric value.
| ||||||||||
void |
runAction(int action, Item item, String data)
Run a Lightning action.
| ||||||||||
void |
runAction(int action, String data)
Same as #runAction(int,Item,String) with a null item and data.
| ||||||||||
void |
runAction(int action)
Same as #runAction(int,String) with a null data.
| ||||||||||
void |
runScript(String name, String data)
This method is deprecated.
use
runScript(String, String)
| ||||||||||
void |
save()
Persist launcher data now.
| ||||||||||
boolean |
sendTaskerIntent(TaskerIntent intent, boolean synchronous)
Send a tasker intent, optionally waiting for its completion to return.
| ||||||||||
void |
setScriptTag(String tag)
This method is deprecated.
use Script#setTag(String) instead together with #getCurrentScript
| ||||||||||
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.
| ||||||||||
boolean |
startActivity(Intent intent)
Start an activity.
| ||||||||||
boolean |
startActivityForResult(Intent intent, Script receiver, String token)
Start an activity and handle the result in another script.
| ||||||||||
void |
unlock()
Unlock the screen.
| ||||||||||
void |
writeToLogFile(String data, boolean append)
Write data to a file.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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 |
---|
Create a blank animation: frames are created fully transparent and need to be drawn. Notes: animations created this way are memory expensive and cannot be persisted (yet). This means that Shortcut.setCustomIcon() wont't work, but Shortcut.setImage() will.
width | image width |
---|---|
height | image height |
count | number of frames to allocate |
duration | default frame duration |
loopCount | initial number of loops to play, use 0 for infinite |
Create a blank new image of the specified size. Pixel format is always ARGB 8888. Take care when creating images since it can rapidly exhaust memory and lead to a crash.
Create an image from the specified file.
path | path of the image |
---|
Create an image from a package and a resource name.
For instance:LL.createImage("net.pierrox.lightning_launcher_extreme", "icon")
The density used is either the one given by ActivityManager.getLauncherLargeIconDensity if available, or the current one.
pkg | name of the package, use "android" to access system resources. |
---|---|
name | name of the drawable resource |
Create an image whose content is drawn using a script.
This can be used for memory efficient graphics and animations.
Please refer to ImageScript
for the documentation on how to use it.
object | the set of functions |
---|---|
width | the prefered image width, use -1 for as big as possible |
height | the prefered image height, use -1 for as big as possible |
Create a new script. Use this API wisely.
Request the user to select an area in the image. Warning: because images need to be persisted to file while cropping, this method may be slow.
image | image to be cropped |
---|---|
full_size | handling big images can be slow or request too much memory, by setting full_size to false this will allow this method to downscale images (approx. the size of the screen) |
Return the collection of scripts matching some flags.
flags | see Script#FLAG_* |
---|
Return the Android Context this script is linked with (an activity context). This is meant to be used with Android services.
Returns a desktop by its name, as set in the "Configure desktop" screen. The desktop name can be retrieved using getName()
.
This method will return null if no desktop by that name can be found
name | name of the desktop |
---|
This method is deprecated.
use getEvent()
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.
Returns the desktop used as the floating desktop, or null if not set.
Returns the home desktop. As of Lightning V14, this method looks for the desktop in the home screen, then in the background desktop.
This method is deprecated.
use getItemById(int)
Returns an item by its id. This is a shortcut avoiding to traverse the list of all desktops and folders.
id | item identifier |
---|
Returns the desktop used as the lock screen, or null if not set. As of Lightning V14, this method looks for the desktop in the lock screen, then in the home screen, and finally in the background desktop.
Returns the list of currently open folders. This function returns the opener item, not the container itself. This method will return null when the script is executed in the background.
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() |
---|
This method is deprecated.
use Script#getTag() instead
Retrieve the whole set of known variables (builtins and user ones).
Go to a specified desktop, without changing the current position in this desktop.
id | desktop identifier |
---|
Go to a specified desktop and set the current absolute position in this desktop, setting a scale of 1 and using animations. This method does nothing when the script is run in background.
id | desktop identifier |
---|---|
x | absolute X position, in pixel |
y | absolute Y position, in pixel |
Go to a specified desktop and set the current absolute position in this desktop. This method does nothing when the script is run in background.
id | desktop identifier |
---|---|
x | absolute X position, in pixel |
y | absolute Y position, in pixel |
scale | zoom factor (1=100%, 0.5=50%, negative values are acceptable, 0 is not very useful) |
animate | whether to animate the move |
Returns true if the screen is currently locked using the Lightning lock screen.
Returns whether the current context is paused. It often means that Lightning Launcher is not displayed, for instance because another app is running. When the script is executed in the background this method always returns true.
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. |
Request the user to pick a color.
title | text displayed at the top of the dialog |
---|---|
color | initial color to display |
hasAlpha | whether to display the transparency slider. It will not enforce a fully opaque color, it only acts on the slider visibility. |
Request the user to pick an image through the Lightning image picker screen. Warning: images returned by this function may be very large, take care at memory use as exceeding limits will make the launcher crash. Use the maxPixels parameter: the image will be scaled by a power of two so that its number of pixels is below or equal. This function supports picking bitmaps and nine patches.
maxPixels | maximum number of pixels in the returned image (width x height), 0 for no limit, 1048576 is one mega pixels (1024 x 1024) |
---|
Image
, or null if the user canceled the operation, or if the image cannot be loaded
Request the user to enter a numeric value. When using the "%" unit, valueType must be set to FLOAT: the dialog will scale a decimal value so that 0.75 is displayed as 75%. Warning: the returned value may be subject to rounding errors.
title | text displayed at the top of the dialog |
---|---|
value | initial value to display |
valueType | either INT or FLOAT. It will default to FLOAT if valueType is not a known value. |
min | minimum value for the slider |
max | maximum value for the slider |
interval | interval between values when sliding |
unit | text to display after the value (for instance "%" or "px"). When using "%" with FLOAT, scale value by 100 |
Run a Lightning action. This method does nothing when the script is run in background.
action | action code (one of the values defined in EventHandler |
---|---|
item | item to be used as the target (only useful with actions requiring an item) |
data | optional data to send to be used by the action, use null if none |
Same as #runAction(int,Item,String) with a null item and data.
Same as #runAction(int,String) with a null data.
This method is deprecated.
use runScript(String, String)
Run another script.
Optional data can be transmitted to the called script and retrieved using getData()
.
name | name of the script as found in the script editor |
---|---|
data | optional data to send to the script. Use JSON to pass more than a string. |
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 |
This method is deprecated.
use Script#setTag(String) instead together with #getCurrentScript
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.
Start an activity.
Example:
var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.pierrox.net/")
LL.startActivity(intent);
intent | intent to start the activity |
---|
Start an activity and handle the result in another script. This is similar to http://developer.android.com/reference/android/app/Activity.html#onActivityResult%28int,%20int,%20android.content.Intent%29 This call is asynchronous and the script will continue its execution. Once the started activity ends, the "receiver" script is called with the following parameters set:
intent | intent to start the activity |
---|---|
receiver | a script to execute upon activity end |
token | an optional string data that you can transmit to the receiver script |
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 |