User Tools

Site Tools


plugins:apk_builder

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
plugins:apk_builder [2015/08/20 20:16]
119.30.38.227 [The APKBuilder plugin]
plugins:apk_builder [2017/01/16 14:18] (current)
Line 1: Line 1:
- +======The APKBuilder plugin======
- +
-//Init variables.  +
-var sum "";  +
- +
-//Called when application is started.  +
-function OnStart()  +
-{  +
-    //Create a layout with objects vertically centered.  +
-    layMain app.CreateLayout( "linear", "FillXY" );      +
- +
-    //Create array to hold number buttons.  +
-    keys [ 7,8,9,"/", 4,5,6,"*", 1,2,3,"-", 0,".","C","+" ];  +
-      +
-    //Create text control for displaying sum.  +
-    txtSum app.CreateText( "", 0.8, 0.1 );  +
-    txtSum.SetTextSize( 42 );  +
-    txtSum.SetBackColor( "#ff222222" );  +
-    txtSum.SetMargins( 0, 0.1, 0, 0.05 );  +
-    layMain.AddChild( txtSum );  +
-      +
-    //Create first row of buttons.  +
-    lay1st app.CreateLayout( "linear", "Horizontal" );      +
-    for( i=0; i<4; i++ ) AddButton( lay1st, keys[i] );  +
-    layMain.AddChild( lay1st );  +
-      +
-    //Create second row of buttons.  +
-    lay2nd app.CreateLayout( "linear", "Horizontal" );      +
-    for( i=4; i<8; i++ ) AddButton( lay2nd, keys[i] );  +
-    layMain.AddChild( lay2nd );  +
-      +
-    //Create third row of buttons.  +
-    lay3rd app.CreateLayout( "linear", "Horizontal" );      +
-    for( i=8; i<12; i++ ) AddButton( lay3rd, keys[i] );  +
-    layMain.AddChild( lay3rd );  +
-      +
-    //Create fourth row of buttons.  +
-    lay4th app.CreateLayout( "linear", "Horizontal" );      +
-    for( i=12; i<16; i++ ) AddButton( lay4th, keys[i] );  +
-    layMain.AddChild( lay4th );  +
-      +
-    //Create fifth row of buttons.  +
-    lay5th = app.CreateLayout( "linear", "Horizontal" );      +
-    AddButton( lay5th, "=" );  +
-    layMain.AddChild( lay5th );  +
- +
-    //Add layout to app.      +
-    app.AddLayout( layMain );  +
-}  +
- +
-//Add a button to a given layout.  +
-function AddButton( lay, name )  +
-{  +
-    if( name=="=" ) w = 0.8; else w=0.2;  +
-    btn = app.CreateButton( name, w, 0.1, "Alum" );  +
-    btn.SetOnTouch( btns_OnTouch );  +
-    lay.AddChild( btn );  +
-}  +
- +
-//Called when user presses number buttons.  +
-function btns_OnTouch()  +
-{  +
-    app.Vibrate( "0,100" );  +
-      +
-    //Get button text.  +
-    btn = app.GetLastButton();  +
-    var txt = btn.GetText();  +
-      +
-    //Handle equals button.  +
-    if( txt=="=" ) CalcResult();  +
-      +
-    //Handle clear button.  +
-    else if( txt=="C" ) sum = "";  +
-      +
-    //Handle other buttons.  +
-    else sum += txt;  +
-      +
-    //Update display.  +
-    txtSum.SetText( sum );  +
-}  +
- +
-//Calculate sum.  +
-function CalcResult()  +
-{  +
-    try {  +
-        //Evaluate sum (and catch errors).  +
-        sum = eval( sum ).toFixed(2);  +
-    }  +
-    catch(e) { sum = "Error" }  +
-+
  
 =====Introduction===== =====Introduction=====
Line 101: Line 12:
  
 It is important to use relative file paths in your JavaScript source code to load images, sounds and external scripts etc, because these files are copied into the APK file as internal assets. Remember the "/sdcard/DroidScript" folder will probably not exist on someone else's mobile device. It is important to use relative file paths in your JavaScript source code to load images, sounds and external scripts etc, because these files are copied into the APK file as internal assets. Remember the "/sdcard/DroidScript" folder will probably not exist on someone else's mobile device.
 +
 +e.g. image is stored in "/sdcard/DroidScript/yourapp/Img/xxx.jpg", you should name the path as "Img/xxx.jpg" instead. Otherwise, while you generate the APK, it will not be included as Android Assets.
  
 =====How can you get this plugin?===== =====How can you get this plugin?=====
  
-The ApkBuilder plugin is **not** free. You have to pay a little money for it. But if you bought it, you can build so much apk files as you want! After each new installation of DroidScript you should **reinstall** (no new buying) the plugin.  +The ApkBuilder plugin is **not** free. You have to pay a little money for it. But if you bought it, you can build as many apk files as you want! The plugin works entirely offline. But after each new installation of DroidScript you should **reinstall** (no new buying) the plugin to bring it up to date with the new version
-You can download it over the Plugin-Section within DroidScript.+You can download or **reinstall** it over the Plugin-Section within DroidScript.
  
 =====First Start===== =====First Start=====
  
-After the first start of the plugin you must create a **user.keystone** file. You need a password for it. You find this file in your apk folder. Every time you want create a apk file DroidScript ask you for that password in that file. **Save this file on a other save place too!**\\+After the first start of the plugin you must create a **user.keystore** file. You need a password for it. You find this file in your apk folder. Every time you want create a apk file DroidScript ask you for that password in that file. **Save this file on a other save place too!**\\
  
 ===Here is a warning from Dave, developer of DroidScript:=== ===Here is a warning from Dave, developer of DroidScript:===
plugins/apk_builder.1440101796.txt.gz · Last modified: 2015/08/21 04:16 (external edit)