CSN jautājumi 1.1

New version up! I’ll share some technical notes here.

Mobile web dev, PhoneGap, jQuery Mobile and XUI

One feature that got requested was to include a reference of driving rules within the app. The reference is available on internet (i.e. I don’t have to scan books), as a long formatted HTML document. Formatting is bold, italic, font sizes, superscripts. For the mobile, it makes sense to keep format in HTML and use WebView to display it. But one long page is not easy to get around. So…

First, got python script running that splits the page in subpages, it uses both BeautifulSoup and regexps, whichever is easier in each case. It generates output with Mako templates.

Next, bundle the static HTML, JS and CSS in the app with PhoneGap. But, umm, phonegap.jar is big (158KB although ProGuard would probably shave some parts off). And phonegap.js is big as well at 146KB. I’m developing for mobile, I’m concerned with file sizes, kilobytes count! Scratch that, bytes count!

So I got rid of phonegap, as I didn’t really have use all the cool integration features, I just needed a WebView that loads local static content.

Next I stole some generic style rules from jQuery Mobile. Next I integrated the whole jQuery Mobile, which drags in jQuery itself too. Just to rip them out soon after. Because, again, for the little features that I needed (showing/hiding elements, handling onclick) this was definitely an overkill, dragging along IE compatibility stuff and everything. Next I picked up xui.js. Mostly because I was amused with the name and its meaning in Russian, but also because on the homepage it was described as being “super micro tiny”. At 10KB, I thought, it wasn’t all that super-micro-tiny. But it’s OK, and the library packs a (relatively) lot in those 10KB.

Yeah, and browsers these days. I’ve been out of the loop for some time, and look now, animations in CSS, gradients in CSS, nice nice nice.

The other things

Manipulating messy HTML and getting the taste of mobile web development was really the most interesting part, but there were few others.

Did the translation to Russian. Russian texts on average seem to be longer than Latvian so had to do some conditional font size tweaking. Also, they take twice the space on disk, because each character is two bytes in UTF-8! sqlite file with Latvian questions is 270KB, Russian version is 542KB for approximately the same number of questions. When compressed the difference goes down to about 30%.

I’ve fixed some bugs (one was to do with picture sizing on XHDPI devices like Galaxy Nexus. I want Galaxy Nexus. I want many things.), and am aware of some bugs still remaining.

In closing, an unrelated comment about the Go language! I haven’t written a single line of Go yet, but from the samples I’ve seen and articles I’ve read it looks like a sweet language. Low-level enough to be able to do interesting things fast–think data structures, pointers (I’m obsessed with optimizations if you haven’t noticed by now), and still feel reasonably high-level, readable and concise. I don’t have an immediate application for it, I however have a small hope that in the next IO Google annouces Go as supported on Android and releases SDK and everyone gets crazy writing impressively performant apps.

About these ads

1 Response to “CSN jautājumi 1.1”


  1. 1 Someone December 29, 2011 at 7:22 am

    Nice article! Really enjoyed reading it.

    P.S. For all the PHP developers out there – if you’re looking for an easy-to-use scraping tools, give a try to PHP Simple HTML DOM Parser (http://simplehtmldom.sourceforge.net/). I’m note sure if it’s as good as Python’s BeautifulSoup, but it certainly did save me from painful “regexping” I was so used to doing.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.

%d bloggers like this: