Category Archives: playbook

Blackberry PlayBook

I’ve had my PlayBook for a week and although my usage hasn’t been high due to FITC obligation (read: drinking & shenanigans), I have some reactions.

1. Size

Although I will never stop making juvenile comments when someone says “7 inches is enough.” I do think the PlayBook has an adequately-sized screen. *snicker*. I don’t own any other tablet, so I wasn’t as prepared for the your hands will not be as close together so typing on screen with your thumbs will be unlike your phone thing. Mind you, that’s a small thing and I doubt I am meant to actually do that much typing.

2. Casing

Ironically, this is one of my very few complaints. Because the edges aren’t bevelled, the exterior of the PlayBook feels almost sharp. It’s not terribly comfortable to hold for long periods. Since it’s a tablet, not being comfortable to hold may be an issue.

3. Usability

Double space, period. Do you know how used to that I am now? Tap space twice and it ends my sentence. I miss that. A lot.

4. Bezel Controls

Being able to switch apps by flicking from the outside of the screen in is pretty cool. Makes it a little difficult to program an app that potentially reacts to a lot of swiping. I see a lot of frustrated game developers doing the funky chicken when they realize that they’ll need to not have any activity within 100 pixels of the borders for fear that user will swipe themselves out of the game. Other than that, I really like it. And swiping up minimizes the app and swiping down can bring down that app’s general navigation. Pretty nice, indeed.

5. General, Quick Reaction

I really like my PlayBook. My app is approved and plays really well on it. It’s free, so if you have a PlayBook, download it and review it. *koff* moviesinhaiku!.

It’s powerful hardware. You can open a ton of apps and switcheroo them without sacrificing performance. The mini HDMI and presentation mode is pretty badass too. Sound is good, not too tinny from the installed speakers. The camera will record 720p video and I have used it a couple of times now as a video-blogging tool for my documentary. I guarantee I’ll be hitting it a lot over the next few years. I have a couple of other apps in mind, so I’ll likely make more.

If I can do a shout out: Rajiv from RIM was most excellent in helping me navigate the debug token installation thing. If you’re a user and not a developer, pretend like I didn’t mention anything at all. But as a developer *shakes fist*.

My PlayBook Experience

As I posted before, I attended the PlayBook introduction in Toronto.

Free PlayBook? Yes, please!

The main draw of course is the offer of a free PlayBook for an approved app in the BlackBerry app store for the PlayBook.

As it so happens, I also have been pursuing a personal project for the past year, Moviesinhaiku. This seemed like a good fit for a tablet app.

There are a lot of great resources on how to get started with developing for the PlayBook, so I won’t touch on that too much. What I’d like is to go over some features of my specific app and some decision-making involved in making those features work.

Without further ado.
(note: all images resized from original screen size)

What should a Movieinhaiku look like?

The first problem I wanted solved was how I wanted to display my haikus. I didn’t want anything too elaborate because;
A) I couldn’t guarantee performance
B) They’re haikus about movies. How elaborate do they need to be?

I have been keeping an updated XML file handy on the moviesinhaiku test site. Each haiku looks like this;

