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: