Google+ Badge

Tuesday, March 29, 2011

Running my app on Honeycomb - why these changes?

My boss bought a Xoom tablet. Pretty sweet device. I have played with the Samsung Tablet a couple of times and I like it too. I have not played with an iPad, I have only seen them for a brief period of time. Makes me pine for one of my own but of course they sold out the WiFi only version rather quickly.

I have installed our software on the Samsung 7" tablet and it ran without a hitch. Of course that is running 2.2 and really is just a big version of a phone. I was expecting the same to happen on the Xoom but I was wrong.

I had to install the Motorola USB device driver first. No big deal. I now have a variety of USB drivers on my development box as I have installed our app on my T-Mobile Samsung Galaxy S, a Verizon phone, an HTC and some others. After that we kicked it into dev mode and moved the software across then things got ugly.

I am using a pretty simple Relative Layout View in a List Activity and two simple views (with some minor special variations) in an Expandable List View. Both looked crappy, labels on top of things, other areas to tall and some layouts just missing data / not sized properly at all.

First up I was creating the Group header view in code for the Expandable List View. I was not using DIP but a hard coded number. This is the wrong way to do Android programming. I was using sample code from the web. I had converted the Items of the Expandable list to XML so I converted this area also quickly solving that issue. I thought this area looked a little off when I ran it in the 1.6 emulator at one time. Both the 1.6 emulator and the Xoom use 160 dpi instead of the 240 dpi of my phone. I should have fixed this earlier.

Next was the labels on top of each other. Turns out the layout_below setting works differently in Honeycomb. I had this type of layout

label1:  data1
label2: data2   label3: data3

I had label2, data2, label3 and data3 using layout_below="@id/label1" which worked for label2 but maybe not for data2 and for sure not for label3 and data3. I used layout_alignBaseline instead to align data2, label3 and data3 to label2 and now it seems to look as it should on all platforms if you do the next step.

Honeycomb does not consider "" to be the same as " " when it comes to control height sizing. If you give it the empty string "" it thinks the size of the area is really small. If you give it " " (notice the SPACE in there) it will correctly calculate font sizes for the TextView. Very annoying and I really don't have a clue why they decided to do this. I understand when things are NULL vs. "" or " " but that control has a font size so I should get back metrics for the font being used not the content and "" should give same results as " " as it has for a long time on the Android platform. I had to adjust all the display items in my Map converting "" to " " as I found them. Small waste of processing time but I decided not to do an OS version check.

For the Item view in the Expandable List View I had to change from android:layout_height="wrap_content" to  android:layout_height="20sp" forcing the items to have a height otherwise they got shrunk to nothingness.

Finally I had to change the background color of my items from null to white because Honeycomb gives the items selected state and that does not paint using the backgroundDrawable I was setting via code. For the first item in the group I was drawing the top left and top right corners rounded. For the final item I was drawing the bottom left and right corners rounded. I know in XML you can set up the normal, selected etc. states but you can not do this in code. For now I have ripped out the rounding of the corners. I am going to try and put that back in tomorrow by bookending the text view group with rounded corner zones. I really liked the way it looked so I hope I can battle it back into place. Not sure why Honeycomb selects the first item in each group but it does. Could be this area would have looked crappy on a phone with a D-Pad too. I already have enough variations of the view in the res directory for my potential item types that doing more sets for each the possible corner types seems a bit overkill.

At least all of the changes I made have left things looking just fine on all the other flavors I test under but I was really surprised I had to make any changes at all. I thought 3.0 would run just like 2.x but with extra features. I will say the preview mode in Eclipse has a setting for 3.0 and it showed the layout being ugly like it is on the device. I also ran the rather slow 3.0 emulator and it matched the device too. At least you can fix things without having access to the physical hardware.

I also find it kind of annoying that the iPad got a ton of press when it sold out quickly but you did not see the same press on the Xoom. Apple is a master and getting their name in the press. Android Tablet is not a thing like the iPad but a general name for tablets from various folks such as Motorola, Samsung, LG just to name a few. Guess it is harder to get press when that is the case. I reserver judgement on the Xoom until I have had a chance to use it more. It still appears to be a flawed device that is an update or two away from being very usable. Google appears to have pulled off their standard Beta release that may stay Beta for a year or may whip into shape with releases just weeks apart. I really hope they push updates to the Xoom quickly as it seems to be vanilla Honeycomb.

One thing I feel both tablet OS versions are missing is multiple user login. I know we use it at home on our various Windows boxes and I use it on my Macbook. I really think people will share tablet devices in the family and they need to step up and allow you to have individual background, web browser and email address settings. I don't need a "switch user" as much as I want a "log user out / log in as new user" functionality. Since Google decided to do a Tablet version of the OS they really should be the first to implement this. Apple seems to lean toward one iOS version for iPhone, iTouch and iPad which will make it a bit harder to pull this off.

Sunday, March 20, 2011

AT&T buys T-Mobile, how annoying

We used Cingular and never had any issues with them. AT&T bought Cingular and we had problem after problem with them. Constant billing issues, false charges, etc. We had to call them every month to clean something up. Hated their customer service too.

We finally said the hell with it and paid the fee to get out of our contract. We switched to T-Mobile as they had much better rates and we went to a no contract plan. We have had pretty good luck with T-Mobile. The coverage can be a bit spotty and you will drop you call a few blocks from our house coming in from the West. The price is good and we like the unlimited text and web. A lot of people my wife talks to are on T-Mobile so we get to talk to them for free. So far we have had no issues with custom service either, they have always been very helpful.

Now AT&T comes along and will probably screw this all up again. I am not looking forward to the buy out at all. I cringe at what will happen to our billing. I am sure the rates will go up. I hope we get better coverage and less dropped calls but I am sure there will be so much more pain.

Thursday, March 10, 2011

Owning a tablet - is it in your future?

I have noticed a couple of things since getting an Android phone. First off I search for stuff on the internet a lot more. This is mostly due to easy access. I was sitting in the car waiting on my son to come out from his clarinet lesson and I spent most of the time on the web looking for birthday presents for my other son. As I found something interesting I did a long press, Share, Email sequence to send it to my wife to discuss later. Worked like a charm.

I do crossword puzzles at home nearly every night. Something you can pick up, work on for a bit while waiting on some aspect of food to cook, put down and come back to later. I will look up answers on the web to obscure things like "author of book {book name here}". Personally I am not a fan of those types of clues but they do turn up often in the more difficult puzzles. Phone works pretty good for that even though I long for a keyboard.

In the car the kids may ask a question and we will look something up. At night while watching things on TV I might want to check out DZone, SlashDot or some other tech site. Maybe I am researching something or looking up information on a home repair. I can do it on my phone in the living room as most of it is content reading. Nothing to fire up, phone is already on so pretty much instant access. Maybe I will switch to a game for a few minutes or check out LOL cats as my son is brushing his teeth getting ready for bed showing him the funny ones. Nice way to unwind the night.

A few friends and neighbors now have tablets. At first I really had no desire to own one. First I don't think I could bring myself to buy something from Apple as they annoy me and second there is the cost. Of course the more both my wife and I use our phones the more I can see a tablet being really handy. My wife really likes to read, text and email at night in bed. I tend to fall asleep well before she does. Laptops are a pain, tablets seem to be about the right form factor.

I tend to be a cheap bastard so I am not looking at the Xoom at this point. I also realize the truly cheap ones will be super crap and most will not have access to the Android Market which is a must. Finally I really want it for in the house so I want WiFi only as I don't want to pay for another data plan. I would love to share my phone for 3G access to use on the road though. I could see it being used by the whole family for a number of activities. Could be one of those things we fight over enough that we end up picking up another one. Kind of like the DVR, once you have one you pretty much end up with more of them.

Just doesn't seem like the Android tablet market has quite shaken out. I like the size of the Samsung Tablet, the 7" size seems to be a good hand size especially for eBook reading. 10" appears to be a bit big but I have not used one enough to really know. I think we are going to get an iPad 2 at work and since I will be the lead developer on that I should get a good chance to check it out.

I also hate to be behind the technology curve by too much. The minute you buy one you are screwed. Never know if they will update to the next Android version. Best to get one with a version you can live with. Is 2.1 or 2.2 enough on a tablet? Will I drool over 3.0 and the dual processor speed? If it really is for web browsing and email then the older version are more than adequate. I will play games on it and newer games might not work on the older stuff which would really stink.

Don't think now is the time to buy. Let more come out, let some go on sale, let the rules change so a device that does not have phone support is still allowed full Android Market access. Check out who is willing to update OS versions and who abandons you once the check clears.

Yesterday I install the app I am writing on a Samsung Tablet owned by our QA lead and I got a chance to play with it for a bit. The screen is not as nice as my phone, not a big surprise as that would be a really big expense, and the glare of the office fluorescents does not help but it seems like a nice tablet. Excellent size, fast enough and familiar as it is same OS version I use. Wanted to see Angry Birds running on it out of curiosity but that was not to be. He got a deal on it at Costco and is really happy with it.

Best just bide my time...

Friday, March 4, 2011

More fun with mobile development

My quest to get both the iPhone and the Android  applications in sync and released continues. Of course I find more differences every day.

I have set up the Android SDK and emulator for the BA on the project. This has been a great help. She can test the program without a physical device and can grab screen shots for documentation. It has not been great in that the emulator snapshot functionality has bitten us repeatedly.

Why use snapshot? If you don't it takes a long time for the emulator to fire up. Not very friendly when someone stops by for a quick demo. I think the best settings are as follows:

  • Tell the virtual device you want to use snapshots on its edit screen or when initially created
  • Start emulator and tell it to "save to snapshot" on exit
  • Once it starts turn off Japanese keyboard stuff (not sure why this is on by default always)
  • Install your APK files via adb
  • Shut down emulator
  • Start emulator, select "Launch from snapshot" and turn off "Save to snapshot"

If you continually have it save to snap shot it will corrupt the snapshot at some point. This has happened to me repeatedly. The second bit of fun, when you delete a device it does NOT delete the snapshot. This means if you delete the device then create a new one with same name you get the old corrupted snapshot to kick in. You can manually delete them in the {user dir}\.android directory. The AVD manager should really take care of this. This does mean when I update the APK I need to get a new save snapshot after I install it. Means I can't automate that process which stinks.

I added a menu to the Android app with and About and Logout buttons. Very easy to do and I love having access to a menu button always on the phone. It also makes it easy when you are helping someone with their device - "Hit the menu button" is easy but "Find the menu somewhere on the screen or get out of the app and go all the way back to Settings to see if there are settings for the app you just closed somewhere in there" is not as friendly.

On the iPhone side you are on your own when it comes to coding. I decided to add a button to the title bar off to the right. On the iPhone the left side is used for the "back" button, the middle for the name of the current view. Makes more sense to me to have the back and menu buttons off the screen the way the Android did it but on the iPhone you have a bit of text telling you where "back" will go. Of course you can do the same thing on the Android if you so choose, Apple just does not give you a choice, one button to rule them all! Reminds me of their battle to avoid two button mice for the longest time.

What should logout do? Turns out closing an app on the iPhone will get you rejected from the app store so that is not an option. Returning you to the login screen appears to be the way to go. On the iPhone the user MUST be the one to press the HOME button to close an app. Of course that does not really close the app anymore depending on what device you use but we better not use the fragmentation word as it only applies to the Android right?

I spent a good deal of time this morning on Stack Overflow to find this line of code:

[self.navigationController popViewControllerAnimated:NO];


When they select logout from the popup menu the view needs to close. Not that I would have figured out this line by scanning the API documentation. At least it is one line of code and not too contorted. I then added a global variable (shudder) to the main control so each view could check that and if we are in the process of logging out we also close ourselves during the view will appear processing. When we hit the Login screen it does not close but instead just clears the variable. Working like a champ during my testing.

This does bring me back to the evil "fragmentation" word. It is thrown at the Android side of things all the time due to screen resolution and other hardware differences. Yes, I have code in my app to handle these differences. No, it is not fun to write and test. Yes, I have an emulator that helps. No the emulator is not a job to work in.

What about on the Apple side? You have various OS versions with some being multitasking and others not. Just tell them to upgrade right? Wrong, some are now stuck at a revision. The second generation iTouch that I use for testing just got added to the stuck list. I already have code in place to check for multitasking in our app. I have been affected by iOS fragmentation.

The new iPad is said to be really speedy compared to the old one. I had lunch with a friend yesterday who expressed concerns with their iPad app and timing issues. Even the simulator in Xcode now lists multiple options - iPad 3.2, iPhone 4.0, iPhone 4.1, iPad 4.2 and iPhone 4.2. They just released GM of 4.3 so I will need to grab that too. The simulator runs a ton better on the Mac than the Android emulator on the PC but it also gives a false sense of speed.

Let's just kill the fragmentation rhetoric. It affects every developer no matter the platform. We have dealt with it for years. It is affecting Apple more than they care to admit. It may limit them from doing a smaller screen iPhone nano. I know not to hard code to screen resolutions but I do see sample code that does on various websites when looking up iOS issues.

You can tell me tablets and phones are different beasts and I will agree. You should not just scale up your phone interface for the tablet, it should become a new fuller featured interface instead. That is one of the early bitches about the Xoom, not enough native applications. Even tossing them into two buckets you still have fragmentation due to iOS differences due to lack of upgrade options. I don't want to see these old devices in the landfill.

Both Apple and Android have fragmentation. It should no longer be listed as a Pro or Con when deciding with camp to join. End of rant.