Happy Christmas! Version 1.61 now released

430 views
Skip to first unread message

Dave Smart

unread,
Dec 22, 2017, 1:29:16 PM12/22/17
to DroidScript

Have a happy coding Christmas 
with our all new DroidScript version

Image result for stocking

It's a feature packed stocking filler especially for you:- 


Here are the highlights:- 

- Enabled creation of live wallpapers for premium users!

- You can now use basic animated GIFs in standard DS Image controls.

- Added basic support for reading and writing to external sdcards.  You need to ask permission from the user to get access to the external cards using app.GetPermission, you can use app.CheckPermission to check if permission is already granted. See sample in the app (premium).

- When using the WiFi editor, the phone/tablet screen is now hidden to prevent editing at both ends (and loosing work).  The IP address of the connected users is also displayed and touching the address or pressing back will allow you to disconnect the Wifi IDE session.

- Added 'SaveSPK' option to device editor (saves to /DroidScript/SPKs folder).

- You can now prevent the slide-out code completion/help panel from sliding automatically (new settings option).

- You can intercept URLs in emails and launch your app.  This is enabled via build.json (use 'urlHost' and 'urlPathPrefix' fields).  This is useful for dealing with password reset or re-licensing etc. via email.

- Loads more, see list below...


It will appear on Google Play in the next few hours, or you can get it directly here:-



Note: Please be aware that we have changed the internal format of SPK files slightly, so that all the .js files now have an .txt extension.  This was done to get around security problems with emailing SPK files through Gmail. (old SPKs will still work in DS though).  you don't have to do anything as DS will handle it for you on import/export transparently.


Here is a list of the other new goodies since the last official release:-

DS 1.61
- Fixed byte swap bug on 'Audio Sample' sample.
- Enabled file rename and file copy to external sdcards.
- Added external sdcard write sample.
- Fixed "Send Intent" sample for newer Gmail version.
- Improved app.SendMail() to show fewer app choices (when no attachment used).
- Added options param to app.SendMail(), use 'SendTo' if have attachment and you know it's gmail.
- Fixed app.GetExternalFolder("external") now returns space on primary external sdcard.
- Fixed img.MeasureText(txt) now responds to img.SetPixelMode().

DS 160b1
- Added app.GetRSSI() to get wifi strength.
- Added support for external sdcard MakeFolder.
- Fixed bugs with GlView and V8 not working in last release.

DS 159b1
- Added new 'Button' option to image controls (causes image to depress like a button when touched)
- Added new app.DisableTouch() to disable/enable all touch events on controls in main activity.
- Added new net.WakeOnLan(ip,mac) for premium users.
- Added support for controlling media players with app.BroadcastIntent() method (see forum).
- Added 'TouchModal' option to YesNoDialog.
- Changed ShowProgress and YesNoDialog to 'TouchModal' by default (use 'NoTouchModal' to revert)
- Added options param to Custom dialog SetTitle() method, use 'Left', 'Center' or 'Right' for text alignment.
- Added new 'Auto-Help' settings option to prevent/enable slide out help panel.
- Added new img.MeasureText(txt) method to get width and height of text when drawn.
- Changed device editor to show IP address of connected user when using WiFi IDE.
- Added SAF support for text files: write,read,delete, app.CheckPermission, app.GetPermission.
- Fixed app.GetExternalFolder() now returns primary external sdcard path.
- File paths starting with '/extsdcard' now map to the primary external sdcard.
- Your IP address is now visible in the about dialog.

DS 159a2
- Added support for Khadas Vim device (including gpio access).
- WebServer object supports new SetOnUpload(callback) method (filename + ip address passed to cb)
- Fixed WebServer bug which required use of at least one Servlet to get file uploads working.

DS 159a1
- Added 'json' mode to app.HttpRequest method.

DS 158a1
- Enabled creation of live wallpapers for premium users!
- Changed .js files inside SPK files to .js.txt to side step Google security issues.
- Added 'SaveSPK' option to device editor (saves to /DroidScript/SPKs folder).
- Added app.SetDensity to scale density of all controls in app (call before creating controls).
- Added basic animated GIF support to Image controls.
- Added URL intent interception via build.json (use 'urlHost' and 'urlPathPrefix' fields).
- Added 'UseBrowser' option to Webview to cause links to launch in the default browser.
- Fixed issue with fontawesome text in app.CreateList() and sumultainious use of fontawesome icons.
- Fixed canvas.Save() not getting Storage permissions for APK build. 


Live wallpaper Example
===================

Create an app called "Live Wallpaper.js" and add the following code:-


//Called when application is started.
function OnStart()
{
    
//Allow user to install our wallpaper.
    app
.InstallWallpaper( "this", "this" );
    app
.Exit();
}


Create another script file in the app called "Wallpaper.js" containing this code:-

var count=0;
var x=0.2,y=0.2;
var memFree = 0;


