Sunday 28 December 2014

Introducing myself (at last)

I've been ignoring this blog for a while as I've concentrated on the discussion groups, some beta testing and the wiki.

However, it occurs to me that there is some significant misunderstanding among some members of the discussion group about who I am and more importantly, who I am not.

  • I am not a member of the team that develops DroidScript
  • I am not a person with any influence over how DroidScript will be developed in the future
  • I am not an experienced user of JavaScript
  • I am not a DroidScript consultant (paid or otherwise)
The above facts may come as a disappointment to several people who send me private emails on a frequent basis.

Monday 1 September 2014

HTTP POST and the Web IDE

I've been playing with http post whilst travelling around a bit. Just getting the feel so I can use it in a project I have coming up.

It occurred to me that there was a way I could be even more lazy than currently.

So I set about writing a little app that will enable me to bookmark the server for the Web IDE, even though the ip address changes occasionally.

I just open the app, hit Ok, wait a couple of second for the button to rename itself to Exit, then hit it again.

The bookmark on my PC then opens a page with a link to the server on my tablet.

Give it a day or two and I'll probably cut out the link and go for a redirect instead. The only problem with that is it makes the initial bookmarking a bit tricky.

The code I use is reproduced below. It points to a different url than I use, so you are welcome to try it.

In the highly unlikely event that 2 people try to use it at the same time, you may not get the right link.

Wednesday 20 August 2014

Getting user input

I frequently need to ask for user input when it is not convenient to have a TextEdit on the screen permanently.

Of course it's possible to organize this on a case by case basis but it is frequently needed at the early stages of code testing, so I could do with a nice simple way to put a quick and dirty solution up, even if I later replace it later with more considered design.

What I've ended up doing is creating a reasonable facsimile of a dialog, which can be called by placing a file ask.js into the Misc folder beside the main code.

I then load that using:
  app.LoadScript("Misc/ask.js");



The question is asked using the format:
  ask("Enter your first name","Steve")
Where the second parameter is an optional default value.
If the default is to be cleared between uses of the dialog, I set it to ""

The answer is return in something similar to an OnTouch handler
function askAnswer( ans ){
  alert( ans )
}
I have a simple demo spk called mydialog
The file Misc/ask.js looks like this:

Thursday 14 August 2014

Simple clock app

I had need of a simple clock app to show the time and speak it to me every 5 minutes.

It took very little time to pull that together but getting it to be configurable by other people on various different devices was a nightmare.

The answers I came up with in the end were much simpler than anything else I tried.

If anyone wants to take a look at it, there is an spk at http://hudl.sgarman.net/public/spk/SJGclock001.spk

The code looks like

Thursday 7 August 2014

Make a copy of a project

One facility I can't find in AndroidScript is the ability to create a working copy (under another name) of an androidscript app.

As I have a need for freezing versions of a tiny app (my file explorer) I wrote an AndroidScript app to do this for me.

It currently has the specific app detail hard-coded but it would be really simple to extend it to work with any app that is made up of only text files.

An spk of the app is at http://hudl.sgarman.net/public/spk/version.spk

The code looks like:

Tuesday 5 August 2014

File explorer v002

I did a bit more work on the file explorer.
You might think I made it worse.

The new layout makes it easier to tell which files are folders.

The new spk is at http://hudl.sgarman.net/public/spk/SJGexplorer_002.spk

The code looks like this:

Coding a file explorer.

I've started work on the beginnings of a file explorer.

There's nothing much to it at the moment but I thought I'd share it in case it's some help to somebody.

I hope that one day it may become the basis of a tutorial but obviously there's quite a way to go.

So far, I've only tested it on a Tesco hudl tablet but I'm reasonably happy with it so far.

The spk with the minimal code I have at the moment is available at http://hudl.sgarman.net/public/spk/SJGexplorer_001.spk

In text form, it looks like this

Saturday 2 August 2014

Tool for a bit of introspection

On google groups, Andreas Rozek posted a useful tool,, AppInspector for looking at the functions of androidscript's app object.

I used this a fair bit, so I stole the main bit of the code and expanded the app a bit so that I can look at various control types.
For anyone who wants to play with it, there's an spk at http://hudl.sgarman.net/public/spk/SJGinspect.spk

The code is a bit ropey as it was intended only for home use. It looks like this:

Saturday 19 July 2014

Starting out with Androidscript

It's great to have access to android devices like my phone and tablet but I always feel a bit naked if I have a device that I can't program in some fashion.

My Tesco hudl tablet is not rooted because I like it to run some apps that do not work on rooted devices.

What I need is a useful scripting/profiling app that will allow me to grow with it later.
So I came across Androidscript which fits the bill nicely.