If an error occurred or the user cancelled the download, the message
(toast) would be redisplayed on every rotation from there on.
This change fixes the bug (by removing the reference to the download
thread when it's finished) and encapsulates all interaction with the
download thread in DownloadHandler.
Rationale:
1) The string is competing for space with the license field.
2) It would need separate singular/plural versions to be correct.
3) It's unnecessary when the list of APKs is shown directly below.
Traceview revealed that the call to DB.getApps() was by far the
slowest part of recreating the activity, followed by getPackageInfo().
By transferring the list contents and some other fields from the old
activity object, the time needed to create the new one can be
substantially reduced.
This moves the download thread from an anonymous inner class to the
class Downloader, which isn't tied to the activity.
The state of the progress dialog is updated by polling the download
thread at regular intervals - message passing seemed to need a bunch
of synchronized methods and shared variables anyway (to ensure that
all messages reached the right activity) so it was much simpler to
just take it out. But maybe my approach is completely backward.
Change the default value of the "cacheDownloaded" preference used in
the actual code to match the default value that is specified in XML
and shown to the user.
There is no point in splitting the strings ahead of time since 1) not
all strings need to be split and 2) we currently deserialize them just
as often as we iterate over them.
Targeting an application at Cupcake triggers compatibility behaviours:
1) The permissions WRITE_EXTERNAL_STORAGE and READ_PHONE_STATE are
automatically requested.
2) Support for different screen sizes and densities is disabled.
We don't want the extra permissions, but we do need the old resolution
compatibility mode to avoid UI breakage (for now), so I'm increasing
the target version and explicitly disabling the new screen support.