Fix a fatal compiler warning when building with the latest version of the Android NDK
(security issue because a variable is used as a format string with no parameters).
Fix memento builds on android.
Fix for bug #694967 - MuPDF crashes after pressing the Back Button while it renders a specific PDF

Some async tasks were still trying to access the globals pointer, which had
been nulled during shutdown, leading to a crash.

Check for NULL and return cleanly in this case.

Possibly we should also be calling AsyncTask.get() to wait for the tasks to
finish, before nulling the global pointer?
Fix for bug #694405 - iOS Pdf Crash

If an iOS app uses too much memory, the OS asks it to free up some space.
If it doesn't do so in a timely manner, it will get a second warning before
being killed by the OS.

In other platforms, where malloc() return NULL in OOM, the store scavenger
releases memory when mallocs fail. In iOS, mallocs usually never return NULL
because the app is killed before this can happen. Therefore, we need to
initiate a scavenge from the low memory notification instead.

We evict the store to 50% of its current size when a memory warning occurs
when it is in the foreground, and 0% when a memory warning occurs whilst
it is in the background. Having said this, I didn't manage to get a background
warning to occur, presumably because we don't request background execution
Therefore, I think in practice the OS just kills the process. However, this
will be useful if we ever add background execution.
Fix bug #695132: MuPDF Library throwing sporadic exception on Android

Android sometimes calls the 'getSelectedView()' method of an AdapterView.
This can be made to happen more predicatably by enabling the Talkback
accessibility feature.

Remove the UnsupportedOperationException and just return null, as we the
ReaderView does not have the concept of a selected page.
Add annotation to fix building from Eclipse.
Fix compiler warning.
Improvement which should hopefully help with bug #693607 - MupdfActivity crash when rotating the device.

When cancelling a render async task, we now wait for it to actually finish
before continuing. The benefit of this is that we should be able to guarantee
that its Bitmap becomes eligible for GC before we continue to create any
new bitmaps.

This should hopefully help with the OOM errors seen when rotating
the device and trying to create the new bitmaps.

To prevent the UI thread from being blocked for too long while we're waiting
for the async task to finish, we use a fz_cookie and set the 'abort' flag to
request the render be stopped as soon as possible.
Ignore .DS_Store files generated by the Mac.
Fix crash when dismissing 'Cannot open document' dialog with back button, then pressing back button again.

I've also added an onCancel() handler, so that the back button only needs
to be pressed once to return to the file picker view.

Spotted while looking at bug #693719 - Attached PDF file does not display (edit)
Fix for bug #695229 - open document from byte array doesn't work, but saving to file and open from file works

Patch was supplied by gong_su@hotmail.com. Thanks!
Prevent the creation/destruction of the fz_cookies from trampling the env/clazz pointers in globals.

The env/clazz pointers are stashed in the globals structure so that they can
be accessed by callback functions in mupdf.c (such as bufferStreamSeek()).

The intention is that only one thread (i.e. the AsyncTask background thread)
reads/writes these stashed pointers. Because cookies are created/destroyed
in the main thread, we add a new version of get_globals() which doesn't trample
these pointers.
Fix for pages being repeated when running on Android Honeycomb.

Fixes bug #695191 - Mupdf Build49/armv7a & Android 3.1: cycles
through subset of pages & page scrubber

The problem here was that in Honeycomb, various bitmap operations
(including drawing via JNI) do not update the bitmap generation count.
When hardware acceleration is enabled, this means that the underlying GL
layer is not aware that the bitmap has changed, and ends up reusing old
textures.

To workaround this, we erase the bitmap before drawing the page. Erase
appears to be the only operation I could find (after pouring through the
source), which actually increments the generation count. The other option
would have been to disable hardware acceleration, but that was far less ideal.
Fix various Xcode analyzer warnings.

Most were pretty harmless, and were addressed by renaming functions to match the Core
Foundation naming conventions, but there was one actual memory leak, and some potential
uses of uninitialised data.
Add missing 'period' to files launched via 'Open In' before file extension.

Fixes bug #694711. As far as I could see, opening an XPS worked fine, the
first time. However, if the same file was opened a second time, then it
should have been saved with a number, e.g. foo(1).xps. However, the period
was ommitted, so the file wasn't recognised as an XPS.

This presumably wasn't an issue for PDF files, as PDF format is assumed
by default (I am guessing).
Fix deleting wrong file or crashing app if first file deleted.

Correct an off-by-one error in the file deletion code.
Add missing fz_var() and fix potential memory leak.
Fix some compiler warnings on Android.

Use intptr_t when casting between a jlong and a pointer to suppress errors
about different size words.

Add a 'u' suffix to unsigned values output by the cmap dump utility.
Partially revert "Add missing fz_var() and fix potential memory leak."

(Revert the fix for potential memory leak - there wasn't a potential memory
leak as the device only takes ownership of it's display list if
dev->free_user is set).

This reverts commit ada560eb015e7b2208c492d47f28da8093733c4a.
Fix #695217 - don't allow annotation of encrypted PDFs