Thursday, February 28, 2013

What's New in PhoneGap Android 2.5.0

Well PhoneGap Android 2.5.0 is out! There isn't much to get excited about on Android in this release as it is mostly bug fixes. Check out the full list of commits in the CHANGELOG. Fixes include:

  • Fixing a null pointer exception when the user clicks the back button while the app is starting.
  • Enabling the application cache.
  • New configuration parameter "disallowOverscroll" to remove that blue glow when you try to scroll past the top/bottom of the screen.
  • Enabled geolocation in the InAppBrowser.

However, something I can get excited about is that in the past month we've seen 8 new committers to the Android project. Yup, 8 new coders contributed their time to cordova-android which I think is a great sign of the health of the project.

Friday, February 22, 2013

Books I've Read This Week

The Fifth Assassin by Brad Meltzer is a follow up to his The Inner Circle novel in which librarians take on the president. Well technically they are archivists from the US National Archives but it is just as exciting as you would think. Look, my Dad really likes Brad Meltzer's novels and I borrowed this from him and read it in an afternoon between hockey games on TV. Now you can either think it is a gripping mystery novel or I'm a really fast reader. It's up to you to decide.
The Lost Stars: Tarnished Knight by Jack Campbell is a bait and switch! I thought we were getting another Black Jack Geary novel but this one is set on the recently freed Syndicate start system of Midway. Even though it isn't what I was expecting it is still a pretty good novel that follows a couple of CEO's as they try to gain control of the Midway system and free it from the communist Syndicate rule.

Soon enough there will be a new Black Jack Geary novel on the way in The Lost Fleet: Beyond the Frontier: Guardian.

Hmmm...a bit negative today maybe I'll be more positive next week.

Monday, February 18, 2013

PhoneGap Android XhrFileReader

The FileReader API works great as long as the file you want to read is on the device's file system. However if you want to read a file you've packed in the Android assets folder you would need to use XHR to read the file. I'm providing an interface that follows the same API as the regular FileReader. Of course the XhrFileReader is not limited to only reading files from the assets folder, it can also read files from the file system and over HTTP.

Adding the plugin to your project 

To install the plugin, move XhrFileReader.js to your project's www folder and include a reference to it in your html files.

Using the plugin 