function OnStart()
{
    
//Show a message.
    app
.ShowPopup( "Hello from wallpaper!" )
    
    
//Create wallpaper object.
    wall 
= app.CreateWallpaper();
    
    
//Create a full screen image with the wallpaper option.
    
var sw = app.GetScreenWidth( "real" )
    
var sh = app.GetScreenHeight( "real" );
    img 
= app.CreateImage( null, sw,sh, "px,wallpaper" );
    
    imgBack 
= app.CreateImage("/Sys/Img/StarField.jpg");
    
    
//Draw our picture 30x every second.
 setInterval
( DrawPicture, 1000/30 );
 
 
//Turn off debugging to improve performance.
 app
.SetDebugEnabled( false );
}
  
function DrawPicture()
{
    
//Do nothing if wallpaper is not visible.
    
if( !wall.IsVisible() ) return;
    
    
//Draw image to background. 
 img
.DrawImage( imgBack, 0,0,1,1);
 
 
//Get available memory every 10th frame.
 
if( ++count%10==0 ) memFree = app.GetMemoryInfo().avail;
 
 
//Draw text showing free memory.
 img
.SetTextSize( 12 );
 img
.SetPaintColor( "white" );
 img
.DrawText( "Mem free:" + Math.round(memFree/(1024*1024))+"M", 0, 0.05 );
 
 
//Draw circle with radius 0.2 of image width.
 img
.SetPaintStyle( "Fill" );
 img
.SetPaintColor( "#66ffffff"  );
 img
.DrawCircle( x, y, 0.2 );
 
 
//Draw circle with radius 0.1 of image going
 
//at a different speed.
 img
.SetPaintStyle( "Fill" );
 img
.SetPaintColor( "#66ffffff"  );
 img
.DrawCircle( x*x, y*y*y, 0.1 );
 
 
//Move circles around.
 x 
+= 0.005;  y += 0.002;
 
if( x > 1.2 ) x = -0.2;
 
if( y > 1.2 ) y = -0.2;


 
//Update the wallpaper.
 img
.Update();
}



You can also use animated GIF files for your wallpaper.  Here is an example of the Wallpaper.js file for an animate GIF:-

var count=0;


function OnStart()
{
    
//Show a message.
    app
.ShowPopup( "Hello from wallpaper!" )
    
    
//Create wallpaper object.
    wall 
= app.CreateWallpaper();
    
    
//Create a full screen image with the wallpaper option.
    
var sw = app.GetScreenWidth( "real" )
    
var sh = app.GetScreenHeight( "real" );
    img 
= app.CreateImage( "Img/wallpaper.gif", sw,sh, "px,wallpaper" );
    
    
//Draw our picture every second.
    app
.SetDebugEnabled( false );
    setInterval
( DrawGif, 1000/20 );
}
  
//Draw GIF to the wallpaper.
function DrawGif()
{
    
if( !wall.IsVisible() ) return;
    

    img
.DrawFrame();
    img
.Update(); 
}



Notes:

When you run the app it will show you a preview of the wallpaper using Androids settings page.  It's probably best not to actually set the wallpaper to your home screen until you have it debugged and working properly as things can get confusing because you will get multiple instances running (preview and home-screen).  

If you are using the WiFi editor (recommended) , then pressing stop on the WiFi editor will kill all instances of the wallpaper service.  Some phones will show a black window on the home-screen until you swap to another wallpaper, but some phones will try to re-start it automatically (eg. Samsungs).  This can actually be quite useful for working on the actual live home-screen wallpaper (with DS left running in the background).  You don't need to preview, just edit the code and press the stop button.


Support for Khadas Vim1 (Tiny and powerful Android TV / Project box) has been added too:-


Basic GPIO example for Khadas Vim
=================================


//Called when application is started.
function OnStart()
{
 
//Create a layout with objects vertically centered.
 lay
= app.CreateLayout( "linear", "VCenter,FillXY" );


 
//Create a text label and add it to layout.
 txt
= app.CreateText( "Hello" );
 txt
.SetTextSize( 32 );
 lay
.AddChild( txt );


 
//Create a toggle button.
    tgl
= app.CreateToggle( "Toggle Button", 0.4 );
    tgl
.SetMargins( 0, 0.02, 0, 0 );
    tgl
.SetOnTouch( tgl_OnTouch );
    lay
.AddChild( tgl );
 
 
//Add layout to app.
 app
.AddLayout( lay );
 
 sys
= app.CreateSysProc("su");
    sys
.Out( "echo " + 176 + " > /sys/class/gpio/export\n" );
    sys
.Out( "echo out > /sys/class/gpio/gpio" + 176 + "/direction\n" );
}




//Called when user touches our toggle button.
function tgl_OnTouch( isChecked )  
{
 
if( isChecked )
 sys
.Out( "echo 1 > /sys/class/gpio/gpio" + 176 + "/value\n" );
 
else
 sys
.Out( "echo 0 > /sys/class/gpio/gpio" + 176 + "/value\n" );
}


A new high performance game engine is coming soon too (sneak peak available in the beta group ;)

Have a great Christmas

Regards
David






Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages