So back in January I made a bunch of resolutions. Since we are getting close to the end of 2012 I thought I'd take a look back and see how I did on them.
Read Less
Back in 2011 I read 218 books and in 2012 I read 137 books so I succeeded in reading less but how did I do on quality.
Well I almost completely cut away my Manga reading with only one Manga book making my list in 2012. Not that I don't like Manga I just overdosed on a lot of quality series last year. My percentage of technical and non-fiction books went up but I still want to do better. What I need to do is stop putting a priority on the fiction and comics I get from the library and delve into the back log of books I already have purchased.
Verdict: Tie
Exterminate, Exterminate, Exterminate
Well I did a really good job on this one. I cut down on a number of inputs that were not providing me good information. If you need help with that I recommend reading The Information Diet by Clay Johnson. I recently subscribed to a bunch more podcasts but that was for me to find some new ones and trim out some of the older podcasts I'm no longer enjoying. I slashed away at who I was following on twitter and slowly added more people over time who are in the mobile development arena. Now my twitter feed contains much more relevant information than it did last year.
Also, TV was slashed away. My PVR actually died so I no longer felt the urge to catch up on the shows that were accumulating on the PVR. Instead I only watched some truly great shows like Homeland, Luther, Game of Thrones and couldn't be bothered to keep track of what is popular now.
Verdict: Win
The Obligatory "Get in Shape" Goal
This was a pretty easy goal for me to meet. They opened up a small gym on the first floor of my office building which makes it much easier for me to get in my weekly workouts. As well I really tried to watch what I was eating. Seriously, stick with food and not food like substances and you should be good folks. As a result I'm down about 10 lbs and in better shape than I was last year.
Verdict: Win
Publish or Perish
Okay, so I ended up publishing my first app to the Android marketplace. It wasn't the app I originally intended. That app was rendered obsolete by an update to the Android OS which included the functionality in the base OS.
I did not publish my first book. I am in the process of writing it and it will be a goal for me in 2013.
Verdict: Tie
So all in all I think I did pretty good in my keeping my resolutions for 2012. A bunch of wins and ties. Here's looking forward to a better 2013!
Monday, December 31, 2012
Friday, December 28, 2012
Books I've Read in My Life
Recently Locus released the results of their all century polls for the 20th and 21st centuries. It is an excellent list of books and I'm going to reproduce it here with the books I've read from the list bolded. Out of the 140 books I've read 116 of them. Lemme know which ones I've missed and should circle back towards.
20th Century Sci-Fi Novel (41 of 50)
1 Herbert, Frank : Dune (1965)
2 Card, Orson Scott : Ender's Game (1985)
3 Asimov, Isaac : The Foundation Trilogy (1953)
4 Simmons, Dan : Hyperion (1989)
5 Le Guin, Ursula K. : The Left Hand of Darkness (1969)
6 Adams, Douglas : The Hitchhiker's Guide to the Galaxy (1979)
7 Orwell, George : Nineteen Eighty-Four (1949)
8 Gibson, William : Neuromancer (1984)
9 Bester, Alfred : The Stars My Destination (1957)
10 Bradbury, Ray : Fahrenheit 451 (1953)
11 Heinlein, Robert A. : Stranger in a Strange Land (1961)
12 Heinlein, Robert A. : The Moon Is a Harsh Mistress (1966)
13 Haldeman, Joe : The Forever War (1974)
14 Clarke, Arthur C. : Childhood's End (1953)
15 Niven, Larry : Ringworld (1970)
16 Le Guin, Ursula K. : The Dispossessed (1974)
17 Bradbury, Ray : The Martian Chronicles (1950)
18 Stephenson, Neal : Snow Crash (1992)
19 Miller, Walter M. , Jr. : A Canticle for Leibowitz (1959)
20 Pohl, Frederik : Gateway (1977)
21 Heinlein, Robert A. : Starship Troopers (1959)
22 Dick, Philip K. : The Man in the High Castle (1962)
23 Zelazny, Roger : Lord of Light (1967)
24 Wolfe, Gene : The Book of the New Sun (1983)
25 Lem, Stanislaw : Solaris (1970)
26 Dick, Philip K. : Do Androids Dream of Electric Sheep? (1968)
27 Vinge, Vernor : A Fire Upon The Deep (1992)
28 Clarke, Arthur C. : Rendezvous with Rama (1973)
29 Huxley, Aldous : Brave New World (1932)
30 Clarke, Arthur C. : 2001: A Space Odyssey (1968)
31 Vonnegut, Kurt : Slaughterhouse-Five (1969)
32 Strugatsky, Arkady & Boris : Roadside Picnic (1972)
33 Card, Orson Scott : Speaker for the Dead (1986)
34 Brunner, John : Stand on Zanzibar (1968)
35 Robinson, Kim Stanley : Red Mars (1992)
36 Niven, Larry (& Pournelle, Jerry) : The Mote in God's Eye (1974)
37 Willis, Connie : Doomsday Book (1992)
38 Atwood, Margaret : The Handmaid's Tale (1985)
39 Sturgeon, Theodore : More Than Human (1953)
40 Simak, Clifford D. : City (1952)
41 Brin, David : Startide Rising (1983)
42 Asimov, Isaac : Foundation (1950)
43 Farmer, Philip Jose : To Your Scattered Bodies Go (1971)
44 Dick, Philip K. : Ubik (1969)
45 Vonnegut, Kurt : Cat's Cradle (1963)
46 Vinge, Vernor : A Deepness in the Sky (1999)
47 Simak, Clifford D. : Way Station (1963)
48 Wyndham, John : The Day of the Triffids (1951)
49* Keyes, Daniel : Flowers for Algernon (1966)
49* Delany, Samuel R. : Dhalgren (1975)
20th Century Fantasy Novel (35 of 50)
11 Adams, Richard : Watership Down (1972)
20 Bulgakov, Mikhail : The Master and Margarita (1967)
41 McCaffrey, Anne : Dragonflight (1968)
45 Lovecraft, H. P. : At the Mountains of Madness (1936)
46 Swanwick, Michael : The Iron Dragon's Daughter (1993)
49 Saint-Exupery, Antoine de : The Little Prince (1943)
1 Scalzi, John : Old Man's War (2005)
2 Stephenson, Neal : Anathem (2008)
3 Bacigalupi, Paolo : The Windup Girl (2009)
4 Wilson, Robert Charles : Spin (2005)
5 Watts, Peter : Blindsight (2006)
6 Morgan, Richard : Altered Carbon (2002)
7 Collins, Suzanne : The Hunger Games (2008)
8 Gibson, William : Pattern Recognition (2003)
9 Mieville, China : The City & the City (2009)
10 Stross, Charles : Accelerando (2005)
11 Mitchell, David : Cloud Atlas (2004)
12 McDonald, Ian : River of Gods (2004)
13 McCarthy, Cormac The Road (2006)
14 Harrison, M. John : Light (2002)
15* Willis, Connie : Black Out/All Clear (2010)
15* Chabon, Michael : The Yiddish Policemen's Union (2007)
17* Simmons, Dan : Ilium (2003)
17* Niffenegger, Audrey : The Time Traveler's Wife (2003)
19* Doctorow, Cory : Little Brother (2008
19* Ishiguro, Kazuo : Never Let Me Go (2005)
20th Century Sci-Fi Novel (41 of 50)
1 Herbert, Frank : Dune (1965)
2 Card, Orson Scott : Ender's Game (1985)
3 Asimov, Isaac : The Foundation Trilogy (1953)
4 Simmons, Dan : Hyperion (1989)
5 Le Guin, Ursula K. : The Left Hand of Darkness (1969)
6 Adams, Douglas : The Hitchhiker's Guide to the Galaxy (1979)
7 Orwell, George : Nineteen Eighty-Four (1949)
8 Gibson, William : Neuromancer (1984)
9 Bester, Alfred : The Stars My Destination (1957)
10 Bradbury, Ray : Fahrenheit 451 (1953)
11 Heinlein, Robert A. : Stranger in a Strange Land (1961)
12 Heinlein, Robert A. : The Moon Is a Harsh Mistress (1966)
13 Haldeman, Joe : The Forever War (1974)
14 Clarke, Arthur C. : Childhood's End (1953)
15 Niven, Larry : Ringworld (1970)
16 Le Guin, Ursula K. : The Dispossessed (1974)
17 Bradbury, Ray : The Martian Chronicles (1950)
18 Stephenson, Neal : Snow Crash (1992)
19 Miller, Walter M. , Jr. : A Canticle for Leibowitz (1959)
20 Pohl, Frederik : Gateway (1977)
21 Heinlein, Robert A. : Starship Troopers (1959)
22 Dick, Philip K. : The Man in the High Castle (1962)
23 Zelazny, Roger : Lord of Light (1967)
24 Wolfe, Gene : The Book of the New Sun (1983)
25 Lem, Stanislaw : Solaris (1970)
26 Dick, Philip K. : Do Androids Dream of Electric Sheep? (1968)
27 Vinge, Vernor : A Fire Upon The Deep (1992)
28 Clarke, Arthur C. : Rendezvous with Rama (1973)
29 Huxley, Aldous : Brave New World (1932)
30 Clarke, Arthur C. : 2001: A Space Odyssey (1968)
31 Vonnegut, Kurt : Slaughterhouse-Five (1969)
32 Strugatsky, Arkady & Boris : Roadside Picnic (1972)
33 Card, Orson Scott : Speaker for the Dead (1986)
34 Brunner, John : Stand on Zanzibar (1968)
35 Robinson, Kim Stanley : Red Mars (1992)
36 Niven, Larry (& Pournelle, Jerry) : The Mote in God's Eye (1974)
37 Willis, Connie : Doomsday Book (1992)
38 Atwood, Margaret : The Handmaid's Tale (1985)
39 Sturgeon, Theodore : More Than Human (1953)
40 Simak, Clifford D. : City (1952)
41 Brin, David : Startide Rising (1983)
42 Asimov, Isaac : Foundation (1950)
43 Farmer, Philip Jose : To Your Scattered Bodies Go (1971)
44 Dick, Philip K. : Ubik (1969)
45 Vonnegut, Kurt : Cat's Cradle (1963)
46 Vinge, Vernor : A Deepness in the Sky (1999)
47 Simak, Clifford D. : Way Station (1963)
48 Wyndham, John : The Day of the Triffids (1951)
49* Keyes, Daniel : Flowers for Algernon (1966)
49* Delany, Samuel R. : Dhalgren (1975)
20th Century Fantasy Novel (35 of 50)
1 Tolkien, J. R. R. : The Lord of the Rings (1955)
2 Martin, George R. R. : A Game of Thrones (1996)
3 Tolkien, J. R. R. : The Hobbit (1937)
4 Le Guin, Ursula K. : A Wizard of Earthsea (1968)
5 Zelazny, Roger : Nine Princes in Amber (1970)
6 Lewis, C. S. : The Lion, the Witch and the Wardrobe (1950)
7 Mieville, China : Perdido Street Station (2000)
8 Gaiman/Pratchett : Good Omens (1990)
9 Rowling, J. K. : Harry Potter and the Philosopher's Stone (1997)
10 Crowley, John : Little, Big (1981)11 Adams, Richard : Watership Down (1972)
12 Goldman, William : The Princess Bride (1973)
13 Martin, George R. R. : A Storm of Swords (2000)
14 Beagle, Peter S. : The Last Unicorn (1968)
15 White, T. H. : The Once and Future King (1958)
16 Kay, Guy Gavriel : Tigana (1990)
17 Gaiman, Neil : Neverwhere (1996)
18 Wolfe, Gene : The Book of the New Sun (1983)
19 Vance, Jack : The Dying Earth (1950)20 Bulgakov, Mikhail : The Master and Margarita (1967)
21 Rowling, J. K. : Harry Potter and the Goblet of Fire (2000)
22 Tolkien, J. R. R. : The Silmarillion (1977)
23 Leiber, Fritz : The Swords of Lankhmar (1968)
24 Jordan, Robert : The Eye of the World (1990)
25 Donaldson, Stephen R. : Lord Foul's Bane (1977)
26 Bradbury, Ray : Something Wicked This Way Comes (1962)
27 Peake, Mervyn : Gormenghast (1950)
28 Rowling, J. K. : Harry Potter and the Prisoner of Azkaban (1999)
29 Powers, Tim : The Anubis Gates (1983)
30 Martin, George R. R. : A Clash of Kings (1998)
31 Bradley, Marion Zimmer : The Mists of Avalon (1983)
32 Hobb, Robin : Assassin's Apprentice (1995)
33 Pratchett, Terry : The Colour of Magic (1983)
34 Holdstock, Robert : Mythago Wood (1984)
35 King, Stephen : The Stand (1978)
36* L'Engle, Madeleine : A Wrinkle in Time (1962)
36* Pratchett, Terry : Small Gods (1992)
38 Howard, Robert E. : Conan the Barbarian (1950)
39 Ende, Michael : The Neverending Story (1983)
40 Peake, Mervyn : Titus Groan (1946)41 McCaffrey, Anne : Dragonflight (1968)
42 Orwell : George : Animal Farm (1945)
43 Feist, Raymond E. : Magician (1982)
44 Silverberg, Robert : Lord Valentine's Castle (1980)45 Lovecraft, H. P. : At the Mountains of Madness (1936)
46 Swanwick, Michael : The Iron Dragon's Daughter (1993)
47 King, Stephen : The Shining (1977)
48 Garcia Marquez, Gabriel : One Hundred Years of Solitude (1970)49 Saint-Exupery, Antoine de : The Little Prince (1943)
50 Hughart, Barry : Bridge of Birds (1984)
21st Century Sci-Fi Novel (14 of 20)
1 Scalzi, John : Old Man's War (2005)
2 Stephenson, Neal : Anathem (2008)
3 Bacigalupi, Paolo : The Windup Girl (2009)
4 Wilson, Robert Charles : Spin (2005)
5 Watts, Peter : Blindsight (2006)
6 Morgan, Richard : Altered Carbon (2002)
7 Collins, Suzanne : The Hunger Games (2008)
8 Gibson, William : Pattern Recognition (2003)
9 Mieville, China : The City & the City (2009)
10 Stross, Charles : Accelerando (2005)
11 Mitchell, David : Cloud Atlas (2004)
12 McDonald, Ian : River of Gods (2004)
13 McCarthy, Cormac The Road (2006)
14 Harrison, M. John : Light (2002)
15* Willis, Connie : Black Out/All Clear (2010)
15* Chabon, Michael : The Yiddish Policemen's Union (2007)
17* Simmons, Dan : Ilium (2003)
17* Niffenegger, Audrey : The Time Traveler's Wife (2003)
19* Doctorow, Cory : Little Brother (2008
19* Ishiguro, Kazuo : Never Let Me Go (2005)
21st Century Fantasy Novel (16 of 20)
1 Gaiman, Neil : American Gods (2001)
2 Clarke, Susanna : Jonathan Strange & Mr Norrell (2004)
3 Rothfuss, Patrick : The Name of the Wind (2007)
4 Mieville, China : The Scar (2002)
5 Martin, George R. R. : A Feast for Crows (2005)
6 Rowling, J. K. : Harry Potter and the Deathly Hallows (2007)
7 Bujold, Lois McMaster : The Curse of Chalion (2001)
8 Mieville, China : The City & the City (2009)
9 Fforde, Jasper : The Eyre Affair (2001)
10* Bujold, Lois McMaster : Paladin of Souls (2003)
10* Pratchett, Terry : Night Watch (2002)
12 Gaiman, Neil : Coraline (2002)
13* Wolfe, Gene : The Wizard Knight (2004)
13* Abercrombie, Joe : The Blade Itself (2006)
15 Pratchett, Terry : Going Postal (2004)
16* Gaiman, Neil : The Graveyard Book (2008)
16* Lynch, Scott : The Lies of Locke Lamora (2006)
18 Jemisin, N. K. : The Hundred Thousand Kingdoms (2010)
19 Le Guin, Ursula K. : Lavinia (2008)
20 Sanderson, Brandon : Mistborn (2006)
Tuesday, December 18, 2012
What's New in PhoneGap Android 2.3.0
Well we've tagged Apache Cordova 2.3.0 release candidate 2 which means that Cordova 2.3.0 will be out soon in source release form which will be followed quickly by the binary PhoneGap 2.3.0 release. Shaz wrote up a post on what's new in iOS so I followed suit to do this one for Android. So without further ado here's what you should expect on Android:
1. InAppBrowser – includes events
More details here. In a nutshell, this has the same functionality as the ChildBrowser, and has events support as well. It supports this simplified spec. Also, the InAppBrowser does not use the app whitelist. Example usage:
2. Device API changes
Minor changes as specified here. For Android, device.name is now deprecated for all platforms. For all platforms, there is a new property called device.model which returns what device.name used to return.
3. Various Bug Fixes
1. InAppBrowser – includes events
More details here. In a nutshell, this has the same functionality as the ChildBrowser, and has events support as well. It supports this simplified spec. Also, the InAppBrowser does not use the app whitelist. Example usage:
2. Device API changes
Minor changes as specified here. For Android, device.name is now deprecated for all platforms. For all platforms, there is a new property called device.model which returns what device.name used to return.
3. Various Bug Fixes
- Searching for emails in Contacts throws an exception always errors out
- Create script improvement: Display usage and exit when no arguments given
- Fixed adding a Photo from a HTTPS address to Contact
- Fixed NPE in onReceivedError with non local errorUrl
- Camera.getPicture gives error when get a picture from photo library with spaces in its name on Android is now fixed
- Online/Offline events now fire on subsequent pages of an app
- fixing cordova commands for paths with spaces in them
- FileEntry.moveTo across file systems incorrectly calls the success callback
Friday, December 14, 2012
Things I've Listened to This Week
I thought I would change it up a bit this week and delve into some of the new podcasts I tried out this week. At work I listen to podcasts almost exclusively as I need something to drown out the white noise that they play in our building. Apparently, it is a good thing but it actually drives me nuts. Since I've already got my two front teeth all I want for Christmas is a pair of noise cancelling headphones.
After you look at these mini-reviews lemme know what other podcasts you think I'd enjoy or which ones you really like.
After you look at these mini-reviews lemme know what other podcasts you think I'd enjoy or which ones you really like.
Freakonomics Radio I loved the books so I figured I'd try out the podcast. I'm not 100% sure on this one though. Verdict: Going to listen to a few more episodes before deciding. |
Girl on Guy well I love the TV show Archer and I've heard an interview with Aisha Tyler on The Nerdist and thought she was great. Then I listened to her talk with nerd godess Felicia Day and was blow away. Then in the second episode she talked to Seth Green. This is a fantastic podcast go listen. Verdict: Keeping it on the playlist. |
Good Job, Brain! A trivia podcast! Sold! I've listened to two episodes so far and I really loved it. I'm a trivia buff and I've probably got more useless knowledge than any two people you know put together. Verdict: Keeping it on the playlist. |
NPR Fresh Air is an interview podcast with folks from popular culture. The first episode I listened to had guest Judd Apatow which was enough to get me hooked. Verdict: Going to listen to a few more episodes before deciding. |
NPR How to do Everything is an odd little podcast which is funny while at the same time informs you. Verdict: Going to listen to a few more episodes before deciding. |
Stuff You Should Know I've tried to like this podcast before and even after a second go around I think I'm going to pass on this one again. You would think that a podcast about obscure stuff would be right up my alley. Sadly I think the issue is that I don't identify with the hosts. Verdict: Deleted. |
WNYC RadioLab a mismatch of stories. Not sure what to think about it yet. Verdict: Going to listen to a few more episodes before deciding. |
WTF with Marc Maron well I really love the Nerdist podcast so I thought I'd give another of the top rated comedy podcasts a try and I wasn't disappointed. Maron does a great job interviewing his comedian friends and the show is downright hilarious. Verdict: Keeping it on the playlist. |
Friday, December 7, 2012
Books I've Read This Week
Double Cross: The True Story of the D-Day Spies by Ben MacIntyre is a bit of a companion piece to Operation Mincemeat which is another book by spies in WWII that I highly recommend. In Double Cross we learn all about the spies that England was running during WWII including the ones that Germany thought they were running but were actually English spies or completely fabricated by the English. It is a great book that tries to make sense of the twisting lives of spies, double and triple agents. |
Two Generals by Scott Chantler is a fascinating look at the life and memories of Law Chantler, the authors grand father, during his time in WWII. It's beautifully drawn and follows Law as his regiment takes part in D-Day. It's stories like this that make me very proud of Canada's accomplishments during WWII. |
Thursday, December 6, 2012
How to Get the Device's Phone Number Using PhoneGap Android
I was a bit surprised when three people asked me how to do this in one day. I figured if there was enough interest in it then maybe it deserved a post of it's own. Basically you want to know the primary phone number of the device your app is running on. In order to do that in PhoneGap you will need to write a plugin to access the TelephonyManager service on Android.
As always the code for this plugin is is GitHub at my TelephoneNumberPlugin repo. If you'd rather have a more detailed walk through please read on.
First up let's code our JavaScript interface which we will use to get the telephone number. We'll setup a new interface at "cordova/plugin/telephonenumber" to avoid name collisions. Then the rest is fairly boiler plate code where we declare and error object that we won't even use and finally provide a get method. When you call the get method you should provide a success callback. The success callback will be invoked with a string that will contain the devices phone number. If something goes wrong the failure callback will be invoked. I've extracted the execute method from TelephoneNumber.java which extends from the new CordovaPlugin interface. The method is fairly self explanatory. If the device has a phone number it will be returned. If not the error call back is invoked with the NO_TELEPHONE_NUMBER error code. If you try to call anything other than "get" on this class you'll get a INVALID_ACTION error. In order to use this plugin you'll need to include the telephonenumber.js in your HTML as a script tag: and add a line to res/xml/config.xml to tell the JavaScript side where to find your Java class: and if you don't already have READ_PHONE_STATE as a permission in your AndroidManifest.xml you will need to add it as well. Now you should be able to get your devices phone number. Here is some sample code that writes the phone number out to the console:
As always the code for this plugin is is GitHub at my TelephoneNumberPlugin repo. If you'd rather have a more detailed walk through please read on.
First up let's code our JavaScript interface which we will use to get the telephone number. We'll setup a new interface at "cordova/plugin/telephonenumber" to avoid name collisions. Then the rest is fairly boiler plate code where we declare and error object that we won't even use and finally provide a get method. When you call the get method you should provide a success callback. The success callback will be invoked with a string that will contain the devices phone number. If something goes wrong the failure callback will be invoked. I've extracted the execute method from TelephoneNumber.java which extends from the new CordovaPlugin interface. The method is fairly self explanatory. If the device has a phone number it will be returned. If not the error call back is invoked with the NO_TELEPHONE_NUMBER error code. If you try to call anything other than "get" on this class you'll get a INVALID_ACTION error. In order to use this plugin you'll need to include the telephonenumber.js in your HTML as a script tag: and add a line to res/xml/config.xml to tell the JavaScript side where to find your Java class: and if you don't already have READ_PHONE_STATE as a permission in your AndroidManifest.xml you will need to add it as well. Now you should be able to get your devices phone number. Here is some sample code that writes the phone number out to the console:
Wednesday, December 5, 2012
Speaking at Decembers OttawaJS
Hey, if you are in Ottawa I'll be speaking at the next OttawaJS meeting. The meeting will be held on Wednesday December 12th at 6:30pm at the gorgeous Shopify offices. My talk is all about developing speech recognition web apps which of course is me pulling the guts of my Android app, Anna, and making it work in the browser.
It should be a good time so if you can make it out it'd be great to talk with you.
It should be a good time so if you can make it out it'd be great to talk with you.
Friday, November 30, 2012
Books I've Read This Week
Saga Volume 1 by Brian K Vaughn and with art by Fiona Staples is pretty damn amazing. It is a science fiction epic where we follow Alana and Marko who are fleeing a war. The crux of the matter is that Alana and Marko are from opposite sides of a war between two different alien races. The powers that be from both sides want them apprehended before it is discovered that the two races can inter-breed. Oh yeah, the story opens up shortly before the birth of their first child. The pair are chased by a collection of odd characters including elements from the military of Alana's race as well as a number of bounty hunters which include the Stalk (a human spider hybrid) and The Will. Just image the original cantina scene from Star Wars: A New Hope writ large. Fiona Staples really gets a chance to play with character designs and sweeping alien vistas. The book would be well worth it from the art alone but you also get some great writing as well. I'm looking forward to picking up this series for years to come. Finally the six issue collection only has a $9.99 price which is an absolute steal. I really love that introductory price on Image Comics first trade paper backs. |
The $100 Startup: Reinvent the Way You Make a Living, Do What You Love, and Create a New Future by Chris Guillebeau. I admit I'm intrigued by entrepeneurs. I'm super impressed by the guts one must have in order to strike out on their own. The thing this book tries to address is taking away the fear of taking that risk. Guillebeau dives into fifty case studies of small entrepreneurs who've started their business with as little as $100 and now make a full time living off of that business. The key piece that I take away from this book is that anyone can do it and you don't need to risk your financial security in order to do it. However, the book also tells you that the way to succeed is to do something that you are not only good at but passionate about. That's where I count myself lucky as my day job is working with open source software and playing with mobile phones. It doesn't get much better than that for me. |
Wednesday, November 28, 2012
Building a HTML Options Menu for PhoneGap Android
Alright, sorry it took me so long to get back to this but I was busy getting things done for the 2.3.0 release. This is a continuation of my series of posts on menus the previous ones were on Context and Option menus. Also, the code is not perfect there are some things I want to do that will support multiple image sizes and organize the menu in multiple rows but I figured I'd release what I was able to re-create. My original code is somewhere on another laptop. So the new code is now available in this github repo.
Okay, so if you want to use this component you will need to download OptionsMenu.js from the above link, place it in your assets/www folder then add the script tag after cordova.js in your HTML file.
Next you will want to create you menu. For my purposes I've used the settings/help example like the previous two posts on menus. To do it you add some code into your to the method that is listening for the "deviceready" event. Something like this:
and that will produce a menu that looks like this:
But let's dig in a bit of that call to create a new OptionsMenu. The magic is in the JSON object passed to the construction. Obviously the "id" is used to set the ID of the div that will hold the menu items. Then the items array will contain all of the menu items you want to display. Each menu item has three properties, image is a url the icon you want to display in the item, label which is the text which is shown under the image and finally action which is a JavaScript function that is called when the item is tapped.
So that's it, you have a fully functioning HTML/CSS/JS only options menu just by including an additional JavaScript file. Like I said the code is up on github and it is not perfect. Feel free to submit issues as I'm going to pick away at making it more robust after I take a mini vacation.
Update: So I realized the menu really should support multiple rows just like a real Android options menu so I just pushed an update to my code on Github to support it. Instead of an array being sent to the constructor of the OptionsMenu you send a multi-dimensional array like so:
and then it looks like this:
You will also notice the icons are a bit smaller. I'm checking for the size of the screen and adjusting the icon width and height accordingly.
Okay, so if you want to use this component you will need to download OptionsMenu.js from the above link, place it in your assets/www folder then add the script tag after cordova.js in your HTML file.
Next you will want to create you menu. For my purposes I've used the settings/help example like the previous two posts on menus. To do it you add some code into your to the method that is listening for the "deviceready" event. Something like this:
and that will produce a menu that looks like this:
But let's dig in a bit of that call to create a new OptionsMenu. The magic is in the JSON object passed to the construction. Obviously the "id" is used to set the ID of the div that will hold the menu items. Then the items array will contain all of the menu items you want to display. Each menu item has three properties, image is a url the icon you want to display in the item, label which is the text which is shown under the image and finally action which is a JavaScript function that is called when the item is tapped.
So that's it, you have a fully functioning HTML/CSS/JS only options menu just by including an additional JavaScript file. Like I said the code is up on github and it is not perfect. Feel free to submit issues as I'm going to pick away at making it more robust after I take a mini vacation.
Update: So I realized the menu really should support multiple rows just like a real Android options menu so I just pushed an update to my code on Github to support it. Instead of an array being sent to the constructor of the OptionsMenu you send a multi-dimensional array like so:
and then it looks like this:
You will also notice the icons are a bit smaller. I'm checking for the size of the screen and adjusting the icon width and height accordingly.
Friday, November 23, 2012
Books I've Read This Week
Wheat Belly by William Davis is another book in a series of books that are blaming the obesity epidemic on carbohydrates, in this case specifically wheat. I'm not a Doctor myself but the author William Davis is and he has the science and real world experience to back up his claims. Personally what I have noticed is that by limiting the amount of processed carbs I eat that my weight is way down, over 10 lbs this year. That may not seem like a lot but I'm not carrying around a lot of extra weight to begin with so maybe Dr. Davis is on to something here. Other books that are similar in natured include The G.I. Diet, The Paleo Solution and even The 4-Hour Body. |
Invincible Iron Man - Volume 7: My Monsters by Matt Fraction is where this series goes off the rails for me. I really enjoyed the first 6 volumes but this is where I suggest folks stop. At the end of volume 6 we could see that the Mandarin was going to be the big baddie going forward. So in volume 7 it opens up with a Mandarin story written by Kelly Sue Deconnick which is the main reason to pick up this book. The Mandarin has kidnapped a famous director so that he can make a movie based on his life story. Of course the Mandarin wants to paint himself in the most flattering light but the director is looking for more "authenticity". After that we are treated to a re-hash of the origin of Iron Man and some alternative future story which I'd rather just forget I'd even read. |
Friday, November 16, 2012
Getting the create Command to Work on PhoneGap 2.2.0 Android
Okay as of PhoneGap 2.2.0 the Getting Started guide has been "simplified" to make creating your first Phonegap Android project easier. Boy, that's not the impression I get after helping people on the PhoneGap Google Group for the past week and a half.
From what I understand most of us Cordova core developers use a Mac as our main machine. Now I don't want to and won't start an OS holy war since there is a very good reason why we do that, you can't do iOS without a Mac and the tools for Android and BlackBerry development will run on a Mac so it makes sense for those of us who have to jump back and forth to be using a Mac. However, we've really dropped the ball in explaining what the proper setup needs to be when you are on a PC. So that's why I'm writing this blog post from my old Windows laptop that I dusted off so I can feel your pain.
Required Software
Once you do that you probably will see this error:
So basically and unhelpful error telling you that you are missing a package. We'll need to make sure the following commands can be run from the command prompt. Let's start by testing if the command line can find java.exe first. So type:
then you will need to modify your PATH environment variable so that the script can find Java. First you'll need to discover where your JDK is installed. I can't tell you where that is so I hope you took my advice and noted where the installer placed those files. Armed with the path to your Java Development Kit do the following:
From what I understand most of us Cordova core developers use a Mac as our main machine. Now I don't want to and won't start an OS holy war since there is a very good reason why we do that, you can't do iOS without a Mac and the tools for Android and BlackBerry development will run on a Mac so it makes sense for those of us who have to jump back and forth to be using a Mac. However, we've really dropped the ball in explaining what the proper setup needs to be when you are on a PC. So that's why I'm writing this blog post from my old Windows laptop that I dusted off so I can feel your pain.
Required Software
Go ahead and download and install those packages if you haven't already. I'll wait. I'm not up to anything else right now. But please pay attention to where you install these packages as you'll need those paths later.
Oh good, you're back.
Oh good, you're back.
First problem
Once you navigate to the phongeap\lib\android\bin directory the getting started guide tells you to run the following command:
./create <project_folder_path> <package_name> <project_name>but that is not accurate on a Windows system as it won't be able to find the create command. The line should be:
create <project_folder_path> <package_name> <project_name>Second problem
Once you do that you probably will see this error:
So basically and unhelpful error telling you that you are missing a package. We'll need to make sure the following commands can be run from the command prompt. Let's start by testing if the command line can find java.exe first. So type:
javainto the command line. If you see something like this:
then you will need to modify your PATH environment variable so that the script can find Java. First you'll need to discover where your JDK is installed. I can't tell you where that is so I hope you took my advice and noted where the installer placed those files. Armed with the path to your Java Development Kit do the following:
- From the Desktop, right-click My Computer and click Properties.
- Click Advanced System Settings link in the left column.
- In the System Properties window click the Environment Variables button.
- Select the PATH variable from the System variables section.
- Select the Edit button.
which means you should have a dialog something like this:
This is where you will add the JDK\bin directory to your PATH. Notice you need to point to the bin directory where commands line java and javac are kept. For example "c:\jdk\bin". Also make sure to separate different path entries using a ";". Now you need to click OK then OK once more. After that close your command prompt and start a new one so the updated PATH variable will be used. In the new command prompt run:
java
once again and you should see something like this:
Now the create script will be able to find java. Unfortunately you'll need to repeat the process for the following commands:
- javac
- ant
- adb
- android
If you get the "blah" is not a recognized internal or external command error message for any of the above you'll need to add it to the PATH.
Third problem
The environment variable JAVA_HOME may be set incorrectly. Make sure that this variable is set and it refers to the root directory of your JDK and not JRE. The create.js script looks for %JAVA_HOME%\bin\javac.exe and if it can't find it there will be an error.
Fourth problem
Don't use '-' in your package name. The '-' is not a valid character in a Java package name.
Bad: ./create ./name com.my-company.name name
Good: ./create ./name com.mycompany.name name
Third problem
The environment variable JAVA_HOME may be set incorrectly. Make sure that this variable is set and it refers to the root directory of your JDK and not JRE. The create.js script looks for %JAVA_HOME%\bin\javac.exe and if it can't find it there will be an error.
Fourth problem
Don't use '-' in your package name. The '-' is not a valid character in a Java package name.
Bad: ./create ./name com.my-company.name name
Okay, I hope that helps everyone. I'm going to make the error messages more descriptive while I'm on my PC for the upcoming 2.3.0 release.
Books I've Read This Week
Doomsday Book by Connie Willis is a book I've been meaning to read ever since I finished her Blackout/All Clear duology. I was surprised but pleased to find out that this book takes place in the same universe as Blackout/All Clear. Unfortunately that also means that I had a very good idea how the time travel plot would play out. It won the Hugo and Nebula awards back in 1993 so I came into it with high expectations considering the other Hugo/Nebula winners I can think off the top of my head are Dune, Ender's Game, Neuromancer, American Gods, The Windup Girl and the afore mentioned Blackout/All Clear. Sadly it didn't live up to my high expectations even though it is a pretty darn good book. In 2048 we are able to send people back into the past to observe things. Our historian Kivrin is about to travel back to the 14th century to observe contemporary life. Unfortunately, the technician who is to send her back to the past falls prey to a 21st century disease and she ends up smack dab in the middle of the black plague. We are left with parallel stories of how the people of the 14th and 21st centuries deal with epidemics. |
The Best of Down Goes Brown by Sean McIndeo is hilarious. By the time I was on page 6 I had already laughed out loud on 4 separate occasions. Honestly this book is worth the purchase price if you only ever read "A Look Back at Game Seven of the 2011 Stanley Cup Final (which, due to a scheduling error, had to be published twelve hours early)" which is one of the best piece of satirical writing I've ever read. Seems like a great gift for that hockey lover in your life and I thoroughly enjoyed every chapter. I'm now a follower of the blog and twitter feed. |
Monday, November 12, 2012
Building a Native Context Menu for PhoneGap Android
So I know I promised that I'd write about a HTML only menu but I thought folks might be interested in native context menus as well. It's not much different than my last blog post on menu's so it should be easy to follow.
So when I talk about a native context menu I mean the menu that clicks when you do a long press on an Android device. Again this is well covered on the Android Developer page. Here is an example of an context menu from the Contacts app:
The first step in creating the menu is to define it in XML. My recommendation is to create a menu folder under the res folder in your Android Eclipse project. Then you create a new File with an XML extension. For this post I'll call mine example.xml. When you're done your res folder should look something like this:
Don't worry about the red X's as we haven't edited the XML file yet so it is going to complain about a premature end of file. For a real good description of what goes into a menu XML file read this. For our purposes I'm just going to give you the XML to paste into the file:
But when you view the file in Eclipse you'll still see errors:
You shouldn't need to change anything unless you've called your menu XML file something different than example.xml. If you have you'll need to change R.menu.example into R.menu. where you replace with the name of your file minus the .xml extension.
The last bit of code you need to add is a method that will tell your application what to do when the individual menu items are clicked. Here's some example code:
When you click on the Setting button we'll use an Android intent to load the devices Settings panel. If you click on the Help button then we'll execute some JavaScript code. That's it! You don't need to add anything to your HTML/JS code to get a native Android context menu working with your PhoneGap application. Here is what it would look like:
Please note, I'm just providing a quick example and you are not limited to how you handle the menu button clicks in the least. You may want to handle it in Java and do something that you can't do in JavaScript or you may want to call a JavaScript function on your page to have your UI react in some interesting way.
So, there you go. The process is nearly identical to creating an options menu that I described in my previous post. I promise that in my next post I'll show you how to handle everything in HTML and JavaScript!
So when I talk about a native context menu I mean the menu that clicks when you do a long press on an Android device. Again this is well covered on the Android Developer page. Here is an example of an context menu from the Contacts app:
The first step in creating the menu is to define it in XML. My recommendation is to create a menu folder under the res folder in your Android Eclipse project. Then you create a new File with an XML extension. For this post I'll call mine example.xml. When you're done your res folder should look something like this:
Don't worry about the red X's as we haven't edited the XML file yet so it is going to complain about a premature end of file. For a real good description of what goes into a menu XML file read this. For our purposes I'm just going to give you the XML to paste into the file:
But when you view the file in Eclipse you'll still see errors:
and that is to be expected as we haven't added the two images to the drawables folder nor have we added our two new strings to strings.xml. To fix these issues first download these two images:
and copy them to your projects res/drawable-hdpi folder. When you want to put out a professional application you'll need to provide icons of various sizes but the above is enough for our needs.
To fix the rest of the red X's you'll need to open the res/values/strings.xml and add two new Strings. The first should have the name "settings" and a value of "Settings. The second should have the name"help" and, predictably, the value of "Help". At this point all the red X's from example.xml and from the res folder hierarchy should have disappeared.
If they haven't, well then you've done something wrong and should probably go back over all the steps to make sure you haven't missed anything.
Okay, so now we've got all the resources in place. Let's go write some actual Java code. Don't worry much of it will be cut and paste. In Eclipse open up your main Java class, you know the one that extends DroidGap.
First you'll need to register the context menu in the onCreate method. Basically, you'll need to add the call to registerForContextMenu to your onCreate method:
Secondly we'll need to tell your application what to do when it detects a long press. You'll need to paste the following code into you main Java class:
The last bit of code you need to add is a method that will tell your application what to do when the individual menu items are clicked. Here's some example code:
When you click on the Setting button we'll use an Android intent to load the devices Settings panel. If you click on the Help button then we'll execute some JavaScript code. That's it! You don't need to add anything to your HTML/JS code to get a native Android context menu working with your PhoneGap application. Here is what it would look like:
Please note, I'm just providing a quick example and you are not limited to how you handle the menu button clicks in the least. You may want to handle it in Java and do something that you can't do in JavaScript or you may want to call a JavaScript function on your page to have your UI react in some interesting way.
So, there you go. The process is nearly identical to creating an options menu that I described in my previous post. I promise that in my next post I'll show you how to handle everything in HTML and JavaScript!
Friday, November 9, 2012
Books I've Read This Week
The Happiness Project by Gretchen Rubin is not the usual type of book I read. Honestly, I have a lot of things to be thankful for. I've got my health, I'm married to an amazing woman, we have a great child, I'm gainfully employed in a job that I actually enjoy but I'm not sure you could call me a happy person. Ernest Hemmingway once said "Happiness in intelligent people is the rarest thing I know." and I identify with that statement. My mind is always running thinking of ways to make things better or thinking of what else needs to be done. So, that's why I was attracted to the Happiness Project. I enjoyed reading the book and what I've really taken from it is just to let go of things. I lead an incredibly blessed life and I should not let the little things bother me quite so much. The book is quite well written in a light tone. It's organized in months where each month focuses on a particular way to improve one's happiness. This makes a lot of sense as it is hard to make new positive habits if you are trying to focus on too many things. |
Thursday, November 8, 2012
My PhoneGap Plugins Have Moved
If you are looking for any of the plugins that I have contributed to the PhoneGap Plugins repo they have moved into my own repo. Why do you ask? Well you should go read Shaz's blog post as to the why's and wherefore's.
So you can now find my plugins at:
So you can now find my plugins at:
Tuesday, November 6, 2012
Building a Native Menu with PhoneGap Android
So this question has been posed to me quite a few times over the past couple of weeks so I figure this is probably a good idea for a series of blog posts. In this instalment I'll talk about creating a native menu and next time we'll use only HTML.
So when I talk about a native menu I mean an Android options menu and a lot of the information I'm going to give you is covered very well on this Android Developer page but what I'm going to do is help show you where to add the hooks into your PhoneGap application. Here is an example of an options menu from the Contacts app:
The first step in creating the menu is to define it in XML. My recommendation is to create a menu folder under the res folder in your Android Eclipse project. Then you create a new File with an XML extension. For this post I'll call mine example.xml. When your're done your res folder should look something like this:
Don't worry about the red X's as we haven't edited the XML file yet so it is going to complain about a premature end of file. For a real good description of what goes into a menu XML file read this. For our purposes I'm just going to give you the XML to paste into the file:
But when you view the file in Eclipse you'll still see errors:
You shouldn't need to change anything unless you've called your menu XML file something different than example.xml. If you have you'll need to change R.menu.example into R.menu. where you replace with the name of your file minus the .xml extension.
The second bit of code you need to add is a method that will tell your application what to do when the individual menu items are clicked. Here's some example code:
When you click on the Setting button we'll use an Android intent to load the devices Settings panel. If you click on the Help button then we'll execute some JavaScript code. That's it! You don't need to add anything to your HTML/JS code to get a native Android options menu working with your PhoneGap application. Here is what it would look like:
Please note, I'm just providing a quick example and you are not limited to how you handle the menu button clicks in the least. You may want to handle it in Java and do something that you can't do in JavaScript or you may want to call a JavaScript function on your page to have your UI react in some interesting way.
In my next post I'll show you the reverse. How to handle everything in HTML and JavaScript!
So when I talk about a native menu I mean an Android options menu and a lot of the information I'm going to give you is covered very well on this Android Developer page but what I'm going to do is help show you where to add the hooks into your PhoneGap application. Here is an example of an options menu from the Contacts app:
The first step in creating the menu is to define it in XML. My recommendation is to create a menu folder under the res folder in your Android Eclipse project. Then you create a new File with an XML extension. For this post I'll call mine example.xml. When your're done your res folder should look something like this:
Don't worry about the red X's as we haven't edited the XML file yet so it is going to complain about a premature end of file. For a real good description of what goes into a menu XML file read this. For our purposes I'm just going to give you the XML to paste into the file:
But when you view the file in Eclipse you'll still see errors:
and that is to be expected as we haven't added the two images to the drawables folder nor have we added our two new strings to strings.xml. To fix these issues first download these two images:
and copy them to your projects res/drawable-hdpi folder. When you want to put out a professional application you'll need to provide icons of various sizes but the above is enough for our needs.
To fix the rest of the red X's you'll need to open the res/values/strings.xml and add two new Strings. The first should have the name "settings" and a value of "Settings. The second should have the name"help" and, predictably, the value of "Help". At this point all the red X's from example.xml and from the res folder hierarchy should have disappeared.
If they haven't, well then you've done something wrong and should probably go back over all the steps to make sure you haven't missed anything.
Okay, so now we've got all the resources in place. Let's go write some actual Java code. Don't worry much of it will be cut and paste. In Eclipse open up your main Java class, you know the one that extends DroidGap.
First we'll need to tell your application what to do when it detects that the menu button has been pressed. You'll need to paste the following code into you main Java class:
The second bit of code you need to add is a method that will tell your application what to do when the individual menu items are clicked. Here's some example code:
When you click on the Setting button we'll use an Android intent to load the devices Settings panel. If you click on the Help button then we'll execute some JavaScript code. That's it! You don't need to add anything to your HTML/JS code to get a native Android options menu working with your PhoneGap application. Here is what it would look like:
Please note, I'm just providing a quick example and you are not limited to how you handle the menu button clicks in the least. You may want to handle it in Java and do something that you can't do in JavaScript or you may want to call a JavaScript function on your page to have your UI react in some interesting way.
In my next post I'll show you the reverse. How to handle everything in HTML and JavaScript!
Monday, November 5, 2012
My WD MyBook Live Crashed
Well, we had a bit of a power hiccup last week and when I got home my WD MyBook Live could no longer be recognized on my home network. Nothing I could do would get the drive working again so I had to assume the power outage fried the ethernet chip on the board of the enclosure. Googling around the internet showed other folks encountered the same problem that I have.
This is the second time a WD enclosure has failed on me. Why, oh why, do I do this to myself. I guess it is because I'm cheap and the WD products offer a good price/functionality ratio. However, what they do not offer is reliability. This is a good lesson for us all not to skimp on quality when you have an important piece of your home setup.
I guess I should explain that I use the MyBook Live to host my iTunes library. As a result it is just packed with shows for my daughter and I really need to get this fixed before she wants to watch Beverly Hills Chihuahua again. As well this drive is setup to be the receptacle of the Time Machine backup on the Mac. I get antsy if my backup isn't running daily even though I also run Carbonite to backup to the cloud.
Anyway, the drive in the enclosure is just fine. I pulled it out and popped it into SATA to USB which works great except for the fact the drive is formatted as XFS. It's a typical Linux file system which predictably isn't recognized by Mac OS or Windows. Luckily there is a great free program called Linux Reader from Disk Internals that you can run on Windows which will allow you read only access to the partitions. I've got it setup on an old Windows laptop now and it is busily copying away.
This is the second time a WD enclosure has failed on me. Why, oh why, do I do this to myself. I guess it is because I'm cheap and the WD products offer a good price/functionality ratio. However, what they do not offer is reliability. This is a good lesson for us all not to skimp on quality when you have an important piece of your home setup.
I guess I should explain that I use the MyBook Live to host my iTunes library. As a result it is just packed with shows for my daughter and I really need to get this fixed before she wants to watch Beverly Hills Chihuahua again. As well this drive is setup to be the receptacle of the Time Machine backup on the Mac. I get antsy if my backup isn't running daily even though I also run Carbonite to backup to the cloud.
Anyway, the drive in the enclosure is just fine. I pulled it out and popped it into SATA to USB which works great except for the fact the drive is formatted as XFS. It's a typical Linux file system which predictably isn't recognized by Mac OS or Windows. Luckily there is a great free program called Linux Reader from Disk Internals that you can run on Windows which will allow you read only access to the partitions. I've got it setup on an old Windows laptop now and it is busily copying away.
Friday, November 2, 2012
Support Canadian Comic Book Creators
Extremely talented Canadian comic book creators have put together an IndiGoGo campaign to self publish a 100 page hard cover anthology of comic stories. They are looking to raise $20,000 by November the 5th and are currently just shy of $13,000. If you love comics then this will be a great anthology to pick up. There are perks levels from $5 to $300 so they are making it so easy for you to find a contribution level you are comfortable with.
Who are they? Well there is...
Adrian Alphona
Andy Belanger
J. Bone
Jack Briglio
Scott Chantler
Tom Fowler
Agnes Garbowska she drew one of my childhood favourites Spider-Ham but I can't get the image to load.
Faith Erin Hicks I recently read all her books.
Tim Levins
Ramon Perez
Ron Salas
Jay Stephens
J. Torres
Howard Wong
I will add images for the rest of these folks as I have time but really you shouldn't need anymore convincing. Go contribute!
Who are they? Well there is...
Adrian Alphona
Andy Belanger
J. Bone
Jack Briglio
Scott Chantler
Tom Fowler
Agnes Garbowska she drew one of my childhood favourites Spider-Ham but I can't get the image to load.
Faith Erin Hicks I recently read all her books.
Tim Levins
Ramon Perez
Ron Salas
Jay Stephens
J. Torres
Howard Wong
I will add images for the rest of these folks as I have time but really you shouldn't need anymore convincing. Go contribute!
Subscribe to:
Posts (Atom)