1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Work around broken office suites by sending an explicit mime type with files we open

This commit is contained in:
Jesse Vincent 2011-11-06 17:00:25 -05:00
parent 70dc27c481
commit 7ca72b9d0f

View File

@ -239,8 +239,10 @@ public class AttachmentView extends FrameLayout {
public void showFile() {
Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// We explicitly set the ContentType in addition to the URI because some attachment viewers (such as Polaris office 3.0.x) choke on documents without a mime type
intent.setDataAndType(uri, contentType);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
try {
mContext.startActivity(intent);
} catch (Exception e) {
@ -271,7 +273,7 @@ public class AttachmentView extends FrameLayout {
Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
if (intent.resolveActivity(mContext.getPackageManager()) == null) {
viewButton.setEnabled(false);
}