k9mail/k-9 — pull request #509 by cketti (2014-11-11 02:08:41+00:00)
Title: Open attachment improvements

The objective of this branch is to improve the success rate when opening attachments.

- We now use Android's intent resolution mechanism to find out whether the MIME type specified in the message or one inferred from the attachment's file extension matches more intent filters, i.e. more apps claim to be able to open/display the attachment.
- Some apps only support the file: scheme in their intent filters. So if the above mechanism reports no supported apps, we try again using a (dummy) file:// URI. If that resolves to an app we write the attachment to a temporary directory and create an intent using a file:// URI pointing to the temporary file. This should allow opening all attachments that previously only opened when saving them first.
- We now also append the file name to content:// URIs to allow intent filters to match by file extension
- Previously, an attachment saved to storage was automatically opened when the media scanner recognized it as supported content, e.g. an image. This functionality was added because of the fact that "Open" often didn't work. Now that it does, "Save" no longer tries to opens saved attachments.

In addition to these features a lot of the code was refactored to hopefully make it more readable.