Google+ Badge

Thursday, December 15, 2011

New ADT 16 includes Lint - very nice

Grabbed the new Android ADT version 16 and it includes Lint. I like to keep my code as clean as possible so I found this very useful. My initial warning list was 374 items which can seem a bit scary. I have knocked that down to 252 items doing some very simple things. All of the information provided by Lint is useful but not all of it is something you must fix.

I have some strings that are hard coded in my XML files. They say things like "date placeholder" and the like. I have them to help me visualize things when I am using the preview window. Actual values will be filled in at run-time. There are also a lot of "Missing contentDescription attribute on image". I might just shut this one off. This program is used by doctors. Being visually disabled pretty much means they can't do their job. I don't need to support that functionality in this project.

I was able to cleanup some "useless layout" issues. I converted single row table layouts to liner layouts. I was setting the background color and cache color hint in a lot of my XML files. It recommended using a theme instead as everything was getting painted twice - once with the them background color and then with my override color. I set up an application level theme in the manifest to solve that problem. It also forced me to define the background color in the style.xml file so I did a quick search across all XML files and updated them to use the define. I can now change the color in one place and have the entire app use it. I should have done it this way from the start but somehow cut and paste seems more fun than doing it right when you are in a hurry. We are hitting final QA cycle and I want things to be as clean as possible meaning this was a good time to fix past oversights.

I still have a couple of "children can be replaced by one and a compound drawable." items to clean up. That will involve code changes and not just XML changes as the image in font of the text changes at run-time depending on the status of the item. Makes sense to use the setCompoundDrawables instead of having two controls in a LinearLayout when the TextView already has full support for that. I will probably wait to change those for the next release as I could find subtle issues to work around since I have not used this particular functionality in a layout used for table rows.

It is highly recommended that you grab the latest ADT and see what warnings it has in store for you. Between the new Lint and the utility I wrote to scan my project for orphan resources I am feeling pretty darn good about the next release. QA has not found any issues in a few days so it looks like we will ship in the next few business days and allow our clients to enjoy all the new functionality.