<haiku answer='True Grit'>
<imdb year='2010'>tt1403865</imdb>
<haiku_text><![CDATA[A man with true grit.<br/>Girl hires. Catch father's killer.<br/>Vengeance costs in time.]]></haiku_text>
</haiku>

The Moviesinhaiku logo is essentially two rectangles, black stacked on white. Made sense to simply continue that for the haiku “cards”

I don’t want to discount the ease or difficulty in using XML and Flash. I’ve been using the exact same class for a long time now MainImporter for importing pretty much everything. But I’m not really going to get into parsing XML.

One thing I decided to try that was new to me was use the Dictionary class. It seemed like a great tool to store all my haikus. I’ll be completely honest in admitting that I don’t get it entirely, but it’s primarily a set of keys. So I created my Dictionary and pushed in all the haikus created so I could reference them whenever I wanted.


haikuDict = new Dictionary;
for each(var haikuXMLnode:XML in haikuXML..haiku){
   var haiku:Haiku = new Haiku(haikuXMLnode);
   haikuHolder.addHaiku(haiku);
   haikuDict[haikuCount] = haiku;
   haikuCount++;
}

Haikus on screen

Once I had my haikus in the dictionary, I wanted to scatter them around. The easiest way I could think to do that was to use the Orbit class I’d written for the Particle book for GalaxyGoo. Throw a little random into the mix and you get a nice, little random orbital display.

Third party services

I wanted to try and give more information than just the title of the movie so, as can be seen in the XML node above, I copied the IMDB identifier for each movie. A friend of mine did some quick searching and located The MovieDB. I applied for an API key and got to work. I set up two classes to get the information from teh interwebz to my app.

The first class I called APIcontrol and in essence just holds my API information; key, listing url and some static constants. The API results can be returned in XML and JSON. I’d never used JSON before and once again decided I’d be better off learning something new than just staying in my comfort zone. The first thing I needed was the as3corelib from Mike Chambers housed at github.
Specifically, I needed one class for one function call

import com.adobe.serialization.json.JSON;
var jsonObj:Object = JSON.decode(event.target.data);

Once again, how to work with JSON is all over the lazy web so I’m not going to get into it. It’s pretty easy and I think I’ll use it more.

The second class I wrote was called ImdbWindow. Technically, I should have called it TmdbWindow, I suppose. However, I didn’t and don’t like living in regret. ImdbWindow grabbed all the information from APIcontrol and created a window using; the movie poster, the synopsis, the array of genres and the release date. Example below. One thing that was very important I’d taken from a post by Christian Cantrell about scaling your images for mobile. Please read it as it’s important.

Filtering

Something I thought really mattered when I started was filtering. I liked the idea of the person using the device being able to view the haikus based on release or by title. In addition, I wanted to be able to give that same person the ability to search by text. There are a few things to consider when doing this so let’s see if I can break it down.

1. When alphabetizing, remember that a lot of movies start with “The”, “A” and “An”. When I store my haikus, each one stores an alphabetical version of their title. Writing a getter/setter for an alphabetic version of the title is as simple as;

public function set alphabetic($str:String):void{
   var tmpStr:String;
   if
($str.toLowerCase().indexOf("the ")==0){
      tmpStr = $str.substr(4,$str.length);
   }else if($str.toLowerCase().indexOf("a ")==0){
      tmpStr = $str.substr(2,$str.length);
   }else if($str.toLowerCase().indexOf("an ")==0){
      tmpStr = $str.substr(3,$str.length);
   }else{
      tmpStr = $str;
   }
   haikuAlphaTitle = tmpStr;
}

As you can see, I do a substring check at the beginning of the title for my little culprits and create a string that has those removed. This way, when I’m alphabetizing, they’ll make sense. The getter, of course, is just a getter, returning the alphabetic title.

Now how does one alphabetically sort? Using arrays and the sortOn method, of course!

I have two separate sortOn functions; Year and Title.

private function sortOnYear(firstHaiku:Haiku, secondHaiku:Haiku):Number {
   var aYear:Number = firstHaiku.year;
   var bYear:Number = secondHaiku.year;
   if(aYear > bYear) {
      return 1;
   } else if(aYear < bYear) {
      return -1;
   } else {
      return 0;
   }
}
private function sortOnTitle(firstHaiku:Haiku, secondHaiku:Haiku):Number {
   var aAlphabet:String = firstHaiku.alphabetic;
   var bAlphabet:String = secondHaiku.alphabetic;
   if(aAlphabet > bAlphabet) {
      return 1;
   } else if(aAlphabet < bAlphabet) {
      return -1;
   } else {
      return 0;
   }
}


(sorting in action)

As can be seen from the above image, the search by title is also active. This ended up being pretty easy. Since all the haikus are in the Dictionary, I was able to just set up an onChanged event with the textField. Then I compare the searched term with the haiku’s title. If there’s a match, I add the haiku to the displayList

private function onSearchHandler(evt:Event):void{
   while (mainHolder.numChildren) {mainHolder.removeChildAt(0); }
   haikuHolder = new HaikuLayout;
   haikuHolder.addEventListener(HaikuEvents.ADD_SCROLLBAR,addScroll);
   haikuHolder.startXposition = stage.stageWidth*.5;
   haikuHolder.startYposition = stage.stageHeight*.5;
   for (var key:Object in haikuDict) {
      // iterates through each object key
      var haiku:Haiku = haikuDict[key] as Haiku;
      var titleStr:String = haiku.title.toLowerCase();
      if(titleStr.indexOf(evt.target.searchStr) != -1){
         haikuHolder.addHaiku(haiku);
      }
   }
   haikuHolder.initLayout();
   mainHolder.addChild(haikuHolder);
}

Of course, no matter how close I thought I got to finishing, something would intercede and remind me that the worst thing you can be is your own boss. Especially when it’s a personal project. More especially when you’re not too busy with client work. Most especially when you like a challenge.

Just as I figured I was nearly done, Matt Fabb tweeted;

@wheniwas19 Looks like a v1 app to me! That said feature request: hide the title. ‘Cause it’s fun guessing the movie just from the haiku.

Which should surprise no-one that knows me I glommed on to like a barnacle to a ship (weird metaphor). So i felt like Matt was right, people should be able to treat this like a quiz! Well, that doesn’t bring me entirely back to the drawing board. So I decided to give it a shot.

Building a quiz

First things first, let people type in their answer or give them multiple choice? According to my friend, Drew, “Don’t give anyone too much to input. Your margin for error increases. Which is true. Unless I wanted to create a massive dictionary full of spelling options, I’d be shooting myself in the foot. So multiple choice it is. Simple enough, I suppose.

My solution is about as smart as I get. I have a list of titles provided by the xml. A huge list of titles. Why not pick four titles at random from the list and use 3 of them as alternates in the multiple choice. How would one do that, you ask? Lucky for you, I know how one does that.

Random numbers that don’t repeat

For some reason, for as long as I can recall, I have been building little functions that make non-repeating random number generators. I have my little RandomRange class so I add this function to it.

public static function nonRepeat(max:Number, num:Number):Array{
   var tempArray:Array = [];
   for (var i:int = 0; i < max && num > 0; ++i) {
      if (Math.floor(Math.random() * max - i) < num) {
         tempArray.push(i + 1);
         num--;
      }
   }
   return tempArray;
}

This is easily called using var randomArr:Array = RandomRange.nonRepeat(titles.length,4);

So here I have an array with four random titles. Now I want to make sure none of the four titles are the answer. Don’t want to double up, right?

var answerCount:Number = 0;
var answersArrArray = [];
for(var i:int=0;i < randomArr.length;i++){
   if(titles[randomArr[i]] != answerTitleStr){
       answersArr[answerCount] = new QuizAnswer(titles[randomArr[i]],answerWidthNum);
      answerCount++;
   }
}

Now I definitely have an array of four answers that are randomly pulled from all the titles in my xml and are not the answer. But I do, absolutely want the correct answer in the four. So I pop it into a random position in the answersArr array.

var realAnswer:QuizAnswer = new QuizAnswer(answerTitleStr);
answersArr[RandomRange.retrieveRandom(0,3)] = realAnswer;

Then all I need to do is build my quiz. As you noticed, I have a class called QuizAnswer that’s basically a textField with a black background that dispatches an event when clicked. If it’s the wrong answer, the textField is dimmed and the MouseEvent is removed. Process of elimination.

Once the quiz is answered, the process of pinging the Movie DB occurs again. I added in the option of seeing the haikus with or without titles and that’s how the whole app loads.

It ain’t over ’til it’s over

Just as I thought I was out, Matt Fabb pulled me back in with his innocuous question:

@wheniwas19 I don’t want to add more work for you, but I assume MoviesInHaiku app links to your Etsy shop?

Long story short, yes. I did. After Matt asked, but whatever.

So that’s it. Maybe not the most informative PlayBook post, but there is some thought to what I do. I have submitted the app at a cost of $1.99 to perhaps recoup some of the cost of building one of these things entirely on my own and on my own dime. I hope it’s approved, I hope people buy it and I hope they like it. I’m sure if they don’t I’ll hear about it.

I (Almost) Met the PlayBook

On December 14th, I attended the “Meet the Blackberry Playbook” event here in Toronto. Sponsored by Adobe and RIM, expectations were high we’d be seeing something awesome.

My tweets went from the approved hashtag #meettheplaybook to #almostmettheplaybook as the obvious scenario of actually touching a PlayBook went from “woohoo” to “uh oh”. I am truly excited about the PlayBook, I really am. I’d be more excited if I could have held one in my hand. There weren’t that many of us, they could have walked around and let each swipe our finger across the screen… followed by hand sanitizer…

Let’s go by the official PlayBook page and what the reviewers so far have to say:

The momentum certainly seems to be there.
It looks astoundingly nice.
It looks sleek, it seems powerful.

I totally agree. It does seem and look like a pretty awesome device. Until you touch it and try it, that’s all it is. Theory.

However, if you want to get your hands on one, write an app for the BlackBerry appworld and be approved. That’s a pretty great caveat, I’d say.

In other words, devs that are bitching that they can’t try out the PlayBook, "Put up or shut up." It’s not like this is the first time a dev has been asked to write something based on blind faith. iOS Packager, anyone?