public class

ActivityScreen

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

Class Overview

A screen backed with an Android Activity.

Summary

Public Methods
ImageBitmap cropImage(ImageBitmap image, boolean full_size)
Request the user to select an area in the image.
void hideActionBar()
Hide the android action bar.
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 showActionBar(Function onCreateOptionsMenu, Function onOptionsItemSelected)
Display the Android action bar.
boolean startActivityForResult(Intent intent, Script receiver, String token)
Start an activity and handle the result in another script.
[Expand]
Inherited Methods
From class net.pierrox.lightning_launcher.script.api.screen.Screen
From class java.lang.Object

Public Methods

public ImageBitmap cropImage (ImageBitmap image, boolean full_size)

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.

Parameters
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)
Returns
  • a cropped image, or null if the operation failed or the user canceled it

public void hideActionBar ()

Hide the android action bar.

public int pickColor (String title, int color, boolean hasAlpha)

Request the user to pick a color.

Parameters
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.
Returns
  • either the selected color, or undefined if the dialog has been canceled

public Image pickImage (int maxPixels)

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.

Parameters
maxPixels maximum number of pixels in the returned image (width x height), 0 for no limit, 1048576 is one mega pixels (1024 x 1024)
Returns
  • an Image, or null if the user canceled the operation, or if the image cannot be loaded

public float pickNumericValue (String title, float value, String valueType, float min, float max, float interval, String unit)

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.

Parameters
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
Returns
  • either the selected value, or undefined if the dialog has been canceled

public void showActionBar (Function onCreateOptionsMenu, Function onOptionsItemSelected)

Display the Android action bar. Supported on Android 5.0+. When used in the app drawer, the android action bar will replace the current action bar. The action bar is not compatible with the system bar overlap option, which will be temporarily disabled. Sample script: http://www.lightninglauncher.com/wiki/doku.php?id=script_action_bar_sample

Parameters
onCreateOptionsMenu see https://developer.android.com/reference/android/app/Activity.html#onCreateOptionsMenu(android.view.Menu)
onOptionsItemSelected see https://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)

public boolean startActivityForResult (Intent intent, Script receiver, String token)

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:

  • resultCode: Integer, the activity result, most often Activity.RESULT_OK or Activity.RESULT_CANCELED
  • data: Intent, data provided by the activity, if any
  • token: String, optional value passed as third argument in startActivityForResult
This method cannot be called when the executing script is run in the background. In that case it will do nothing and return false

Parameters
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
Returns
  • true if the activity has been started