?

Log in

No account? Create an account
trying to learn Android and missing webOS - Greg [entries|archive|friends|userinfo]
Greg

[ website | gregstoll.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| * Homepage * Mobile apps (Windows Phone, Win8, Android, webOS) * Pictures * LJBackup * Same-sex marriage map * iTunesAnalysis * Where's lunch? ]

trying to learn Android and missing webOS [Aug. 22nd, 2011|09:53 pm]
Greg
[Tags|, , , ]
[Current Mood |angryangry]

So, here's my plan: try to port FlightPredictor to Android and Windows Phone 7. Hopefully this will lead me toward which platform I'd rather own. Note: I am definitely not abandoning webOS, but I need a new phone and since the Pre3 is only being released in Europe and the European Pre3's will work on AT&T or T-Mobile but won't get 3G service, that's not gonna work.

So! First up is Android, mostly because I can develop for it on Linux. But it's not off to a good start. I'm reading through the mounds of documentation and not getting much of anywhere.

The very first screen in FlightPredictor shows a list of flights with their status and such. So I need to define a list in the UI and each list item I want to display certain properties of the Flight object.

In Enyo (the newest webOS framework), this is pretty easy. My list item code looks like:
{kind: 'HFlexBox', name: 'downTarget', components: [
    {kind: 'VFlexBox', components: [
        {kind: 'HFlexBox', className: 'flightsList info', components: [
            {name: 'flightAirlineNameAndNum', allowHtml: true, content: ''},
            {name: 'flightSummary', allowHtml: true, className: 'summary', content: ''},
        ]},
        {kind: 'HFlexBox', name: 'cities', className: 'flightsList cities', components: [
            {name: 'flightOriginCity', allowHtml: true, content: ''},
            {allowHtml: true, content: ' to '},
            {name: 'flightDestinationCity', allowHtml: true, content: ''},
        ]},
        {kind: 'HFlexBox', name: 'times', className: 'flightsList cities', components: [
            {name: 'departureTime', allowHtml: true, content: ''},
            {allowHtml: true, content: ' - '},
            {name: 'arrivalTime', allowHtml: true, content: ''},
        ]},
    ]},
    ...
and so on, and the code to display it looks something like:
    this.$.flightAirlineNameAndNum.setContent(flight.airline.name + ' ' + flight.num + ' ');
    if (flight.category == FlightPredictor.FlightCategories.Current) {
       this.$.flightSummary.setContent(flight.summary);
       this.$.flightSummary.setClassName('summary ' + flight.summaryClass);
    }
    if (this.showCities && flight.category == FlightPredictor.FlightCategories.Current) {
       this.$.cities.setShowing(true);
       this.$.flightOriginCity.setContent(flight.originAirport.city);
       this.$.flightDestinationCity.setContent(flight.destinationAirport.city);
    } else {
       this.$.cities.setShowing(false);
    }
    ...
and so forth.

So, I thought a good first step for tonight would be getting something like this to work in Android.

First of all, the tutorial for ListView seems to assume that you want the list to take up the whole screen. (I want buttons at the bottom for adding a new flight, etc.) Digging around a little more, I found a page that says how to make the list coexist with other controls, and it says to do so I just make a ListView with id "@android:id/list". This is already a bad sign: what if I (gasp!) want two lists in a screen?

But, OK, I'll use your magic id. Some ids look like "@android:id/list" and the rest look like "@+id/flightsHeader" when I'm defining them and "@id/flightsHeader" when I'm referring to them. (why? I have no idea)

So then I have to define my Flight class, with annoying getters and setters that aren't necessary in JavaScript. After another hour of searching and getting frustrated, do I use the ArrayAdapter or a SimpleAdapter? (I'm just trying to define my flights in code - storing them in a database or whatever is for another day) ArrayAdapter lets me pass in an array of them, which I need, but it doesn't let me map the object fields to id's in the list template like SimpleAdapter does. But SimpleAdapter seems to only work on XML objects, or something?

Lists are important. I'm frustrated that the ListView tutorial is so drop-dead simple that it only touches the very simplest use case for a list (yay, a list of strings!) It looks like what I want is something like this list example except
- that's an awful lot of code
- it still doesn't show me how to set values into things in a resource file, which is supposed to be how all non-trivial views are done! Arrrrrrrrgh.

Anyway. Not a productive night. I want to stick it out and accomplish something before giving up, because that seems like the right thing to do, right?
LinkReply

Comments:
From: spchampion
2011-08-23 03:30 am (UTC)
Are you definitely a "no" on iOS?
(Reply) (Thread)
[User Picture]From: gregstoll
2011-08-23 03:33 am (UTC)
Not definitely, but probably. Partially because the opportunity for developing iOS apps is much less exciting (I specialize in apps that interact with a service, and any service worth anything already has an iOS app), partially because I don't have a Mac anymore, and partially because in a perverse way I like supporting competition and rooting for the underdog.

Is iOS what you're using these days?
(Reply) (Parent) (Thread)
From: spchampion
2011-08-23 03:37 am (UTC)
Crazy alternate idea: since you like the Javascript approach so much, skip the whole native app thing and develop for mobile web instead. It changes how you monetize, but you could either do advertisements or subscriptions. The big advantage is that you can target every mobile platform instead of just one - which means a much bigger potential audience.

Plus, tools like jQuery Mobile are dead simple. And you can do some incredible stuff with HTML5.
(Reply) (Thread)
[User Picture]From: gregstoll
2011-08-23 03:15 pm (UTC)
Ooh, I do like me some Javascript :-) But I think there are two big problems:
- Being in various app catalogs gives me major discoverability. If you have an existing brand then you have a decent shot of people coming to your website naturally, but I have no brand :-)
- A lot of the features that I think add a lot of value require using an API. The biggest example is notifications, or getting the app to wake up at a specific time - pretty sure there's no way to do this with just a web app.

That's an interesting idea though...
(Reply) (Parent) (Thread)