Changed strings.xml to reflect the multi-repo nature of updating.
Also refactored progress events to make them more generic and
easier to nest deeply down the call stack. The ProgressListener
now just expects a ProgressListener.Event, which in addition to
statically typed type and progress info, also has an associated
Bundle which can store arbitrary data.
Polls the download server before download to see how big the file is so
that we can figur eout our progress during download. Its a bit of a hit
(about 1.5 seconds on my connection), but I think most people would be
willing to take a small hit to get accurate percentage measurements.
I also spend a small amount of time (~1.5 seconds) asking how big the
file is before we download it, so that we can give an accurate
progress measurement. The same can be said for peeking into the
XML file before we pass it to the SAX parser, by just iterating
over every line looking for "<application" and counting that. It
is not perfect, and it takes about 3 seconds for 600 apps on my
crappy emulator, but the progress makes much more sense.
Refactored helper loops as per Andrew's suggestions.
Close file reader correctly.
See http://stackoverflow.com/a/6495399.
I thought that I could just wrap
API dependent code in an if statement, ant it would only have a problem
if it tried to execute a particular function at runtime. However when
testing on a 1.6 emulator, I was getting "VerifyErrors" which as the
link above suggest, are because it is verifying every statement in a
class. Refactoring out to another class solves this because it only
verifies classes which are loaded at runtime.
Also added utility method to make checking a bit easier,
and removed reference to SDK from DB (it mentioned in the
comments that SDK_INT was only available in v5, but the
Android docs say it was introduced in v4. Because FDroid
now depends on the Android support library, which in turn
depends on v4, it sould be okay to depen on this.
As this was my first experience with fragments, I didn't respect
their lifecycle properly. I think this has solved the issue I was
having, where recreating the app list fragments after it was destroid
by Android caused them to stuff up.
The "update" icon was a "+" (add icon) which looked a bit weird, so a
quick search of other UI's shows that the "refresh" icon is used for
"update". The official Android reference docs say to copy icons that
aren't part of the android.R.drawable.* constants into your own
drawable-* folders, so I've done that here. The icons are from android
SDK version 17.
This is only done if the device api version is >= 11, and if there is
room in the action bar. I added the funcitonality in a new class
CompatabilityUtils because there may be other things for which this is
desirable.