public class

Screen

extends Object
java.lang.Object
   ↳ net.pierrox.lightning_launcher.script.api.screen.Screen
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The screen is the surface where user interactions occur. Example of known screens are:

Summary

Public Methods
Container[] getAllContainersById(int id)
Returns all containers for a given id.
Item[] getAllItemsById(int id)
Returns all items for a given id.
Container getContainerById(int id)
Returns the first container found with this id.
Context getContext()
Return the Android Context this screen is linked with (an activity context for the home, app drawer and lock screens, a service context for the floating desktop).
Desktop getCurrentDesktop()
Returns the currently displayed desktop.
Container getFocusedContainer()
Returns the focused container.
Item getItemById(int id)
Returns an item by its id.
float getLastTouchScreenX()
Absolute X position in the screen space of the last touch event.
float getLastTouchScreenY()
Absolute Y position in the screen space of the last touch event.
float getLastTouchX()
Absolute X position in the container space of the last touch event.
float getLastTouchY()
Absolute Y position in the container space of the last touch event.
Folder[] getOpenFolders()
Returns the list of currently open folders.
boolean isPaused()
Returns whether the current screen is paused.
void runAction(int action, String data)
Same as #runAction(int,Item,String) with a null item and data.
void runAction(int action, Item item, String data)
Run a Lightning action.
void runAction(int action)
Same as #runAction(int,String) with a null data.
void runScript(String name, String data)
Run another script.
void runScript(String path, String name, String data)
Run another script.
boolean startActivity(Intent intent)
Start an activity.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public Container[] getAllContainersById (int id)

Returns all containers for a given id. Warning: this is an expensive call.

public Item[] getAllItemsById (int id)

Returns all items for a given id. Warning: this is an expensive call.

public Container getContainerById (int id)

Returns the first container found with this id. As of Lightning V14, a single container may be displayed at several locations. This function returns the first one found, in no particular order. Calling this function can possibly be expensive because the container and its parents may have to be loaded on the fly.

public Context getContext ()

Return the Android Context this screen is linked with (an activity context for the home, app drawer and lock screens, a service context for the floating desktop). This is meant to be used with Android services.

public Desktop getCurrentDesktop ()

Returns the currently displayed desktop.

public Container getFocusedContainer ()

Returns the focused container. The focused container is usually the last touched container, or the last open folder. This can be either a desktop, folder or panel.

Returns
  • can be null if no container has been focused yet.

public Item getItemById (int id)

Returns an item by its id. This is a shortcut avoiding to traverse the list of all desktops and folders.

Parameters
id item identifier
Returns
  • an item, or null if this id is not known.

public float getLastTouchScreenX ()

Absolute X position in the screen space of the last touch event. This function returns Integer.MIN_VALUE if no touch has been registered yet.

Returns
  • x position expressed in screen coordinates.

public float getLastTouchScreenY ()

Absolute Y position in the screen space of the last touch event. This function returns Integer.MIN_VALUE if no touch has been registered yet.

Returns
  • y position expressed in screen coordinates.

public float getLastTouchX ()

Absolute X position in the container space of the last touch event. This function returns Integer.MIN_VALUE if no touch has been registered yet.

Returns
  • x position expressed in container coordinates, not in screen coordinates.

public float getLastTouchY ()

Absolute Y position in the container space of the last touch event. This function returns Integer.MIN_VALUE if no touch has been registered yet.

Returns
  • y position expressed in container coordinates, not in screen coordinates.

public Folder[] getOpenFolders ()

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.

Returns
  • an Array of Folder items, sorted top to bottom (topmost folder is at index 0).

public boolean isPaused ()

Returns whether the current screen is paused. It often means it is not displayed.

public void runAction (int action, String data)

Same as #runAction(int,Item,String) with a null item and data.

public void runAction (int action, Item item, String data)

Run a Lightning action. This method does nothing when the script is run in background.

Parameters
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

public void runAction (int action)

Same as #runAction(int,String) with a null data.

public void runScript (String name, String data)

Run another script. Same as calling runScript(null, name, data) with a null path.

public void runScript (String path, String name, String data)

Run another script. Optional data can be transmitted to the called script and retrieved using getData().

Parameters
path path of the script (null to look in all directories)
name name of the script as found in the script editor, optionally prefixed with its path
data optional data to send to the script. Use JSON to pass more than a string.

public boolean startActivity (Intent intent)

Start an activity. Example:

 var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.pierrox.net/")
 LL.startActivity(intent);

Parameters
intent intent to start the activity
Returns
  • true if launch is successful, false if activity not found or permission denied

public String toString ()