Saturday, March 30, 2013

Books I've Read This Week

It's been awhile since I've done one of these. I've been away on vacation and didn't get as much reading done as I would have hoped but I'm back on track now.
Salt: A World History by Mark Kurlansky is an interesting little book about an everyday item, table salt. Honestly I didn't realize that salt was such a sought after commodity in history as it seems so plentiful now. It's interesting to see how some wars were won/lost just by the control of salt and it kinda makes sense how much food production was tied to salt before refrigeration units were invented. A pretty good read and you get to learn where terms "worth his salt" and "salary" come from.
Jack Kirby's Fourth World Omnibus Vol. 1 by Jack "The King" Kirby is a collection of stories I've been wanting to look into for awhile. It collects in chronological order the books he was cranking out at the time so you get Superman's Pal Jimmy Olsen, The Forever People, New Gods and Mister Miracle. While Kirby was an absolute master of draftmanship not all of these stories are gems. I really enjoyed the New Gods and Mister Miracle issues, kinda liked the Forever People but found the Jimmy Olsen issues to be darn tedious to read. I'm going to give the second volume a try as I can check it out from my library before I decide to buy anymore collections.

Monday, March 4, 2013

PhoneGap Bluetooth Plugin Updated

So the Bluetooth plugin was horribly out of date so I took some time to update it to work with PhoneGap 2.2.0 and higher. As well as the usual updates to the JS and Java code I fixed an instance in the "listDevices" call which would block code execution for 10 seconds while it scanned for devices.

Anyway, if you need Bluetooth functionality the plugin provides the following method:

  • listDevices
  • isBTEnabled
  • enableBT
  • disableBT
  • pairBT
  • unPairBT
  • listBoundDevices
  • stopDiscovering
  • isBound
Enjoy!

Update: Oh by the Hoary Hosts of Hogarth! I should mention that I didn't originate this plugin, I just saw the need for it to be updated. All credit should go the original authors: Daniel Tizón, Idoia Olalde and Iñigo González

Friday, March 1, 2013

Books I've Read This Week

The Blinding Knife and The Black Prism by Brent Weeks are the first two books in his new trilogy. I previously enjoyed his Night Angel trilogy so I figured I'd start in on this new series of books. While I have not enjoyed it as much as as the Night Angel trilogy is it still a pretty good series.

The system of magic that is used is based off of the colours of the rainbow. Each colour is also linked to an emotion so someone "drafting" (using) red magic will feel rage or anger and someone drafting blue magic will feel calm and detached. It is a pretty neat concept that may remind some folks of the time they've spent playing Magic the Gathering. Which is by design as the game shows up in the books as something called 5 Kings. No, I'm not making this up. Brent Weeks admits to this in the afterword of the second book.

Anyway, the story itself centers around Gavin Guile who is the top magic user or Prism of the main religious organization in this world. His role is not unlike the Pope of the Catholic church and that is not the only analogy to be drawn between their system of religion and the Catholic church. Anyway, the world is in a bit of dis-array and people are turning away from the church.

Now Gavin has to try and hold off full scale war who's roots were seeded 16 years ago when he and is brother fought in "The False Prism's War" to see who would be the true Prism. Well not really, the war was actually started by the brothers fighting over a woman. Typically right?

Anyway, good characterization going on in these books and some interesting commentary on our contemporary society going on under the scenes. I thought for awhile there Weeks was going to do something really different with the main character then he backed away from it. Regardless, I'll be picking up the third book in the series when it comes out.

As an aside if anyone wants the three books of the Night Angel trilogy get in touch with me and I'll ship them to you as long as it is not prohibitively expensive. 

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");
    console.log(evt.target.result);
}; 
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 evt.target.result 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) {
    console.log("progress");
}; 
Finally call your read method, for instance:
reader.readAsText("http://www.google.com"); 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.