Wednesday, October 31, 2012

What's New in PhoneGap Android 2.2.0

Well we've tagged Apache Cordova 2.2.0 release candidate 2 which means that Cordova 2.2.0 will be out soon in source release form which will be followed quickly by the binary PhoneGap 2.2.0 release. Shaz wrote up a post on what's new in iOS so I was asked (shamed) to do this on for Android. So without further ado here's what you should expect on Android:

1. FileTransfer API changes

  • Added support for the onprogress event to get progress events for a FileTransfer operation
  • Added the abort function to cancel a FileTransfer operation

See the API doc.

2. Graduated the Globalization plugin to core

This plugin was previously in the phonegap-plugins repo (BB WebWorks 5, iOS, Android). The globalization object obtains information and performs operations specific to the user’s locale and timezone.

See the API doc.

3. Splashscreen API

The Splashscreen API is now formally documented for iOS and Android.

4. Android JavaScript to Java bridge improvements
  • The callback server is gone.
  • Uses events to specify when a result it ready.
  • Up to 25 times faster.
Read issue CB-638 for more information.

5. Partial support for video tag

We've been able to shim in support for the video tag. See my earlier blog post for more details.

6. Hardware acceleration is enabled by default

When you run bin/create to make a new PhoneGap Android project then android:hardwareAccelerated is set to true by default on the main activity.

See Android docs for an explanation of hardware acceleration.

7. useBrowserHistory now defaults to true

We've deprecated the current way that history is handled in Android apps in favour of the default way it is handled in the web view. To go back a page you should be using history.back(). Because of this change iframe's now work properly.

If you need to enable the old way to handle history you can set useBrowserHistory to false in config.xml.

8. Introduce CordovaPlugin class

CordovaPlugin will be replacing the Plugin class for extending PhoneGap functionality. It adds a new execute method public boolean execute(String action, String rawArgs, CallbackContext callbackContext) to enable developers passing large amounts of data to the native side provide their own JSON parser. It also cuts down on boiler-plate, makes multi-threading easier, and adds an application-wide thread-pool to CordovaInterface. Adds an onReset method that is called when top level navigation changes. This is where you should stop any long running processes like a file transfer that are no longer needed on the new page.

9. Various bug fixes
  • Back and Menu button events now fire if the cursor is inside a text view.
  • Fixed a path where the whitelist was not being checked in DroidGap.
  • FileTransfer.download now supports the trustAllHosts option to allow downloading from servers with self signed certificates.
  • Removed trailing space from contact.name.formatted.
  • Properly set contact's IM type.
  • navigator.language is now set properly when the language is switched in Android settings.

Saturday, October 27, 2012

Books I've Read This Week

Mobile First by Luke Wroblewski is a manifesto for properly designing web pages. With the advent of mobile devices we need to start thinking of smaller screens first and build our way up to larger screens. He makes a number of really good points as to why you should go mobile first and he backs it up with plenty of data. Although this isn't really a book about responsive design, for that you should check out Responsive Web Design by Ethan Marcotte for a great book on the topic. 
Disarming the Narcissist by Wendy T. Behary is exactly the type of book I needed to read. I firmly believe that the world, nay the cosmos revolves around me. You see, I am a narcissist. Now the question is does that level of self awareness make me more of an ass or less of an ass? Probably more.

So this book was very, very interesting to me. A number of things I read helped me understand better how people relate and react to my behaviour. I can honestly say the book was eye opening. I hope that I can put to use what I've learned in this book to better relate to my family and friends.

Also, if you've met me and come away with the impression that I'm a jerk. Sorry. I know ignorance is not a defence but I hope to leave you with a better impression on a second meeting.

Monday, October 22, 2012

Partial Support for the Video Tag in PhoneGap Android 2.2.0

Well if you've followed the saga of getting the video tag to work properly in the WebView on Android then you've read my post about why I created the VideoPlayer plugin and it's enhancement. Well in the upcoming PhoneGap 2.2.0 we will have better, but not perfect, support for the video tag thanks to work by Steren Giannini.

