Wednesday, August 29, 2012

Android Layout XML - Oh my

Despite the fact that my schedule by in large is fairly awful, I have managed to set aside at least some time each week to do a bit of research / development.  I'll avoid posting which time that is lest someone try to schedule a meeting during that block but the project this week has been to look at finally doing a bit of Android development, particularly on my recently replaced iMac and the Nexus 7.  

The process of getting everything set up was not bad, a few minor glitches here and there, but nothing too severe.  Nice to see that is the case.

Beyond getting the basic Hello World example working, my first project is to try to get a Bluetooth Serial Port Profile (SPP) listener going for the purposes of instrumenting my eBike.  The eBike or really electric motor scooter (it does 60 mph, whoot) was my sanity prize for doing our departmental accreditation efforts.  That and the family vacation to Hawaii last year.  Even then, I am not sure it was enough but lest I dwell too much on accreditation and become grumpy, I'll get back to the task at hand.

Basically, the prototype variant that I had does not have the new fancy display that the current bikes ship with but it does have a serial TTL output.  I found a fairly neat Serial TTL to Bluetooth converter at MDFly and got it rigged up late last year.  At the time, I had been using a simple Serial TTL / USB cable and a bit of C# code on my notebook.  Unfortunately, the bike reared its prototype / test pilot nature this year and has largely been out of action, not allowing me significant riding time until this past week.  Current Motor has been wonderful about troubleshooting and hopefully the wonder that was troubleshooting the bad BMS (Battery Management System) led to better troubleshooting for other riders.

Now that my bike is back, I had been occasionally using a simple Bluetooth SPP application from the Play Store.  However, that is not a whole lot of fun as it does not give me GPS or a display for my bike.  I could also just settle for the simple SparkFun adapter to log things to a microSD but again, where is the fun of not having a full display :)  

The task then this week was to actually build a real Android app together with a dash of Bluetooth.  Not too bad on the core of the Bluetooth (Google's documentation is pretty sweet) but holy lord of obfuscation, the layout code is abysmal.  Granted, I am a bit biased from working with WPF and the C# side of things but wow, it is pretty awful.  I thought WPF had some awful kludges (properties and the magic XAML compilation behind the scenes) but Android layout definitely takes the cake.  I am hoping the awful obfuscation is just a byproduct of the fact that I am using sample code but I am not terribly optimistic.  

If anyone would like to educate me why I am off base and espouse the merits of Android's layout XML over WPF / XAML, feel free to do so.    

No comments: