**This is an old revision of the document!** ----
==== External API: Manage Scripts ==== [[https://drive.google.com/folderview?id=0B40xU-30MxN7flhicHg3Y05XMWplMTl3c1RJU0ZuWUZ3emJxZG56RDdma2xpMXVvRmRlaXc&usp=sharing|Download]] the current Version of the Library and drop the .aar file in your projects lib folder (/app/libs) if the folder does not exist, create it. Add this to build.gradle of your apps module: <sxh java;>repositories{ flatDir { dirs 'libs' } } dependencies { compile(name:'name-of-file',ext:'aar') //other dependencies... }</sxh> and replace //name-of-file// with the actual file name (without the extension). Now you can import the class ''com.app.lukas.script.ScriptManager'' in any of your modules files. The ''ScriptManager'' provides several static methods: Method signatures: (v1.3.1) <sxh java;>loadScript(Context context, String code / int codeResourceId, String name, int flags, final Listener listener)</sxh> * ''context'' can be any context * ''code'' the code the script should have / ''codeResourceId'' the raw resource id containing the script code * ''name'' name for the new script. Be sure to use as unique names for scripts as possible, because if a script with the same name already exists, it may be overwritten. It may be a good idea to start your script name with your projects name (e.g. "layoutmanager_save"). * ''flags'' sum of flags for the script * 2: App menu * 4: Item menu * 8: Custom Menu * ''forceUpdate'' (optional, default is true) Whether to directly overwrite a script with the same name or not. **If this is set to false, you have to implement the confirmUpdate method in your listener.** * ''listener'' a ''ScriptManager.listener'' which will retrieve the ID once the script is loaded <sxh java;>runScript(Context context, int id, String data) </sxh> * ''context'' can be any context * ''id'' the id of the script which should be run, usually as returned by a ''ScriptManager.listener'' * ''data'' an optional string containing additional data. Can be retrieved in the script with ''LL.getEvent().getData()'' <sxh java;>enableDebug()</sxh> * Call this method to see extensive Log output from the library <sxh java;>askForRepositoryImporterInstallationIfMissing(boolean value)</sxh> * By Default the library shows a dialog when the Repository Importer is missing. With this method you can disable/enable that at will. Listener methods: <sxh java;>OnLoadFinished(int id);</sxh> * This method is called when the load succeeded with the ID of the imported script <sxh java;>OnError()</sxh> * Implement this method if you want to receive a callback when an error occurs (recommended). Do not call super.onError(). <sxh java;>confirmUpdate(UpdateCallback callback)</sxh> * Implement this method if you've set the forceUpdate flag to false. You can e.g. show a Dialog here asking the user what to do. You have to call callback.callback with a result (boolean) afterwards. **//Hint: This requires the Repository Importer to be installed on the android device.//**