In Android 4.x you only need to set the hardwareAccelerated attribute to true in order to get true in-line video tag support on Android.

Unfortunately, in earlier versions of Android this doesn't fix the problem. So instead code has been added to the core of PhoneGap to detect the video tag and handle it better. Sadly, we are unable to play the video in-line but when a users taps on a video tag a full screen video player will be launched. In order to get back to the main app the user need only hit the back button to return to main app screen.

There are a few caveats though. The video tag will only support a single source so it will need to look something like this:
<video poster="http://path.to.my/poster.png" controls>
<source src="http://path.to.my/video.mp4">
</source> />
</video>
Additionally the source url can refer to a video on the internet using the http:// protocol or a local file using the file:// protocol. At this time videos in the assets directory are not support so something like file:///android_asset/www/video.mp4 will not work.

So again, it's not perfect but it is better than nothing. If you are getting tripped up with one of the caveats I described above the VideoPlayer plugin still works.

Friday, October 19, 2012

Books I've Read This Week

Amped by Daniel H. Wilson is an interesting novel and the second one I've read from Mr. Wilson. In a near future America, we see a growing amount of discontent between the pure humans and amplified humans or amps. In Wilson's world technology has progressed to such a degree that people are grafted with computers that solve common medical problems like bad eyesight or epileptic seizures. A political party emerges to basically discriminate against the Amped humans. There certainly is a parallel between what is going on in the novel and the discrimination against South African runner Oscar Pistorius.

The novel is full of very interesting ideas and I recommend it as a good thought provoking read.
Tapworthy: Designing Great iPhone Apps by Josh Clark may be focused on developing iPhone applications but there is a lot of great cross over advice for mobile developers. It really helps developers understand the design of good touch interfaces, how to give your app a personality, common touch gestures and the importance of a good icon.

Thursday, October 18, 2012

Ottawa-Carleton Wildlife Centre Video

My amazing wife, Kate, has put together a three minute video highlighting the Ottawa-Carleton Wildlife Centre where she's worked for the past 15 years. The OCWC is giving thanks to the Community Foundation of Ottawa on their 25 years of service in the community. Give the video a watch if for no other reason than to see pictures of cute baby animals and if you can hit the like button on YouTube it would be greatly appreciated.

Tuesday, October 16, 2012

Presenting PhoneGap at Ottawa Web Design, UX Design and Web Development

So if you are one of the few people in Ottawa who haven't heard me do my presentation on PhoneGap I will be doing it one more time this year at the Ottawa Web Design, UX Design and Web Development meetup on November 7th. The meeting will be held at The Code Factory which is at 246 Queen St. Ottawa, ON. Maybe I'll see you there.

Friday, October 12, 2012

Books I've Read This Week

Sir Terry Prachett is a a national treasure, scratch that, an international treasure. His latest book Dodger is doesn't even take place on Discworld but that doesn't mean it is missing Prachett's signature humour. The book takes place in Victorian London and as you may have guessed the main character Dodger is an homage to Charles Dickens character the Artful Dodger from Oliver Twist. In fact other Victorian age characters fictional or real like Sweeney Todd, Benjamin Disraeli and Charles Dickens himself play roles in this story.

Dodger interrupts an attack on a young woman saving her life in the process. From there he pulls away at the mystery of why she was attacked trying to save her from more danger. His investigations lead him to a lot of interesting places and he meets a number of great characters.

I love Prachett's writing so I may be biased but I'd recommend this book to anyone. Especially non-Discworld fans as you don't need any background to jump in and read this story.

Oh and if you don't trust my review check out what Cory Doctorow had to say in his review over on Boing Boing.
Eloquent JavaScript: A Modern Introduction to Programming by Marijn Haverbeke is a great book for folks who want to be introduced to the JavaScript programming language. It is a very clear, concise, well written book with great examples. It recommend it to any beginner or intermediate JavaScript programmers. As well if you want to try it out before you buy it you can download a HTML copy from EloquentJavaScript.net.

