mirror of
https://github.com/TrianguloY/LightningLauncher.git
synced 2024-12-26 09:58:20 +01:00
Merge branch 'scriptAPI' of lightning-dev/lightning_launcher into 14.3-beta5
This commit is contained in:
commit
e9cdffcacf
42 changed files with 198 additions and 92 deletions
|
@ -16,6 +16,7 @@ javadoc \
|
|||
|
||||
sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/Lightning.html
|
||||
sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/LL.html
|
||||
sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/Event.html
|
||||
sed -i 's/getEvent_/getEvent/g' html/reference/current.xml
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<h1>Lightning Launcher Scripting API</h1>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
<p>Starting at version 10 (alpha 9.9), Lightning Launcher has support for extending its behavior through JavaScript. This is an advanced and extremly powerful feature, and for this reason it requires some care.</p>
|
||||
<p>The description of LL script APIs can be found here {@link net.pierrox.lightning_launcher.script.api}. The {@link LL} objet is the entry point for most things.</p>
|
||||
<p>Starting at version 10 (alpha 9.9), Lightning Launcher has support for extending its behavior through JavaScript. This is an advanced and extremely powerful feature, and for this reason it requires some care.</p>
|
||||
<p>The description of LL script APIs can be found here {@link net.pierrox.lightning_launcher.script.api}. The {@link LL} object is the entry point for most things.</p>
|
||||
|
||||
<h2>Available Android classes</h2>
|
||||
<p>Some Android classes can be directly used through scripting (creation of new instances, access to static fields - aka constants - and method calls). The list of supported classes are:
|
||||
|
@ -35,26 +35,26 @@
|
|||
<li>TaskerIntent</li>
|
||||
<li>ActionCodes</li>
|
||||
</ul>
|
||||
Other classes can be accessed through their fully qualified name. For instance, should you need to access accelerometers, you may want to use <code>android.hardware.Sensor.TYPE_ACCELEROMETER</code>. Using <code>LL.bindClass(String name)</code> will conveniently suppress the need for explicit package naming (<code>Sensor.TYPE_ACCELEROMETER</code> would be enough if <code>LL.bindClass("android.hardware.Sensor");</code> has been called previously.
|
||||
Other classes can be accessed through their fully qualified name. For instance, should you need to access accelerometers, you may want to use <code>android.hardware.Sensor.TYPE_ACCELEROMETER</code>. Using <code>bindClass(String name)</code> will conveniently suppress the need for explicit package naming (<code>Sensor.TYPE_ACCELEROMETER</code> would be enough if <code>bindClass("android.hardware.Sensor");</code> has been called previously.
|
||||
</p>
|
||||
|
||||
<h2>Things to be aware of</h2>
|
||||
<p>Use the new Script Editor icon (in your app drawer) to quickly edit scripts. No need to configure events and select run a script: just launch the script editor and it will open on the last edited script.</p>
|
||||
|
||||
<h2>DOs and DON'Ts</h2>
|
||||
<h3>Use and absuse from variables</h3>
|
||||
<h3>Use and abuse from variables</h3>
|
||||
<p>API calls are expensive, and you never know what is hidden behind. It is a good idea to keep return values in local variables to minimize API calls. For instance:
|
||||
<pre>
|
||||
alert(LL.getEvent().getTouchX()+" / "+LL.getEvent().getTouchY()); /* BAD */
|
||||
alert(getEvent().getTouchX()+" / "+getEvent().getTouchY()); /* BAD */
|
||||
|
||||
var e = LL.getEvent();
|
||||
var e = getEvent();
|
||||
alert(e.getTouchX()+" / "+e.getTouchY()); /* BETTER */
|
||||
</pre>
|
||||
</p>
|
||||
<h3>Not suitable for (smooth) animations</h3>
|
||||
<p>While it is possible to move, rotate or change items configuration, performances may not be enough to sustain a 60Hz animation rate.</p>
|
||||
<h3>Timers</h3>
|
||||
<p>It is possible to set timers using setTimeout. Pay special attention to clear these timers when needed, LL won't do this for you. If you don't clear timers, you may severly increase CPU use and battery consumption.</p>
|
||||
<p>It is possible to set timers using setTimeout. Pay special attention to clear these timers when needed, LL won't do this for you. If you don't clear timers, you may severely increase CPU use and battery consumption.</p>
|
||||
|
||||
<h3>Object references</h3>
|
||||
<p>Avoid keeping references to objects returned by LL APIs in the script side, otherwise you may leak data. It is possible to use <pre>self</pre> to store data that are kept between two script execution (and can be shared between scripts), but try to avoid this as much as possible.</p>
|
||||
|
|
|
@ -1762,10 +1762,10 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
|||
if(mNoScriptCounter == 5) {
|
||||
ScriptManager sm = mEngine.getScriptManager();
|
||||
Script easter_egg = sm.createScriptForFile(getString(R.string.mi_nost), "/"+getPackageName().replace('.', '/'));
|
||||
easter_egg.setSourceText("LL.bindClass('android.view.animation.AccelerateDecelerateInterpolator');\n" +
|
||||
"LL.bindClass('android.view.animation.AnimationUtils');\n" +
|
||||
easter_egg.setSourceText("bindClass('android.view.animation.AccelerateDecelerateInterpolator');\n" +
|
||||
"bindClass('android.view.animation.AnimationUtils');\n" +
|
||||
"\n" +
|
||||
"var item = LL.getEvent().getItem();\n" +
|
||||
"var item = getEvent().getItem();\n" +
|
||||
"\n" +
|
||||
"var properties = item.getProperties();\n" +
|
||||
"var was_on_grid = properties.getBoolean('i.onGrid');\n" +
|
||||
|
|
|
@ -49,8 +49,8 @@ import net.pierrox.lightning_launcher.Version;
|
|||
import net.pierrox.lightning_launcher.data.FileUtils;
|
||||
import net.pierrox.lightning_launcher.data.Utils;
|
||||
import net.pierrox.lightning_launcher.engine.LightningEngine;
|
||||
import net.pierrox.lightning_launcher.script.ScriptManager;
|
||||
import net.pierrox.lightning_launcher.script.Script;
|
||||
import net.pierrox.lightning_launcher.script.ScriptManager;
|
||||
import net.pierrox.lightning_launcher.script.api.Array;
|
||||
import net.pierrox.lightning_launcher.script.api.Box;
|
||||
import net.pierrox.lightning_launcher.script.api.Container;
|
||||
|
@ -64,7 +64,6 @@ import net.pierrox.lightning_launcher.script.api.ImageNinePatch;
|
|||
import net.pierrox.lightning_launcher.script.api.ImageScript;
|
||||
import net.pierrox.lightning_launcher.script.api.ImageSvg;
|
||||
import net.pierrox.lightning_launcher.script.api.Item;
|
||||
import net.pierrox.lightning_launcher.script.api.LL;
|
||||
import net.pierrox.lightning_launcher.script.api.Lightning;
|
||||
import net.pierrox.lightning_launcher.script.api.PageIndicator;
|
||||
import net.pierrox.lightning_launcher.script.api.Panel;
|
||||
|
@ -240,7 +239,9 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
}
|
||||
}
|
||||
private static ArrayList<TokenMethod> sAutoCompleteTokens;
|
||||
private static TokenClass sLLToken = new TokenClass(LL.class);
|
||||
private static Token[] sMainTokens = new Token[]{
|
||||
new TokenMethod(Lightning.class, "getEvent", "void", new Class[0])
|
||||
};
|
||||
|
||||
private Animation mLeftPaneAnimIn;
|
||||
private Animation mLeftPaneAnimOut;
|
||||
|
@ -967,7 +968,7 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
ImageScript.class,
|
||||
ImageSvg.class,
|
||||
Item.class,
|
||||
LL.class,
|
||||
//LL.class,
|
||||
Lightning.class,
|
||||
Panel.class,
|
||||
StopPoint.class,
|
||||
|
@ -1205,7 +1206,10 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
|
||||
mCompletionsViewGroup.removeAllViews();
|
||||
final LayoutInflater inflater = getLayoutInflater();
|
||||
addSugestion(inflater, sLLToken);
|
||||
if(completions.isEmpty()) {
|
||||
// add main Tokens if no others are available
|
||||
addSugestions(inflater, sMainTokens);
|
||||
}
|
||||
for (ArrayList<Token> tokens : completions) {
|
||||
addSugestion(inflater, tokens);
|
||||
}
|
||||
|
@ -1226,10 +1230,12 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
completions.add(l);
|
||||
}
|
||||
|
||||
private void addSugestion(LayoutInflater inflater, Token token) {
|
||||
ArrayList<Token> l = new ArrayList<>(1);
|
||||
l.add(token);
|
||||
addSugestion(inflater, l);
|
||||
private void addSugestions(LayoutInflater inflater, Token[] tokens) {
|
||||
for (Token token : tokens) {
|
||||
ArrayList<Token> l = new ArrayList<>(1);
|
||||
l.add(token);
|
||||
addSugestion(inflater, l);
|
||||
}
|
||||
}
|
||||
|
||||
private void addSugestion(LayoutInflater inflater, ArrayList<Token> tokens) {
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.pierrox.lightning_launcher.LLApp;
|
||||
import net.pierrox.lightning_launcher.R;
|
||||
import net.pierrox.lightning_launcher.api.ScreenIdentity;
|
||||
|
@ -68,7 +70,9 @@ public class MultiPurposeTransparentActivity extends ResourceWrapperActivity {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// should pass the base dir of the engine in the intent and use it instead of the default engine
|
||||
LLApp.get().getAppEngine().getScriptManager().getOrLoadScript(script_id).setFlag(Script.FLAG_DISABLED, true);
|
||||
LLApp llApp = LLApp.get();
|
||||
llApp.getAppEngine().getScriptManager().getOrLoadScript(script_id).setFlag(Script.FLAG_DISABLED, true);
|
||||
Toast.makeText(llApp, R.string.sc_disable_toast, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -344,6 +344,7 @@ public class ScriptExecutor {
|
|||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mCurrentScriptDialog = false;
|
||||
mCurrentScript.setFlag(Script.FLAG_DISABLED, true);
|
||||
Toast.makeText(context, R.string.sc_disable_toast, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
|
@ -406,6 +407,7 @@ public class ScriptExecutor {
|
|||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mCurrentScriptDialog = false;
|
||||
script.setFlag(Script.FLAG_DISABLED, true);
|
||||
Toast.makeText(context, R.string.sc_disable_toast, Toast.LENGTH_LONG).show();
|
||||
continuePendingContinuation(pending, input == null ? false : null);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,25 +42,26 @@ public class ScriptManager {
|
|||
|
||||
BUILTINS = new Script[] {
|
||||
new Script(this, Script.TYPE_BUILTIN, BUILTIN_USER_MENU, null,
|
||||
"var item = LL.getEvent().getItem();\n"+
|
||||
"LL.runAction(EventHandler.CLOSE_TOPMOST_FOLDER);\n"+
|
||||
"var item = getEvent().getItem();\n"+
|
||||
"var screen = getEvent().getScreen();\n"+
|
||||
"screen.runAction(EventHandler.CLOSE_TOPMOST_FOLDER);\n"+
|
||||
"switch(item.getName()) {\n"+
|
||||
" case 'wallpaper': LL.runAction(EventHandler.SELECT_WALLPAPER); break;\n"+
|
||||
" case 'wallpaper': screen.runAction(EventHandler.SELECT_WALLPAPER); break;\n"+
|
||||
" case 'theme': " +
|
||||
" var intent=new Intent(Intent.ACTION_VIEW, Uri.parse('"+ Version.BROWSE_TEMPLATES_URI+"'));"+
|
||||
" var intent=new Intent(Intent.ACTION_VIEW, Uri.parse('"+ Version.BROWSE_TEMPLATES_URI+"'));\n"+
|
||||
" intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n"+
|
||||
" LL.startActivity(intent);\n"+
|
||||
" screen.startActivity(intent);\n"+
|
||||
" break;\n"+
|
||||
" case 'add_item': LL.runAction(EventHandler.ADD_ITEM); break;\n"+
|
||||
" case 'edit_layout': LL.runAction(EventHandler.EDIT_LAYOUT); break;\n"+
|
||||
" case 'settings': LL.runAction(EventHandler.CUSTOMIZE_LAUNCHER); break;\n"+
|
||||
" case 'add_item': screen.runAction(EventHandler.ADD_ITEM); break;\n"+
|
||||
" case 'edit_layout': screen.runAction(EventHandler.EDIT_LAYOUT); break;\n"+
|
||||
" case 'settings': screen.runAction(EventHandler.CUSTOMIZE_LAUNCHER); break;\n"+
|
||||
"}",
|
||||
null
|
||||
),
|
||||
new Script(this, Script.TYPE_BUILTIN, BUILTIN_REPOSITORY_IMPORTER, null,
|
||||
"/*Script necessary for the repository importer to work correctly.*/\n" +
|
||||
"\n" +
|
||||
"eval(\"function toEval(){\\n\"+LL.loadRawResource(\"com.trianguloy.llscript.repository\",\"executor\")+\"\\n}\");\n" +
|
||||
"eval(\"function toEval(){\\n\"+loadRawResource(\"com.trianguloy.llscript.repository\",\"executor\")+\"\\n}\");\n" +
|
||||
"toEval();",
|
||||
null
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.widget.Toast;
|
|||
|
||||
/**
|
||||
* The Android object gives access to some platform services.
|
||||
* @deprecated use the android.widget.Toast class instead
|
||||
* @deprecated use the android.widget.Toast class directly or the {@link Lightning#toast(String)} alternative instead
|
||||
*/
|
||||
public class Android {
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
|
||||
/**
|
||||
* A binding links a "target" (a property) with a "formula" (a value).
|
||||
* An instance of this object can be created with {@link #Binding(String, String, boolean)}; or retrieved with {@link Item#getBindingByTarget(String)} or {@link Item#getBindings()}.
|
||||
*/
|
||||
public class Binding {
|
||||
private boolean enabled;
|
||||
|
|
|
@ -23,7 +23,9 @@ import net.pierrox.lightning_launcher.data.Utils;
|
|||
* <li>Padding bottom:<b>pb</b></li>
|
||||
* <li>Content:<b>c</b></li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link PropertyEditor#getBox(String)} or {@link PropertySet#getBox(String)}.
|
||||
*
|
||||
* Example of using the Box object to change item properties:
|
||||
* <pre>
|
||||
* var color = 0xff00ff00; // pure green
|
||||
|
|
|
@ -7,15 +7,13 @@ import android.view.ViewGroup;
|
|||
|
||||
import com.faendir.rhino_android.RhinoAndroidHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.pierrox.lightning_launcher.R;
|
||||
import net.pierrox.lightning_launcher.data.EmbeddedFolder;
|
||||
import net.pierrox.lightning_launcher.data.IconPack;
|
||||
import net.pierrox.lightning_launcher.engine.LightningEngine;
|
||||
import net.pierrox.lightning_launcher.data.Page;
|
||||
import net.pierrox.lightning_launcher.data.Utils;
|
||||
import net.pierrox.lightning_launcher.engine.LightningEngine;
|
||||
import net.pierrox.lightning_launcher.script.api.screen.Screen;
|
||||
import net.pierrox.lightning_launcher.views.ItemLayout;
|
||||
import net.pierrox.lightning_launcher.views.item.ItemView;
|
||||
|
||||
|
@ -25,8 +23,13 @@ import org.mozilla.javascript.NativeJavaObject;
|
|||
import org.mozilla.javascript.ScriptRuntime;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The container can be either a desktop, a folder or a panel. Its role is to manage items inside.
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Event#getContainer()}, {@link Item#getParent()}, {@link Folder#getContainer()}, {@link Panel#getContainer()}, {@link net.pierrox.lightning_launcher.script.api.screen.Screen#getContainerById(int)}, {@link net.pierrox.lightning_launcher.script.api.screen.Screen#getAllContainersById(int)} or {@link Screen#getFocusedContainer()}; or by using directly the special variable 'container' (which is the current Container) when running a 'Menu' event.
|
||||
*/
|
||||
public class Container {
|
||||
public static final int NONE = Page.NONE;
|
||||
|
|
|
@ -2,10 +2,14 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import net.pierrox.lightning_launcher.script.api.screen.Screen;
|
||||
import net.pierrox.lightning_launcher.views.item.CustomViewView;
|
||||
import net.pierrox.lightning_launcher.views.item.ItemView;
|
||||
|
||||
/**
|
||||
* A CustomView is an advance special item that can display any Android View.
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Container#addCustomView(float, float)}; or with any function that returns an {@link Item} when that returned item is a CustomView; or by using directly the special variable 'item' (which is the current CustomView) when running a 'Create/Destroy script' event.
|
||||
*/
|
||||
public class CustomView extends Item {
|
||||
/**
|
||||
* @hide
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.pierrox.lightning_launcher.views.ItemLayout;
|
|||
/**
|
||||
* The desktop is a kind of container, and is typically displayed as the home screen.
|
||||
* It includes all capabilities of the base container, plus some other ones specific to desktops.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns a {@link Container} when that returned container is a Desktop; or with {@link net.pierrox.lightning_launcher.script.api.screen.HomeScreen#getDesktopByName(String)} or {@link net.pierrox.lightning_launcher.script.api.screen.Screen#getCurrentDesktop()}.
|
||||
*/
|
||||
public class Desktop extends Container {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.pierrox.lightning_launcher.views.item.ItemView;
|
|||
|
||||
/**
|
||||
* The event gather useful data dealing with the context of the event, such as which item caused the script to be executed, or what was the container at time of the event.
|
||||
* @see LL#getEvent().
|
||||
* An instance of this object can be retrieved with {@link Lightning#getEvent_()}.
|
||||
*/
|
||||
public class Event {
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class Event {
|
|||
}
|
||||
|
||||
/**
|
||||
* Optional data that may have passed to this script when run from {@link LL#runScript(String, String)}.
|
||||
* Optional data that may have passed to this script when run from {@link Screen#runScript(String, String)}.
|
||||
*/
|
||||
public String getData() {
|
||||
return mData;
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.pierrox.lightning_launcher.data.EventAction;
|
|||
* Describe an event handler made of an action, some optional data and possibly a handler to execute after this one.
|
||||
* Handlers are chained in a linked list. The last handler in the list has no next.
|
||||
* When modifying an EventHandler acquired from {@link PropertySet#getEventHandler(String)}, you still need to call {@link PropertyEditor#setEventHandler(String, EventHandler)} to save changes.
|
||||
*
|
||||
* An instance of this object can be created with {@link #EventHandler(int, String)}; or retrieved with {@link PropertySet#getEventHandler(String)}.
|
||||
*/
|
||||
public class EventHandler {
|
||||
public static final int UNSET=0;
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.pierrox.lightning_launcher.data.*;
|
||||
import net.pierrox.lightning_launcher.engine.Screen;
|
||||
import net.pierrox.lightning_launcher.views.FolderView;
|
||||
import net.pierrox.lightning_launcher.views.ItemLayout;
|
||||
|
@ -12,7 +11,9 @@ import net.pierrox.lightning_launcher.views.item.ItemView;
|
|||
import java.io.File;
|
||||
|
||||
/**
|
||||
* The folder item extends the shortcut (because it have a label and an icon) and add folder specific services such as open/close.
|
||||
* The folder item extends the shortcut (because it have a label and an icon) and add folder specific services such as open/close.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns a {@link Shortcut} when that returned shortcut is a Folder; or with {@link Container#addFolder(String, float, float)} or {@link net.pierrox.lightning_launcher.script.api.screen.Screen#getOpenFolders()}.
|
||||
*/
|
||||
public class Folder extends Shortcut {
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ import java.lang.reflect.Field;
|
|||
* Utility class to manipulate images (icons, backgrounds, etc.).
|
||||
* This is the base class for various kind of images. Each image type (bitmap, nine patch, animation, scripted) have their own set of features.
|
||||
* Please refer to their respective documentation.
|
||||
*
|
||||
* An instance of this object can be created with {@link #createImage(String)}, {@link #createImage(String, String)}, {@link #fromDrawable(Lightning, Drawable, Item, File)}; or retrieved with {@link Folder#getWindowBackground()}, {@link net.pierrox.lightning_launcher.script.api.Item#getBoxBackground(String)}, {@link Shortcut#getDefaultIcon()}, {@link Shortcut#getCustomIcon()}, {@link Shortcut#getImage()}, {@link Shortcut#getIconLayer(String)} or {@link net.pierrox.lightning_launcher.script.api.screen.ActivityScreen#pickImage(int)}.
|
||||
*/
|
||||
public abstract class Image {
|
||||
protected Lightning mLightning;
|
||||
|
@ -264,7 +266,7 @@ public abstract class Image {
|
|||
|
||||
/**
|
||||
* Create an image from a package and a resource name.
|
||||
* For instance:<code>LL.createImage("net.pierrox.lightning_launcher_extreme", "icon")</code>
|
||||
* For instance:<code>Image.createImage("net.pierrox.lightning_launcher_extreme", "icon")</code>
|
||||
* The density used is either the one given by ActivityManager.getLauncherLargeIconDensity if available, or the current one.
|
||||
* @param pkg name of the package, use "android" to access system resources.
|
||||
* @param name name of the drawable resource
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.io.File;
|
|||
* A kind of image which can play an animation (often loaded from GIF files).
|
||||
*
|
||||
* <b>Note</b>: as of today backgrounds and icon layers do not support animations, only the first frame will be displayed.
|
||||
*
|
||||
* An instance of this object can be created with {@link Image#createAnimation(int, int, int, int, int)}; or retrieved with any function that returns an {@link Image} when that image is an ImageAnimation.
|
||||
*/
|
||||
public class ImageAnimation extends Image {
|
||||
private SharedAsyncGraphicsDrawable mDrawable;
|
||||
|
|
|
@ -2,12 +2,11 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import net.pierrox.lightning_launcher.LLApp;
|
||||
import net.pierrox.lightning_launcher.engine.*;
|
||||
import net.pierrox.lightning_launcher.engine.Screen;
|
||||
import net.pierrox.lightning_launcher.views.SharedAsyncGraphicsDrawable;
|
||||
import net.pierrox.lightning_launcher.views.item.ItemView;
|
||||
|
@ -18,7 +17,9 @@ import java.io.IOException;
|
|||
|
||||
/**
|
||||
* Wraps a static bitmap.
|
||||
* Such an image can be loaded from file, created using {@link LL#createImage(int, int)}, or obtained from items icons.
|
||||
* Such an image can be loaded from file, created using {@link Image#createImage(int, int)}, or obtained from items icons.
|
||||
*
|
||||
* An instance of this object can be created with {@link Image#createImage(int, int)} or {@link Image#createTextIcon(String, int, int, int, Typeface)}; or retrieved with any function that returns an {@link Image} when that image is an ImageBitmap; or with {@link ImageAnimation#getFrameImage(int)} or {@link net.pierrox.lightning_launcher.script.api.screen.ActivityScreen#cropImage(ImageBitmap, boolean)}.
|
||||
*/
|
||||
public class ImageBitmap extends Image {
|
||||
private Bitmap mBitmap;
|
||||
|
@ -101,7 +102,7 @@ public class ImageBitmap extends Image {
|
|||
* <ul>
|
||||
* <li>{@link net.pierrox.lightning_launcher.script.api.Shortcut#getDefaultIcon()}</li>
|
||||
* <li>{@link net.pierrox.lightning_launcher.script.api.Shortcut#getCustomIcon()}</li>
|
||||
* <li>{@link net.pierrox.lightning_launcher.script.api.LL#createImage(String)}</li>
|
||||
* <li>{@link Image#createImage(String)}</li>
|
||||
* Calling this method on an image without source file will do nothing.
|
||||
*/
|
||||
public void save() {
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.graphics.drawable.NinePatchDrawable;
|
|||
|
||||
/**
|
||||
* Wraps a Nine Patch image.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Image} when that image is an ImageNinePatch.
|
||||
*/
|
||||
public class ImageNinePatch extends Image {
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ import org.mozilla.javascript.Scriptable;
|
|||
/**
|
||||
* ImageScript is a way to draw images or animations without the need for intermediate bitmaps.
|
||||
* Such images are scalable and memory efficient.
|
||||
* Instances of ImageScript can be created with {@link LL#createImage(Scriptable, int, int)}.
|
||||
*
|
||||
* An instance of this object can be created with {@link Image#createImage(Scriptable, int, int)}; or retrieved with any function that returns an {@link Image} when that image is an ImageScript.
|
||||
*
|
||||
* The Scriptable object must have a "draw" function, and optionally a "pause" and "resume" functions. These functions are called with a DrawingContext instance.
|
||||
* <br/><br/>
|
||||
|
@ -20,7 +21,7 @@ import org.mozilla.javascript.Scriptable;
|
|||
* <br/><br/>
|
||||
* Sample 1 : draw a static image.
|
||||
* <code><pre>
|
||||
* var img = LL.createImage({
|
||||
* var img = Image.createImage({
|
||||
* draw: function(context) {
|
||||
* var canvas = context.getCanvas();
|
||||
* var w = context.getWidth();
|
||||
|
@ -88,7 +89,7 @@ import org.mozilla.javascript.Scriptable;
|
|||
* timers: {}
|
||||
* };
|
||||
*
|
||||
* var img = LL.createImage(drawing, -1, -1);
|
||||
* var img = Image.createImage(drawing, -1, -1);
|
||||
* </pre></code>
|
||||
*/
|
||||
public class ImageScript extends Image {
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.pierrox.android.lsvg.SvgDrawable;
|
|||
|
||||
/**
|
||||
* An image backed by a SVG document
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Image} when that image is an ImageSvg.
|
||||
*/
|
||||
|
||||
public class ImageSvg extends Image {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package net.pierrox.lightning_launcher.script.api;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -13,9 +9,10 @@ import android.widget.TextView;
|
|||
|
||||
import net.pierrox.lightning_launcher.LLApp;
|
||||
import net.pierrox.lightning_launcher.configuration.ItemConfig;
|
||||
import net.pierrox.lightning_launcher.data.*;
|
||||
import net.pierrox.lightning_launcher.data.Box;
|
||||
import net.pierrox.lightning_launcher.data.Page;
|
||||
import net.pierrox.lightning_launcher.data.Shortcut;
|
||||
import net.pierrox.lightning_launcher.data.Utils;
|
||||
import net.pierrox.lightning_launcher.script.api.screen.Screen;
|
||||
import net.pierrox.lightning_launcher.views.IconLabelView;
|
||||
import net.pierrox.lightning_launcher.views.ItemLayout;
|
||||
|
@ -27,6 +24,10 @@ import org.mozilla.javascript.NativeJavaObject;
|
|||
import org.mozilla.javascript.ScriptRuntime;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The item is the base class for other objects that can be found in a container (shortcuts, folders, etc.).
|
||||
* There are specific classes for some items (shortcut, folder, ...) when these items provides custom services.
|
||||
|
@ -34,6 +35,8 @@ import org.mozilla.javascript.Scriptable;
|
|||
*
|
||||
* Since Lightning V14 allows the same container to be displayed multiple times on the same screen, it is possible to retrieve
|
||||
* several Item objects linked with the same underlying data. The identifier (see {@link #getId()}) will then be the same.
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Event#getItem()}, {@link Screen#getItemById(int)}, {@link Screen#getAllItemsById(int)}, {@link Container#getAllItems()}, {@link Container#getItemById(int)}, {@link Container#getItemByName(String)}, {@link Container#cloneItem(Item)}, {@link Container#moveItem(Item, Container)}, {@link Container#getOpener()} or {@link ImageScript.DrawingContext#getItem()}; or by using directly the special variable 'item' (which is the current Item) when running a 'Menu' event.
|
||||
*/
|
||||
public class Item {
|
||||
|
||||
|
@ -61,7 +64,11 @@ public class Item {
|
|||
object.setPrototype(new NativeJavaObject(scope, this, null));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the Screen where this item is placed.
|
||||
* @return the screen containing this item
|
||||
*/
|
||||
public Screen getScreen() {
|
||||
return mLightning.createScreen(mItemView.getParentItemLayout().getScreen());
|
||||
}
|
||||
|
|
|
@ -514,7 +514,7 @@ public class LL {
|
|||
* @return an animation or null in case of error (most likely out of memory)
|
||||
*
|
||||
* @deprecated use {@link Image#createAnimation(int, int, int, int, int)} instead
|
||||
* <br><code>LL.createAnimation(width, height, count, duration, loopCount) -> Image.createImage(width, height, count, duration, loopCount)</code>
|
||||
* <br><code>LL.createAnimation(width, height, count, duration, loopCount) -> Image.createAnimation(width, height, count, duration, loopCount)</code>
|
||||
*/
|
||||
public ImageAnimation createAnimation(int width, int height, int count, int duration, int loopCount) {
|
||||
return Image.createAnimation(width, height, count, duration, loopCount);
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.content.res.Resources;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.faendir.rhino_android.RhinoAndroidHelper;
|
||||
|
||||
|
@ -42,8 +43,8 @@ import java.util.ArrayList;
|
|||
|
||||
/**
|
||||
* Entry point for most Lightning Launcher scripted features.
|
||||
* The Lightning object is the root object in the script context, hence its functions can be called without naming it, unlike with the deprecated LL object.
|
||||
* For instance, instead of using <code>LL.getDesktopByName('d')</code>, simply use <code>getDesktopByName('d')</code>
|
||||
* The Lightning object is the root object in the script context, hence its functions can be called without naming it (unlike the rest of the classes).
|
||||
* For instance, instead of using <code style="color:#333">Lightning.alert('Hello World')</code>, simply use <code>alert('Hello World')</code>
|
||||
*/
|
||||
public class Lightning {
|
||||
|
||||
|
@ -339,6 +340,9 @@ public class Lightning {
|
|||
return createScreen(LLApp.get().getScreen(net.pierrox.lightning_launcher.api.ScreenIdentity.BACKGROUND));
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public Screen createScreen(net.pierrox.lightning_launcher.engine.Screen screen) {
|
||||
if(screen == null){
|
||||
return null;
|
||||
|
@ -352,21 +356,21 @@ public class Lightning {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set a boolean variable. This is a shortcut for <code>LL.getVariables().edit().setBoolean(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
* Set a boolean variable. This is a shortcut for <code>getVariables().edit().setBoolean(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
*/
|
||||
public void setVariableBoolean(String name, boolean value) {
|
||||
setVariable(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a boolean variable. This is a shortcut for <code>LL.getVariables().edit().setInteger(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
* Set a boolean variable. This is a shortcut for <code>getVariables().edit().setInteger(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
*/
|
||||
public void setVariableInteger(String name, long value) {
|
||||
setVariable(name, (int)value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a boolean variable. This is a shortcut for <code>LL.getVariables().edit().setFloat(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
* Set a boolean variable. This is a shortcut for <code>getVariables().edit().setFloat(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
*/
|
||||
public void setVariableFloat(String name, float value) {
|
||||
if(Float.isNaN(value)) {
|
||||
|
@ -376,7 +380,7 @@ public class Lightning {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set a string variable. This is a shortcut for <code>LL.getVariables().edit().setString(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
* Set a string variable. This is a shortcut for <code>getVariables().edit().setString(name, value).commit();</code>. When modifying several at once, consider using the {@link net.pierrox.lightning_launcher.script.api.PropertyEditor} object instead for best efficiency.
|
||||
*/
|
||||
public void setVariableString(String name, String value) {
|
||||
setVariable(name, value);
|
||||
|
@ -573,7 +577,7 @@ public class Lightning {
|
|||
context.sendBroadcast(intent);
|
||||
throw pending;
|
||||
} catch(IllegalStateException e) {
|
||||
android.widget.Toast.makeText(context, "cannot wait for Tasker result in this context, set 'synchronous' to false", android.widget.Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, "cannot wait for Tasker result in this context, set 'synchronous' to false", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
} finally {
|
||||
org.mozilla.javascript.Context.exit();
|
||||
|
@ -637,16 +641,26 @@ public class Lightning {
|
|||
throw pending;
|
||||
} catch (IllegalStateException e) {
|
||||
// not called with continuation support
|
||||
android.widget.Toast.makeText(context, "cannot display \"" + message + "\" in this context", android.widget.Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, "cannot display \"" + message + "\" in this context", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
} finally {
|
||||
org.mozilla.javascript.Context.exit();
|
||||
}
|
||||
} else {
|
||||
android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a toast (small message at the bottom of the screen).
|
||||
* This is equivalent to <code>Toast.makeText(getEvent().getScreen().getContext(), text, Toast.LENGTH_LONG).show()</code>
|
||||
* (you can use that code directly if you want a LENGTH_SHORT toast or to save the toast object instead of showing it).
|
||||
* @param text message to display
|
||||
*/
|
||||
public void toast(String text){
|
||||
Toast.makeText(getScriptScreen().getContext(), text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a function later.
|
||||
|
|
|
@ -7,6 +7,8 @@ import org.mozilla.javascript.Function;
|
|||
|
||||
/**
|
||||
* Provides an access to the popup menu, so that it can be customized.
|
||||
*
|
||||
* An instance of this object can be retrieved by using directly the special variable 'menu' (which is the current Menu) when running a 'Menu' event.
|
||||
*/
|
||||
public class Menu {
|
||||
/** Main item menu in edit mode */
|
||||
|
|
|
@ -2,6 +2,11 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
|
||||
import net.pierrox.lightning_launcher.views.item.ItemView;
|
||||
|
||||
/**
|
||||
* Represents a Page Indicator Item. No extra methods available.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Item} when that returned item is a PageIndicator; or with {@link Container#addPageIndicator(float, float)}.
|
||||
*/
|
||||
public class PageIndicator extends Item {
|
||||
/**
|
||||
* @hide
|
||||
|
|
|
@ -5,6 +5,8 @@ import net.pierrox.lightning_launcher.views.item.ItemView;
|
|||
|
||||
/**
|
||||
* The panel is a special kind of item, providing access to items contained in this panel.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Item} when that returned item is a Panel; or with {@link Container#addPanel(float, float, float, float)}.
|
||||
*/
|
||||
public class Panel extends Item {
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@ import net.pierrox.lightning_launcher.R;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* Enumeration class. Represents a Property object {@see PropertySet} {@see PropertyEditor}.
|
||||
*
|
||||
* An instance of this object can be created with {@link #getByName(String)}.
|
||||
*/
|
||||
public class Property {
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
public static final int TYPE_BOOLEAN = 0;
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.HashMap;
|
|||
|
||||
/**
|
||||
* Utility to modify one or more configuration settings at once. Modify one or more properties using the same PropertyEditor, then call {@link #commit()} to validate changes.
|
||||
* This object is retrieved using {@link PropertySet#edit()}. You can chain calls this way:
|
||||
* An instance of this object can be retrieved with {@link PropertySet#edit()}. You can chain calls this way:
|
||||
* <pre><code>
|
||||
* property_set.edit()
|
||||
* .setInteger("someProperty", some_value)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.pierrox.lightning_launcher.script.api;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import android.util.Pair;
|
||||
|
||||
import net.pierrox.lightning_launcher.configuration.FolderConfig;
|
||||
import net.pierrox.lightning_launcher.configuration.GlobalConfig;
|
||||
|
@ -8,20 +8,21 @@ import net.pierrox.lightning_launcher.configuration.ItemConfig;
|
|||
import net.pierrox.lightning_launcher.configuration.PageConfig;
|
||||
import net.pierrox.lightning_launcher.configuration.ShortcutConfig;
|
||||
import net.pierrox.lightning_launcher.configuration.ShortcutConfigStylable;
|
||||
import net.pierrox.lightning_launcher.data.*;
|
||||
import net.pierrox.lightning_launcher.data.EventAction;
|
||||
import net.pierrox.lightning_launcher.data.Page;
|
||||
|
||||
import android.util.Pair;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Access to container and item properties (aka settings).
|
||||
* This object provides a way to query for configuration options as well as a mean to update them (see {@link #edit()}.
|
||||
* Properties are accessed through their named. There are different property classes:
|
||||
* This object provides a way to query for configuration options as well as a mean to update them (see {@link #edit()}).
|
||||
* Properties are accessed through their name. There are different property classes:
|
||||
* <ul>
|
||||
* <li>container properties: options that can be seen in the desktop, folder and panel settings screen</li>
|
||||
* <li>item properties: options available to all objects (such as box properties or pin mode)</li>
|
||||
* <li>shortcut properties: options related to text/icon objects (including apps, shortcuts, folders and dynamic texts)</li>
|
||||
* <li>folder properties: options related to folder window (hence only for folder objects)</li>
|
||||
* </ul>
|
||||
* <li>folder properties: options related to folder window (hence only for folder objects)</li>
|
||||
* </ul>
|
||||
* Available properties depends on the object from which this PropertySet is retrieved:
|
||||
* <ul>
|
||||
* <li>Container: contains properties for the container and default properties for items, shortcuts and folders.</li>
|
||||
|
@ -30,9 +31,12 @@ import android.util.Pair;
|
|||
* <li>Page Indicator: item, shortcut and page indicator properties</li>
|
||||
* <li>Other objects: contains item properties only</li>
|
||||
* </ul>
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Item#getProperties()}, {@link Container#getProperties()} or {@link Configuration#getProperties()}.
|
||||
*
|
||||
* The list of supported properties can be found below. Behavior when setting a value for a property marked as read only is unspecified and can lead to data loss.
|
||||
* The same may appear when setting a value out of its bounds. These cases are currently not checked.
|
||||
*
|
||||
*
|
||||
* <br><br><b>Container properties:</b>
|
||||
* <table>
|
||||
* <thead><tr><td>Name</td><td>Type</td><td>Access</td><td>Admissible values</td></tr></thead>
|
||||
|
@ -57,7 +61,7 @@ import android.util.Pair;
|
|||
* <tr><td><a href="/help/app/topic.php?id=61">gridLayoutModeVerticalLineColor</a></td><td>int</td><td>Read/Write</td><td>argb color</td></tr>
|
||||
* <tr><td><a href="/help/app/topic.php?id=62">gridLayoutModeVerticalLineThickness</a></td><td>float</td><td>Read/Write</td><td>>=0</td></tr>
|
||||
* <tr><td><a href="/help/app/topic.php?id=63">gridAbove</a></td><td>boolean</td><td>Read/Write</td><td>true/false</td></tr>
|
||||
*
|
||||
*
|
||||
* <tr><td><a href="/help/app/topic.php?id=53">bgSystemWPScroll</a></td><td>boolean</td><td>Read/Write</td><td>true/false</td></tr>
|
||||
* <tr><td><a href="/help/app/topic.php?id=54">bgSystemWPWidth</a></td><td>int</td><td>Read/Write</td><td>>0</td></tr>
|
||||
* <tr><td><a href="/help/app/topic.php?id=55">bgSystemWPHeight</a></td><td>int</td><td>Read/Write</td><td>>0</td></tr>
|
||||
|
@ -120,7 +124,7 @@ import android.util.Pair;
|
|||
* <tr><td><a href="/help/app/topic.php?id=194">adActionBarTextColor</a></td><td>int</td><td>Read/Write</td><td>argb color</td></tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* <br><br><b>Item properties:</b>
|
||||
* <table>
|
||||
* <thead><tr><td>Name</td><td>Type</td><td>Access</td><td>Admissible values</td></tr></thead>
|
||||
|
@ -150,7 +154,7 @@ import android.util.Pair;
|
|||
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* <br><br><b>Shortcut properties:</b>
|
||||
* <table>
|
||||
* <thead><tr><td>Name</td><td>Type</td><td>Access</td><td>Admissible values</td></tr></thead>
|
||||
|
@ -182,7 +186,7 @@ import android.util.Pair;
|
|||
* <tr><td><a href="/help/app/topic.php?id=162">s.iconColorFilter</a></td> <td>int</td> <td>Read/Write</td> <td>argb color</td></tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* <br><br><b>Folder properties:</b>
|
||||
* <table>
|
||||
* <thead><tr><td>Name</td><td>Type</td><td>Access</td><td>Admissible values</td></tr></thead>
|
||||
|
@ -288,8 +292,10 @@ public class PropertySet {
|
|||
}
|
||||
|
||||
private Type mType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
/*package*/ public PropertySet(Lightning lightning, Object script_object) {
|
||||
mLightning = lightning;
|
||||
mScriptObject = script_object;
|
||||
|
@ -414,7 +420,7 @@ public class PropertySet {
|
|||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
case 's':
|
||||
if(page != null) {
|
||||
config = page.config.defaultShortcutConfig;
|
||||
} else if(item instanceof ShortcutConfigStylable) {
|
||||
|
|
|
@ -2,7 +2,11 @@ package net.pierrox.lightning_launcher.script.api;
|
|||
|
||||
import android.graphics.Rect;
|
||||
|
||||
/** A rectangle class. */
|
||||
/**
|
||||
* A rectangle class in the format left-top-rigth-bottom.
|
||||
*
|
||||
* An instance of this object can be created with {@link #RectL(Rect)} or {@link #RectL(int, int, int, int)}; or retrieved with {@link Item#getCell()} or {@link Container#getBoundingBox()}.
|
||||
*/
|
||||
public class RectL {
|
||||
private int l, t, r, b;
|
||||
|
||||
|
@ -12,7 +16,11 @@ public class RectL {
|
|||
this.r = r;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy constructor. Creates a copy of the RectL
|
||||
* @param r the rectL which will be copied.
|
||||
*/
|
||||
public RectL(android.graphics.Rect r) {
|
||||
this(r.left, r.top, r.right, r.bottom);
|
||||
}
|
||||
|
@ -28,7 +36,11 @@ public class RectL {
|
|||
public String toString() {
|
||||
return "["+l+","+t+","+r+","+b+"]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a java Rect with the same values.
|
||||
* @return Java Rect object with the same values.
|
||||
*/
|
||||
public Rect toRect() {
|
||||
return new Rect(l, t, r, b);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.HashMap;
|
|||
/**
|
||||
* This object is used to access script properties such as text, tag and menu attributes.
|
||||
* Warning: this API is currently experimental.
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Lightning#getCurrentScript()}, {@link Lightning#getScriptByName(String)}, {@link Lightning#getScriptByPathAndName(String, String)}, {@link Lightning#getScriptById(String)}, {@link Lightning#createScript(String, String, String, int)} or {@link Lightning#getAllScriptMatching(int)}.
|
||||
*/
|
||||
public class Script {
|
||||
public static final int FLAG_ALL = net.pierrox.lightning_launcher.script.Script.FLAG_ALL;
|
||||
|
@ -93,7 +95,7 @@ public class Script {
|
|||
* </pre></code>
|
||||
* And then use it this way:
|
||||
* <code><pre>
|
||||
* eval(LL.getScript("some_script"));
|
||||
* eval(getScriptByName("some_script").getText());
|
||||
* doSomething();
|
||||
* </pre></code>
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,9 @@ import java.io.File;
|
|||
|
||||
/**
|
||||
* A shortcut is a label and an icon, tapping on it will usually launch an app.
|
||||
* It is used for both so called 'apps' and 'shortcuts' because these two objects are really the same thing (technically)
|
||||
* It is used for both so called 'apps' and 'shortcuts' because these two objects are really the same thing (technically)
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Item} when that returned item is a Shortcut; or with {@link Container#addShortcut(String, Intent, float, float)}.
|
||||
*/
|
||||
public class Shortcut extends Item {
|
||||
|
||||
|
@ -30,7 +32,7 @@ public class Shortcut extends Item {
|
|||
}
|
||||
|
||||
/**
|
||||
* Launch the intent associated with this shortcut. This generic method does nothing when the script is run in background: in this context an app or shortcut can be launched using LL.getContext().startActivity(item.getIntent)); instead.
|
||||
* Launch the intent associated with this shortcut. This generic method does nothing when the script is run in background: in this context an app or shortcut can be launched using <code>getActiveScreen().getContext().startActivity(item.getIntent));</code> instead.
|
||||
*/
|
||||
public void launch() {
|
||||
mItemView.getParentItemLayout().getScreen().launchItem(mItemView);
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.pierrox.lightning_launcher.views.item.ItemView;
|
|||
|
||||
/**
|
||||
* The StopPoint object allows getting and setting stop points values.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Item} when that returned item is a StopPoint; or with {@link Container#addStopPoint(float, float)}.
|
||||
*/
|
||||
public class StopPoint extends Item {
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|||
|
||||
/**
|
||||
* A VariableEditor is a tool to change the value of one or more variable.
|
||||
* This object is retrieved using {@link VariableSet#edit()}. You can chain calls this way:
|
||||
* An instance of this object can be retrieved with {@link VariableSet#edit()}. You can chain calls this way:
|
||||
* <pre><code>
|
||||
* variable_set.edit()
|
||||
* .setInteger("someVariable", some_value)
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package net.pierrox.lightning_launcher.script.api;
|
||||
|
||||
import net.pierrox.lightning_launcher.engine.variable.Value;
|
||||
import net.pierrox.lightning_launcher.engine.variable.Variable;
|
||||
import net.pierrox.lightning_launcher.engine.variable.VariableManager;
|
||||
|
||||
/**
|
||||
* A VariableSet object enumerates known variables with their type and value.
|
||||
* It is also the entry point to modify variable through
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Lightning#getVariables()}.
|
||||
*/
|
||||
public class VariableSet {
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ import java.util.List;
|
|||
* These can be retrieved from the appropriate getter method.
|
||||
*
|
||||
* <p>
|
||||
* Instances can be created with the synchronous factory methods {@link #generate(android.graphics.Bitmap)} and
|
||||
* {@link #generate(android.graphics.Bitmap, int)}.
|
||||
* An instance of this object can be created with {@link #generate(android.graphics.Bitmap)} or {@link #generate(android.graphics.Bitmap, int)}.
|
||||
* <p>
|
||||
* These should be called on a background thread, ideally the one in
|
||||
* which you load your images on. Sometimes that is not possible, so asynchronous factory methods
|
||||
|
|
|
@ -15,6 +15,8 @@ import org.mozilla.javascript.Function;
|
|||
|
||||
/**
|
||||
* A screen backed with an Android Activity.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link Screen} when that returned Screen is an ActivityScreen; or with {@link Lightning#getAppDrawerScreen()} or {@link Lightning#getLockScreen()}.
|
||||
*/
|
||||
public class ActivityScreen extends Screen {
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.pierrox.lightning_launcher.views.ItemLayout;
|
|||
|
||||
/**
|
||||
* A specialized ActivityScreen used for the main home screen.
|
||||
*
|
||||
* An instance of this object can be retrieved with any function that returns an {@link ActivityScreen} when that returned ActivityScreen is a HomeScreen; or with {@link Lightning#getHomeScreen()}.
|
||||
*/
|
||||
public class HomeScreen extends ActivityScreen {
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.ArrayList;
|
|||
* <li>the lock screen (see {@link ActivityScreen})</li>
|
||||
* <li>the floating desktop</li>
|
||||
* </ul>
|
||||
*
|
||||
* An instance of this object can be retrieved with {@link Event#getScreen()}, {@link Item#getScreen()}, {@link Lightning#getActiveScreen()}, {@link Lightning#getFloatingScreen()}, {@link Lightning#getLiveWallpaperScreen()}, {@link Lightning#getBackgroundScreen()}
|
||||
*/
|
||||
public class Screen {
|
||||
private static final String EVENT_SOURCE_SCRIPT = "RUN_SCRIPT";
|
||||
|
@ -272,7 +274,7 @@ public class Screen {
|
|||
* Start an activity.
|
||||
* Example:<code><pre>
|
||||
* var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.pierrox.net/")
|
||||
* LL.startActivity(intent);</pre></code>
|
||||
* getActiveScreen().startActivity(intent);</pre></code>
|
||||
* @param intent intent to start the activity
|
||||
* @return true if launch is successful, false if activity not found or permission denied
|
||||
*/
|
||||
|
|
|
@ -1311,7 +1311,9 @@
|
|||
|
||||
|
||||
<string name="permission_label">Use Script Service</string>
|
||||
<string name="permission_description">Allows to view, create, editm delete and run scripts in Lightning Launcher.</string>
|
||||
<string name="permission_description">Allows to view, create, edit, delete and run scripts in Lightning Launcher.</string>
|
||||
|
||||
<string name="sc_disable_toast">Script disabled. Open it in the editor to enable again</string>
|
||||
|
||||
|
||||
<!-- deprecated: before 90 -->
|
||||
|
|
Loading…
Reference in a new issue