public class

Container

extends Object
java.lang.Object
   ↳ net.pierrox.lightning_launcher.script.api.Container
Known Direct Subclasses

Class Overview

The container can be either a desktop, a folder or a panel. Its role is to manage items inside.

Summary

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

Fields

public static final int NONE

Public Methods

public CustomView addCustomView (float x, float y)

Create a new custom view using default values.

public Folder addFolder (String label, float x, float y)

Create a new empty folder with the default icon and size.

Parameters
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)
Returns
  • the new folder

public PageIndicator addPageIndicator (float x, float y)

Create a new page indicator using default values.

public Panel addPanel (float x, float y, float width, float height)

Create a new empty panel. All coordinates are in pixels and rounded to the nearest cell when the item is attached to the grid.

Returns
  • the new panel

public Shortcut addShortcut (String label, Intent intent, float x, float y)

Create a new shortcut with the default icon and size.

Parameters
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)
Returns
  • the new shortcut

public StopPoint addStopPoint (float x, float y)

Create a new stop point with the default configuration.

Parameters
x absolute position (rounded to nearest cell when attached to grid)
y absolute position (rounded to nearest cell when attached to grid)
Returns
  • the new stop point

public void applyIconPack (boolean synchronous)

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.

Parameters
synchronous allow the operation to be done synchronously or asynchronously. Asynchronous is unsafe due to risks of container concurrent modifications running in the background.

public void cancelFling ()

Stop inertial movement initiated by a fling. Does nothing when the script is run in background.

public Item cloneItem (Item item)

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.

Parameters
item object to clone
Returns
  • the newly created item.

public Scriptable extend ()

Return a new script object, with this container as prototype

Returns
  • a new script object which inherit from this container

public Item[] getAllItems ()

Returns the list of items in this container

public RectL getBoundingBox ()

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.

public float getCellHeight ()

Returns the current computed cell width. It will return 0 if the script is run in background.

public float getCellWidth ()

Returns the current computed cell width. It will return 0 if the script is run in background.

public int getHeight ()

Returns the height of this container. This function will return 0 if the script is run in background.

public int getId ()

Returns the container unique identifier.

public Item getItemById (int id)

Retrieve an item using its identifier.

Parameters
id item identifier
Returns
  • an item, or undefined if not found

public Item getItemByLabel (String label)

This method is deprecated.
Use #getItemByName instead

public Item getItemByName (String name)

Retrieve an item using its name. If two or more items have the same name, the first is returned.

Parameters
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
  • an item, or undefined if not found.

public int getItemZIndex (int itemId)

Returns the Z-index of the item in the container.

Parameters
itemId item identifier as returned by getId()
Returns
  • the index or -1 if this item identifier is unknown in this container

public Array getItems ()

This method is deprecated.
use #getAllItems instead

Returns the list of items in this container

public Scriptable getMy ()

Return a scriptable object that can be used to store live data. These data won't be stored, unlike tags.

public Item getOpener ()

Returns the item used to open this container. This can either be a Folder or a Panel.

Returns
  • an item, or null if this container has no opener, i.e. this is a desktop.

public Container getParent ()

Returns the parent container for this container, or null if this container is a desktop.

public float getPositionScale ()

Returns the current scale. This function will return 1 if the script is run in background.

public float getPositionX ()

Returns the current absolute horizontal position. This function will return 0 if the script is run in background.

public float getPositionY ()

Returns the current absolute vertical position. This function will return 0 if the script is run in background.

public PropertySet getProperties ()

Retrieve container properties (configuration data). Please note that modifying properties for a container is particularly expensive and slow.

Returns
  • an object to read and write properties

public String getTag ()

Returns the value associated with this container. Same as getTag(null)

See Also

public String getTag (String id)

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.

See Also

public String getType ()

Used to identify the kind of this container.

Returns
  • 'Desktop', or 'Container' for any other type of container (folder, panel).

public ViewGroup getView ()

Retrieve the android View for this container. This function will return null if the script is run in background.

Returns
  • an instance of ItemLayout or null if it is not available in this context

public int getWidth ()

Returns the width of this container. This function will return 0 if the script is run in background.

public Item moveItem (Item item, Container to_other_container)

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.

Parameters
item the item to move
to_other_container the container in which to move the item
Returns
  • the new item

public void removeCustomIcons ()

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.

public void removeItem (Item item)

Remove an item, without confirmation, whatever its type.

Parameters
item object to remove

public void setBoundingBox (RectL bb)

Manually set a bounding box for this container. The bounding box is interpreted according to the "Fit desktop to items" option.

Parameters
bb a custom bounding box rect, use null to let the container compute the default bounding box.

public void setItemZIndex (int itemId, int index)

Move an item to another layer. This method will do nothing if the item cannot be found in this container.

Parameters
itemId item identifier as returned by getId()
index new index, starting at 0

public void setPosition (float x, float y, float scale, boolean animate)

Go to a specified absolute position in this container. Does nothing when the script is run in background.

Parameters
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

public void setPosition (float x, float y)

Go to a specified absolute position in this container, setting a scale of 1 and using animations.

Parameters
x absolute X position, in pixel
y absolute Y position, in pixel

public void setTag (String id, String value)

Set a custom and persistent data for this container. Using a null id is the same as using setTag(String) without the id argument.

public void setTag (String value)

Set a custom and persistent data for this container. Same as setTag(null, value)

public void showAddItemDialog ()

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.

public String toString ()

public float translateIntoScreenCoordX (float x)

Convert horizontal coordinates in this container into screen coordinates. This function will return y if the script is run in background.

public float translateIntoScreenCoordY (float y)

Convert vertical coordinates in this container into screen coordinates. This function will return y if the script is run in background.

public void updateBoundingBox ()

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).