My most recent Caltroid update added map view with two location listeners: one coarse (=network) and one fine (=GPS) location listener. Or so I thought. Even though I was calling
LocationManager.removeUpdates() for both location listeners, I could still see the GPS icon active at the top, and
logcat showed GPS activity still going on. Users were reporting drained batteries. Not good.
It took me a few false starts until it occurred to me that I was also using MyLocationOverlay to automatically put the user’s location on the map. Well, this obviously requires location updates. I had somehow falsely assumed that as soon as the map view went away,
MyLocationOverlay would stop listening to location updates. That is not the case. You must explicitly call
MyLocationOverlay.enableMyLocation() to start updates, and
MyLocationOverlay.disableMyLocation() to stop updates.
After figuring this out the fix was easy. In my map view’s
onResume() I request location updates for my two location listeners and enable
MyLocationOverlay, and in
onPause() I do the opposite. No more drained batteries!
My latest update to Caltroid added two notable new features: the next available train is highlighted and scrolled into view automatically, and the simple locate function was replaced with a custom Google Map view. The map has Caltrain stations as an overlay, and the map starts out centered and zoomed so that all stations should be visible. While the map is active, it will update the users current position (using GPS and/or network location), and showing the nearest Caltrain station (as the crow flies). It is possible to select this station as the starting station from the map. Additionally, it is possible to tap the directions button on the map to get driving directions to the nearest station.
Working on the map feature was a pleasure now that I actually have an Android device.
If you look at the map view carefully, you will notice the text is written in transparent grey boxes with rounded corners. A stackoverflow question showed me how to do this with custom shape resource. I also based the map overlay largely on this blog post.
I had agonized for the longest time about how to get highlighting for the the list view. Then I stumbled into a couple of stackoverflow questions that showed me the way. In the end the best example I found was the List14 sample in Android API demos. I just need to call
convertView.setBackgroundDrawable() with the right drawable, and make sure to add the following attribute for the list view:
Not a big update to Caltroid at this time, but I wanted to get out the release because Caltroid now works in 320×240 resolution (QVGA), and there are even devices out with that resolution, like the HTC Tattoo. Of course bigger screens will work as well (I’m looking at you, Verizon Droid). The other minor user visible change is that when you locate the nearest station with GPS, the destination station will stay the same whenever possible.
Under the hood I fixed the spaghetti layout into pretty clean
RelativeLayout affair, except for the red strip container which is
LinearLayout so I could use layout weight to size the departure and destination stations the same. Apparently this can be a performance hit, but it is probably overall faster than it used to be. (Yeah, bad me, I didn’t measure.)
Figuring out how to make an apk that would work in all SDK versions took some time as well. I ended up creating
layout-land-320x240 directories to put in the QVGA specific changes needed. I should change to
layout-small instead, but for some reason I could not get this to work. I also added
AndroidManifest.xml and built with 1.6 SDK.
Final change in place is that I exported using the wizard in the Eclipse plugin, which should zipalign the apk and make the app use less memory.
Oh, I should note that Caltroid passed 100 users last month. Thanks to everyone who purchased it, and made it the best rated Caltrain schedule application for Android!
Caltrain updated schedules today, August 31, 2009. I released updated versions of my Caltrain schedule applications last night, so this is a little delayed notice.
My first application is CaltrainPy, which started out as a Python app for my phone, but it did not work so great on the phone after all, at least on Windows Mobile. It is fine for desktop use, though. I added schedule scraping functionality later to support the next two applications. Fully open source and all that.
CaltrainJS is a web version, optimized for Windows Mobile browser. It of course works with other browsers as well, although it hasn’t been optimized for them. CaltrainJS is free to use, but not really open source.
The last and most fully featured one is the Android port, Caltroid, which is a commercial version. I’ve added a little Google Comments gadget on the Caltroid homepage in the hopes that people would find this an easier way to communicate with me on what new features they’d want, what is broken and so on. The Android Market comment system doesn’t let me respond to comments in any sane manner, but the Comments gadget does. The gadget isn’t perfect, but hopefully better than nothing. This is also first time I am testing out Google Gadgets, so time will tell if I’ll keep using them.
The only application to gain small new features is the Python version, which basically just got some properties to identify which schedule it embeds and what schedule date it was confirmed to be able to process. I have some additional ideas for improvements, but due to currently being somewhat sleep deprived those will have to wait a bit. But if you do have ideas, please let me know.
Since the Android Cupcake version has started rolling out to devices I went through my Android applications to see if any needed updating. While I was most concerned about UI glitches, there were none. However, Caltroid sources included use of the Google Maps API although it was not enabled in the Caltroid UI because it wasn’t fully ready yet. However, the maps API usage is different in Cupcake, and this prevented me from installing Caltroid on images running SDK 1.5 aka Cupcake. Rather than finishing the map activity, I decided to simply rip it out for now.
When I tried to upload the new version to Android Market I was greeted with the dreaded minSdkVersion error. The Android Market now requires you to specify the minimum SDK version in the manifest file. The trouble was I did include it. Luckily the workaround mentioned by many in the forums worked for me: just place the
uses-sdk element as first child of
<?xml version="1.0" encoding="utf-8"?>
I just pushed the 1.1 upgrade of Caltroid to the Android Market. The 1.1 release includes the upcoming March 2, 2009 timetable and ticket information.
While the free open source version got a few hundred downloads (as far as I can tell, since the distribution was picked up by sites I had not even informed about Caltroid’s existence) in about one and a half months, the 1.0 version on the Market got 12 happy customers during the first week. Everyone who bought it is still using it, and I heard no reports of any problems with it. Four people rated it with an average of 4.25 stars, and one person left a (positive) comment.
I hope my users will be able to upgrade without a problem. Caltroid does not use the “copy protection” scheme which seems to be causing problems for some, nor does it use a database which seems to be another problem area during upgrades.
Caltrain will update their schedules and fares on Monday, March 2, 2009. They were kind enough to provide the new information online a bit early, so I went ahead and updated my Python Caltrain schedule application and library. Simply
easy_install caltrain to get it.
If you run the application, it will now quit when you press ‘q’ or Esc. Naturally the new timetable is included in this release. Caltrain changed their HTML schedule format a bit, which broke the scraper in the previous release; the new release is now more robust in being able to get all the text inside a table cell regardless of HTML markup:
Interestingly enough I did both 0.5 and 0.5.1 releases today. Right after I released 0.5, I run caltrain again in another terminal that was using different virtualenv with the latest BeautifulSoup. It turns out BS 3.1 switched to HTMParser, which can not handle all the bad markup that SGMLParser did. The Caltrain page has this gem in it which killed HTMLParser:
A line of preprocessing took care of that.
Incidentally, I will need to update Caltroid, which is a port of CaltrainPy for Android, and the online version, which is mainly targeted at Windows Mobile before Monday. It is going to be a busy weekend.
I have been working quite a bit on Caltroid, which is my Caltrain schedules application for Android. I have added new features like automatically scrolling to show the next train, displaying zones of travel and fares, improved the performance by a factor of 10, fixed crasher bug and many other improvements too numerous to mention here. I felt it was now solid enough to call it 1.0, and after all Caltroid is over a year old now.
Caltroid 1.0 screenshot
I kept versions 0.1 through 0.3 Open Source and free to download, but I changed this for 1.0. I decided I wanted to make it easier to find the application as well as experiment with the Android Market, so I registered myself and paid the $25 registration fee. I have priced Caltroid at $1.99, which leaves me about a dollar per sale after Google takes 30% through the Market
+ 2% + $0.20 through Google Checkout. So if I get at least 25 people willing to buy it, I won’t feel like a fool for registering for the Market.
Update: Seems Google does NOT charge the usual Checkout fees on the Market, so it is just the 30%. Although several of my transactions seems to have $0.10 transaction fee instead, which is not 30% nor 2% + $.020. I have reported this to Google through some Market feedback page (couldn’t find any other contact form), but haven’t heard anything back. Basically it seems like Google is a black hole as far as trying to contact them or trying to get them to respond.