java.lang.Object | |
↳ | net.pierrox.lightning_launcher.script.api.Container |
Known Direct Subclasses |
The container can be either a desktop, a folder or a panel. Its role is to manage items inside.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final int | NONE |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CustomView |
addCustomView(float x, float y)
Create a new custom view using default values.
| ||||||||||
Folder |
addFolder(String label, float x, float y)
Create a new empty folder with the default icon and size.
| ||||||||||
PageIndicator |
addPageIndicator(float x, float y)
Create a new page indicator using default values.
| ||||||||||
Panel |
addPanel(float x, float y, float width, float height)
Create a new empty panel.
| ||||||||||
Shortcut |
addShortcut(String label, Intent intent, float x, float y)
Create a new shortcut with the default icon and size.
| ||||||||||
StopPoint |
addStopPoint(float x, float y)
Create a new stop point with the default configuration.
| ||||||||||
void |
applyIconPack(boolean synchronous)
Requests a manual application of the selected icon pack.
| ||||||||||
void |
cancelFling()
Stop inertial movement initiated by a fling.
| ||||||||||
Item |
cloneItem(Item item)
Clone an item, including containers if any, recursively.
| ||||||||||
Scriptable |
extend()
Return a new script object, with this container as prototype
| ||||||||||
Item[] |
getAllItems()
Returns the list of items in this container
| ||||||||||
RectL |
getBoundingBox()
Returns the area covered by items in this container.
| ||||||||||
float |
getCellHeight()
Returns the current computed cell width.
| ||||||||||
float |
getCellWidth()
Returns the current computed cell width.
| ||||||||||
int |
getHeight()
Returns the height of this container.
| ||||||||||
int |
getId()
Returns the container unique identifier.
| ||||||||||
Item |
getItemById(int id)
Retrieve an item using its identifier.
| ||||||||||
Item |
getItemByLabel(String label)
This method is deprecated.
Use #getItemByName instead
| ||||||||||
Item |
getItemByName(String name)
Retrieve an item using its name.
| ||||||||||
int |
getItemZIndex(int itemId)
Returns the Z-index of the item in the container.
| ||||||||||
Array |
getItems()
This method is deprecated.
use #getAllItems instead
| ||||||||||
Scriptable |
getMy()
Return a scriptable object that can be used to store live data.
| ||||||||||
Item |
getOpener()
Returns the item used to open this container.
| ||||||||||
Container |
getParent()
Returns the parent container for this container, or null if this container is a desktop.
| ||||||||||
float |
getPositionScale()
Returns the current scale.
| ||||||||||
float |
getPositionX()
Returns the current absolute horizontal position.
| ||||||||||
float |
getPositionY()
Returns the current absolute vertical position.
| ||||||||||
PropertySet |
getProperties()
Retrieve container properties (configuration data).
| ||||||||||
String |
getTag()
Returns the value associated with this container.
| ||||||||||
String |
getTag(String id)
Returns the value associated with this container.
| ||||||||||
String |
getType()
Used to identify the kind of this container.
| ||||||||||
ViewGroup |
getView()
Retrieve the android View for this container.
| ||||||||||
int |
getWidth()
Returns the width of this container.
| ||||||||||
Item |
moveItem(Item item, Container to_other_container)
Move an item from this container to another container.
| ||||||||||
void |
removeCustomIcons()
This method removes custom icons and layer images.
| ||||||||||
void |
removeItem(Item item)
Remove an item, without confirmation, whatever its type.
| ||||||||||
void |
setBoundingBox(RectL bb)
Manually set a bounding box for this container.
| ||||||||||
void |
setItemZIndex(int itemId, int index)
Move an item to another layer.
| ||||||||||
void |
setPosition(float x, float y, float scale, boolean animate)
Go to a specified absolute position in this container.
| ||||||||||
void |
setPosition(float x, float y)
Go to a specified absolute position in this container, setting a scale of 1 and using animations.
| ||||||||||
void |
setTag(String id, String value)
Set a custom and persistent data for this container.
| ||||||||||
void |
setTag(String value)
Set a custom and persistent data for this container.
| ||||||||||
void |
showAddItemDialog()
Display the Lightning "Add item" dialog.
| ||||||||||
String |
toString()
| ||||||||||
float |
translateIntoScreenCoordX(float x)
Convert horizontal coordinates in this container into screen coordinates.
| ||||||||||
float |
translateIntoScreenCoordY(float y)
Convert vertical coordinates in this container into screen coordinates.
| ||||||||||
void |
updateBoundingBox()
Update the items bounding box.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new empty folder with the default icon and size.
label | folder name |
---|---|
x | absolute position (rounded to nearest cell when attached to grid) |
y | absolute position (rounded to nearest cell when attached to grid) |
Create a new page indicator using default values.
Create a new empty panel. All coordinates are in pixels and rounded to the nearest cell when the item is attached to the grid.
Create a new shortcut with the default icon and size.
label | shortcut text |
---|---|
intent | shortcut action, see http://developer.android.com/reference/android/content/Intent.html |
x | absolute position (rounded to nearest cell when attached to grid) |
y | absolute position (rounded to nearest cell when attached to grid) |
Create a new stop point with the default configuration.
x | absolute position (rounded to nearest cell when attached to grid) |
---|---|
y | absolute position (rounded to nearest cell when attached to grid) |
Requests a manual application of the selected icon pack. The icon pack can either be configured from the settings screen or the "iconPack" container property. Setting the property "iconPack" will not automatically update icons for the container and this method need to be called afterwards. Manually applying the icon pack can also be useful if shortcuts intents have been changed or if the icon pack has been updated. Important note: no container modification should occur during this operation. This will always be true when the method is called with the synchronous parameter set to true, but the app will be frozen. When this parameter is set to false, the method will still return only when the operation is complete, but the user will be able to interact with the app in the meantime. Displaying a progress dialog will help in avoiding modifications but background operations/script executions can still take place.
synchronous | allow the operation to be done synchronously or asynchronously. Asynchronous is unsafe due to risks of container concurrent modifications running in the background. |
---|
Stop inertial movement initiated by a fling. Does nothing when the script is run in background.
Clone an item, including containers if any, recursively. Widgets are not fully cloned and need an user action to be fully restored. The position of the newly created item is automatically chosen.
item | object to clone |
---|
Return a new script object, with this container as prototype
Returns the area covered by items in this container. This function will return an empty rect if the container has not been displayed yet or if the script is run in background.
Returns the current computed cell width. It will return 0 if the script is run in background.
Returns the current computed cell width. It will return 0 if the script is run in background.
Returns the height of this container. This function will return 0 if the script is run in background.
Returns the container unique identifier.
Retrieve an item using its identifier.
id | item identifier |
---|
Retrieve an item using its name. If two or more items have the same name, the first is returned.
name | the name set in the "+" tab in the item settings, and if name is not set use the label for shortcuts and folders |
---|
Returns the Z-index of the item in the container.
itemId | item identifier as returned by getId() |
---|
This method is deprecated.
use #getAllItems instead
Returns the list of items in this container
Return a scriptable object that can be used to store live data. These data won't be stored, unlike tags.
Returns the item used to open this container. This can either be a Folder or a Panel.
Returns the parent container for this container, or null if this container is a desktop.
Returns the current scale. This function will return 1 if the script is run in background.
Returns the current absolute horizontal position. This function will return 0 if the script is run in background.
Returns the current absolute vertical position. This function will return 0 if the script is run in background.
Retrieve container properties (configuration data). Please note that modifying properties for a container is particularly expensive and slow.
Returns the value associated with this container. Same as getTag(null)
Returns the value associated with this container. Can be undefined if it has never been set.
Using a null id is the same as using getTag()
without argument.
Used to identify the kind of this container.
Retrieve the android View for this container. This function will return null if the script is run in background.
Returns the width of this container. This function will return 0 if the script is run in background.
Move an item from this container to another container.
Warning: moving an item will change its identifier. Any reference to this item should be cleared, for instance this way:
var item = container_a.getItemByName('some_item');
item = container_a.moveItem(item, container_b);
Additionally both containers may be reloaded and references to other items in these container may become invalid too.
item | the item to move |
---|---|
to_other_container | the container in which to move the item |
This method removes custom icons and layer images. It also reset the inner icon scale to 1. The purpose is to "cancel" the application of an icon pack.
Remove an item, without confirmation, whatever its type.
item | object to remove |
---|
Manually set a bounding box for this container. The bounding box is interpreted according to the "Fit desktop to items" option.
bb | a custom bounding box rect, use null to let the container compute the default bounding box. |
---|
Move an item to another layer. This method will do nothing if the item cannot be found in this container.
itemId | item identifier as returned by getId() |
---|---|
index | new index, starting at 0 |
Go to a specified absolute position in this container. Does nothing when the script is run in background.
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 |
Go to a specified absolute position in this container, setting a scale of 1 and using animations.
x | absolute X position, in pixel |
---|---|
y | absolute Y position, in pixel |
Set a custom and persistent data for this container.
Using a null id is the same as using setTag(String)
without the id argument.
Set a custom and persistent data for this container. Same as setTag(null, value)
Display the Lightning "Add item" dialog. This method will do nothing if the script is run in background. The position of the item is automatically selected. During the item selection process, the app can be stopped by the system. As a consequence the newly created item (if any) is not retrieved through this method, use the container "Item added" event instead.
Convert horizontal coordinates in this container into screen coordinates. This function will return y if the script is run in background.
Convert vertical coordinates in this container into screen coordinates. This function will return y if the script is run in background.
Update the items bounding box. This should be called after items have been moved or resized. Since it can be an expansive operation, it is best to call this method once for many item, not after every item geometry change (if possible).