Thursday, October 11, 2012

Music To Code By

If you are anything like me you like to listen to music while you are coding. Recently I've noticed that my collection of coding music had grown stale. I was listening to Daft Punk, The Chemical Brothers and David Guetta. There is only so many times you can listen to the Tron Legacy soundtrack on repeat. Don't get me wrong I love that album and Daft Punk in general but I need something new.

So like anyone else I took the question to twitter to see what my coder friends are listening to:

Julio Cesar suggested The Beatles which is a great but not exactly unique suggestion. I have about 64 of my favourite Beatles songs on my system. However, it doesn't really fit the bill as I'm looking for music without distracting lyrics.

Fil Maj suggested Baby Mammoth which I started listening to on YouTube and then moved over to GrooveShark where I've been listening to them quite a bit as it exactly fits the bill of what I wanted. Thanks Fil!

Adem Hamidovic suggested the Dredd Original Film Soundtrack soundtrack which is currently posted up on YouTube but I'm sure it'll get a takedown notice soon. I'm going to give it a listen this morning to see if it is worth the purchase.

William Prey suggested Sweet Mother Logic again on GrooveShark. I did a quick listen to some of their songs and it sounds just great. I love how it is completely instrumental but not electronic. Great change of pace from some of the other stuff I've been listening too.

Finally, Revolunet suggested using the music service 8tracks. You pick what music you want to listen to by selecting genre tags. It seems like an interesting way to discover new music.

So, what do you listen to while you are coding? Leave a comment to tell me about it.

Wednesday, October 10, 2012

Barcode Scanner Example Projects

For some reason a lot of folks have trouble setting up the BarcodeScanner Plugin. I've just posted two zip files to my Dropbox account.


1) Barcode scanner library project
2) Barcode scanner example project

Import both of these projects into Eclipse and you should be all set to go. Hopefully seeing the full projects will help people get up and running.

If this works for you and you don't already have Dropbox sign up for the free service via my referral link so I can have more space to host future example projects. Thanks!

Update: The easiest way to get this projects into Eclipse is to do the following. In Eclipse, go to the File menu, select the Import option, expand the Android folder, select Existing Android Code into Workspace. Then in the dialog that pops up select Finish. Now the project has been imported. If you have an error in your project, specifically with AndroidManifest.xml then you will want to right click on the project folder and select properties. Select Android and then choose the latest version of the Android SDK that you have installed. At this point the errors should go away, if they don't select the Project menu then Clean.

Friday, October 5, 2012

Books I've Read This Week

This week two fantastic anthropomorphic graphic novels:

I love, love, love these new Donald Duck and Uncle Scrooge collections from Fantagraphics. Walt Disney's Uncle Scrooge: "Only a Poor Old Man" by Carl Barks, the good duck artist, is the second volume to be release and it once again succeeds in returning me to childhood. This volume includes a number of short and long form stories including a couple of my favourites including “Tralla La La” and “The Secret of Atlantis". These are the stories that inspired the younger version of me to look into the topics of geography and history and helped build the know-it-all I am today. Even those these stories are funny they also have a bit of social commentary that is still relevant today. The young and the young at heart will love this book!
Blacksad: A Silent Hell written by Juan Diaz Canales and drawn by Juanjo Guarnido is the fourth Blacksad story. The first Blacksad collection is in my top three of best graphic novels of all time so my anticipation for new Blacksad was at an all time high. With that level of expectation it would be pretty easy to be disappointed by this latest story but I was not. The art and writing are as good as they ever been.

A Silent Hell finds Blacksad in New Orleans where he is embroiled in a murder mystery, missing person case. Blacksad needs to find jazz musician Sebastian "Little Hand" Fletcher as all of his former band mates are either missing or dead. Of course, because this is New Orleans you know voodoo will be involved somehow. Anyway, another great book and if you haven't picked up the original Blacksad collection of the first 3 adventures you owe it to yourself to pick it up and devour it.

Next week, no funny animal books.