📜 ⬆️ ⬇️

DroidScript - a simple and functional tool for developing mobile applications for Android


Some time ago I was given the following task: to develop a prototype of an Android application for wireless communication with the Arduino in real time. To dive with this head in Java, Qt or C # was impractical, so I decided to look for a ready-made solution on the script engine. Phonegap? Interesting, but not to work with Bluetooth. Something from mobile development environments? Perhaps, but I wanted to work in a familiar desktop environment, and not on a tablet with a small screen. Soon, the desired was found - a mobile DroidScript development environment with the ability to connect to it from a browser-based WiFi IDE, which can be installed on Windows, Mac and Linux.

What is DroidScript?


DroidScript is an Android application that includes a development and execution environment for program code on an Android device. It allows you to create two types of applications - JavaScript (with the native interface) and HTML (hybrid).

For creating native UI and accessing Android software and hardware resources, JavaScript is used in conjunction with the DroidScript API, which allows you to work with WebView, SQLite, email, SMS, WebGL, sensors, Web servers, sockets, sprite animation, and many others, as well as interact with external devices via Bluetooth, WiFi, USB and LAN.

Impressive out-of-box functionality is one of the features of DroidScript. Another feature is its ease of use. What is it? First of all, in coding. Below is a simple application code example:
')
//   function OnStart() { //        var lay = app.CreateLayout( "linear", "FillXY" ); //     30%   10%    var btn = app.CreateButton( "", 0.3, 0.1 ); //      btn.SetTextSize( 18 ); //      btn.SetOnTouch( function(){ app.ShowPopup( ", !" ); //   app.Vibrate( "0,100,30,100,50,300" ); //  }); //    lay.AddChild( btn ); //          app.AddLayout( lay ); } 

Everything is encoded in JavaScript and DroidScript API without using xml markup, connecting libraries, creating classes, etc.

There are no visual interface design tools in DroidScript, like in Android Studio, AIDE or MIT App Inventor, but you can implement LivePreview on Android for even faster development of interactive prototypes, as well as extend functionality using plug-ins written in JavaScript or Java.

The simplicity of working with DroidScript is not only coding. It was originally designed to give novice Android developers a quick and easy immersion into this process.

Installation and Setup


If you do not have a phone or tablet with the Android operating system at hand, you can use its emulator, for example, BlueStacks or Nox APP Player .

Install DroidScript from Google Play and open it. An interface with the only Hello World application area appears on the screen.


A short touch of the application icon will launch it. To edit the code, you need to perform a long touch of the icon and select the Edit option in the list of actions that appears.

The control panel includes buttons for accessing documentation, connecting to a WiFi IDE, general commands and examples.

Setting up a remote development environment for WiFi IDE is as follows:

  1. Launch DroidScript and go to settings on the command ... / Settings to change the access password or reset it.
  2. In the control panel, press the up arrow button. A dialog appears with the address of the DroidScript.
  3. On a desktop or laptop, open the browser and enter the address obtained in the previous paragraph. A password prompt dialog appears if it has not been reset. Enter the password, and after successful access, the interface of the development environment appears on the screen.


The left side of the window contains tabs with the application area, editor, resource files, and the right side contains tabs with news, help, examples, and a debugger.

WiFi IDE has the ability to expand its functionality by adding tabs. The “Espruino” tab is an example of this extension.

In the simplest case, the application may consist of a single file with the extension js, in which the code is stored in its original form. To exchange the project in the source code, you can pack it into an spk-archive. It is also possible to build a project into an apk-file, but for this you need to buy and install the ApkBuilder plugin.

When you first see such simple DroidScript and WiFi IDE interfaces, after working in a desktop or web environment, a logical question arises, is it possible to do something serious with this? Of course! As you know, with simple tools you can create impressive things!

Documentation


Source: https://habr.com/ru/post/326460/


All Articles