Over the past few days I’ve been attempting to apply my proof-of-concept to the MM Subsystems mode. There are currently a few roadblocks that mostly involve performing programmatic Android Layout. In general, my layouts are created with xml before any java code runs on the phone. (This is technically a lie, as the java-based Android OS interprets my xml for me; suffice it to say, it runs before any of my java code does).
This doesn’t work for subsystems because we require the ability to size the bars at runtime. What we basically want is to say:
find the biggest number in the results of the subsystems cgi query;
foreach ( bar in the graph )
bar.width = (this bar's number / biggest bar's number) * screen width
We can query the size of the screen, which is nice (and was a concern given the imminent release of phones of varying resolution). We can get the result names / numbers to write into the bars (which is easy because it is the same CGI queries I’ve been doing). We can draw text on top of a bar (which is what I thought would be the hard part).
As stupid as it sounds, what is stopping me currently is that I can’t figure out how to simultaneously size a bar at run-time and put it where I want it on the screen. I know how to do one or the other, but not both at once. That is essentially where I’m at with things for the moment, but I hope to deliver a triumphant tutorial on programmatic android layouts sometime in the near-ish future!
Edit (6:50PM 9/19/09): Aforementioned triumphant tutorial is incoming in the next workday or two. Proof of concept is looking pretty good, but not quite good enough to warrant a post of its own yet – stay tuned!
Edit (4:40 PM 9/20/09): Proof of concept is looking good enough; I’ll tone down the color scheme for the real version, but it gets the idea across.. Check behind the Read More!