native Android or PhoneGap or PyQt for wall tablet software?

In the house we now have a bunch of android tablets fixed into the walls where most of the light switches would have been.  To get things working I initially wrote a “simple” Android application to turn on and off the lights via the Vera 3 box that manages the Z-Wave network they are all attached to. Having said this I don’t think the phrase “simple” can really be applied to any Android App as even such a simple application as this wasn’t easy to write from scratch. I had to learn about application lifecycles and fragment lifecycles and all sorts of delphic (I chose this term because I’m sitting in Corfu writing this) stuff.  And even after I’d finished it I realised it was a pretty poor effort – even though it supports both vertical and horizontal orientations it crashes when you change screen orientation on my Samsung phone (fortunately you can’t rotate the tablets as they’re fixed into the walls).  What is clear though is that I do want an application that can be run on a phone (and possibly a PC) as well as on the tablets.

Perhaps unsurprisingly I’ve been putting off improving the app for the wall tablets as I didn’t really fancy reminding myself of all the Android nonsense. But having got the window shades working with their own MBED web server I felt I really needed to support them on the wall tablets and found myself thinking about writing an updated app.

how about Qt on Android?

I’ve been playing around with Qt a bit recently and enjoying the close integration with Python using PyQt so I figured it would be nice to see if Qt might be the right cross-platform tool to use. I delved a little into the murky world of QtQuick and QML (which is Qt’s alternative markup to HTML5). But the more I got into it the more I realised I’d be working in C++ (which I’m pleased to avoid where possible) and Javascript (which I really don’t like much either). And the baggage of the Qt runtime plus  the non-standardisation of QML really pushed me to think again.  So I landed back looking at other cross-platform approaches and thinking about Cordova/PhoneGap which I’d tinkered with a few years ago but left aside.

getting started with PhoneGap

PhoneGap’s development approach is a little unusual these days in that it is all command-line based. Essentially, once you’ve set it up, you create a new project using the command “create” and you build using the command “build” – pretty logical I guess.

The trickiest part of getting PhoneGap set up was getting the Android environment to work with the PhoneGap command line. This required a lot of jiggling to get the environment variables JAVA_PATH, ANT_PATH and PATH set so that all the required tools can be found during build. I haven’t tried PhoneGap Build as yet simply because it just adds another step and I’m only targeting one platform right now.

The application is just HTML/CSS/Javascript and that got me thinking about how much I hate Javascript.  I’d also love to be able to program an application without having to create lots of different versions of CSS to cope with the different platforms it might run on.  This got me to thinking about languages that might be translatable to Javascript – I’d heard about CoffeeScript from Chris Greening (@MrBananas) and Nick Ager @nickager but never taken the plunge – until now!

So I’ve been working quite happily on an application using PhoneGap, CoffeeScript and LESS and really quite enjoying it.  I’ve ended up building the entire DOM contents dynamically and the structure of the software is pretty much as I would want it to be if it were developed with Python and a good UI framework.

It really is quite surprising how much like Python my CoffeeScript code is looking and I’m really happy with it. I’m close to finishing so plan to blog about it separately … so stay tuned.

robnative Android or PhoneGap or PyQt for wall tablet software?

Leave a Reply

Your email address will not be published. Required fields are marked *