To instantiate a new reader use the folling code:
var reader = cordova.require("cordova/plugin/xhrfilereader"); 
Setup your event handlers:
// called once the reader begins
reader.onloadstart = function() {
    console.log("load start");
// called when the file has been completely read
reader.onloadend = function(evt) {
    console.log("File read");
Unfortunately, you will only get an error on files read over HTTP. When you specify a file:// path the request status is always 0. There is no way to tell between a successful read or an error. So if you specify a file that does not exist like "file:///does.not.exist.txt" you will get an empty in your onloadend handler.
// called if the reader encounters an error
reader.onerror = function(error) {
    console.log("Error: " + error.code);
Progress events are fired but are not very useful as they don't contain partial results.
// called while the file is being read
reader.onprogress = function(evt) {
Finally call your read method, for instance:
reader.readAsText(""); reader.readAsText("file:///android_asset/www/config.json"); reader.readAsText("file:///sdcard/error.log");
and that's about it. Obviously, this plugin is most useful when you need to read a text file from the assets folder.

Friday, February 15, 2013

Books I've Read This Week

Mind the Gap Volume 1: Intimate Strangers by Jim McCann and art by Rodin Esquejo is a book I love. When it was originally announced with Esquejo on interior art duties I was excited as I love his covers on Morning Glories and having Eisner award winning McCann providing scripting duties it seemed like it couldn't miss. It doesn't miss, it delivers in spades.

Mind the Gap is a bit hard to explain as it is structured not unlike a murder mystery but in this case the investigator is also the victim, Elle Peterssen. You see Elle is in a coma but can her spirt can still interact with the mortal plain. I know it sounds a bit crazy but it really works.

McCann has said all the information you need to solve the mystery is contained in the story which has me reading and re-reading the book. Just recently I picked up on something I'd never seen before which caused me to re-evaluate all of my theories.

Highly recommended for lovers of graphic novels.
The Signal and the Noise by Nate Silver is a really interesting book about what a lot of people find to be a boring topic, statistics (not me I'm a stats nerd). Specifically how one can make better predictions by learning to separate good information, the signal, from extraneous information, the noise. There are some really great chapters in here on weather, baseball and political predictions. I particularly enjoyed reading that we've gotten much better at weather predictions in the past 15 years. When I used to work at the Department of Meteorology a 4 day forecast was the best you could do with even a 30% accuracy. Now we've gotten out to fairly accurate 7 day forecasts. As an aside days 8 to 14 of a 2 week forecast are crap, don't plan anything around them. Plus there is a name check to the company I work for when he talks about Kasparov and Deep Blue. 

Thursday, February 14, 2013

What's New in PhoneGap Android 2.4.0

Well PhoneGap 2.4.0 has been released. So here are couple of the new things you can look forward to:

1. Support Reading Slices of Text Files.

The File object now has a slice method. Suppose the file we're reading contains the text:

"All that is gold does not glitter, not all those who wander are lost." 


  • f.slice(4, 8) would result in "that" 
  • f.slice(9) would be "is gold does not glitter, not all those who wander are lost." 
  • f.slice(-5, -1) would be "lost"

2. Added input type=file support

Now if you specify an input field of type file you will get a "Choose File" button:

Then when you click the button you will launch an intent that can handle file picking:

Now the value of your input tag will be the file you selected.

3. Additional preferences in config.xml

I completely missed this one so Joe Bowser wrote it up.

Tumblr Account

I've created a new Tumblr account where I will post links to things that I find funny and or interesting. If you enjoy comics, quirky comedies and Star Wars you'll probably enjoy it.

Tuesday, February 12, 2013

How much caffeine is too much?

A good post on how much caffeine is too much?

I felt like reposting this as I've had some conversations lately with some of the guys I play hockey with. They are slamming Monster energy drinks and 5-Hour Energy before the game and some of their kids do it as well. I'm not a doctor but I'm okay with an adult making that decision but having a kid take in that much caffeine before exercising strenuously seems like a bad idea to me.

Saturday, February 9, 2013

PhoneGap Plugin Updates to TelephoneNumber, IMEI and TTS

I've updated the TelephoneNumber, IMEI and TTS plugins to use the Apache Cordova 2.2.0 API's. That means no more deprecation notices in the Java code and the JavaScript code uses the cordova.require method. However, I'm still slapping the objects into window.plugins so you shouldn't need to change any of your JavaScript code after upgrading.

This completes the upgrade of my plugins that everyone voted on. Next up will be some new work and hopefully I'll be able to get to that WebSpeech shim I've been threatening to do.

Friday, February 8, 2013

Books I've Read This Week

The Last Hero is yet another novel in which Sir Terry Prachett delivers. I've made no secret of my love for Prachett but this book is just great. Interestingly enough it is an illustrated novel so you get to see some fantastic drawings of Prachett's characters.

In this book Cohen the Barbarian who's reached old age and doesn't want to die on his throne decides to get his Silver Horde together and go out with a bang by assaulting the home of the gods of Discworld. The journey gives Prachett a chance to make fun of the tropes of the fantasy genre in a hilarious fashion. 
The Rapture of the Nerds by Cory Doctorow and Charles Stross was a slog. I almost didn't finish reading it and that is saying something as I love both of the authors. The book is structured in three parts. One part written by Doctorow, a second written by Stross and finally the third part being co-written by both authors. It is an interesting experiment but in my opinion it just didn't work. The novel was too disjointed. This is funny considering I've read and like the short stories that the novel was originally built up from.

Friday, February 1, 2013

Books I've Read This Week

Cold Days by Jim Butcher is the 14th novel in the Dresden Files series. At some point in a long running series you'd expect the quality to drop off but it really hasn't or at least for me it hasn't. Anyone who hasn't read about Chicago's resident wizard/private detective should head back a start with Storm Front. For those of you who have been following along will love Dresden's return to the land of the living and all he has to do to keep on living is to kill an immortal.
Sweet Tooth Vol. 5: Unnatural Habitats by Jeff Lemire is the penultimate collection of the Vertigo series. In this outing we finally get to discover the cause of the plague that has devastated humanity in a flashback to 1911 illustrated by Matt Kindt. The we jump back to present day and continue on our story as Guys wants to head north to Alaska to discover his origins. Can't wait for volume 6 to be available.