1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Append file name to content:// URI

This allows intent filters with patterns for file extensions to match.
This commit is contained in:
cketti 2014-11-10 05:46:38 +01:00
parent 6a1905b7b7
commit dfd40659d1
2 changed files with 4 additions and 3 deletions

View File

@ -58,12 +58,13 @@ public class AttachmentProvider extends ContentProvider {
.build(); .build();
} }
public static Uri getAttachmentUriForViewing(Account account, long id, String mimeType) { public static Uri getAttachmentUriForViewing(Account account, long id, String mimeType, String filename) {
return CONTENT_URI.buildUpon() return CONTENT_URI.buildUpon()
.appendPath(account.getUuid()) .appendPath(account.getUuid())
.appendPath(Long.toString(id)) .appendPath(Long.toString(id))
.appendPath(FORMAT_VIEW) .appendPath(FORMAT_VIEW)
.appendPath(mimeType) .appendPath(mimeType)
.appendPath(filename)
.build(); .build();
} }

View File

@ -287,7 +287,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
int activitiesCount; int activitiesCount;
Uri originalMimeTypeUri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId(), Uri originalMimeTypeUri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId(),
contentType); contentType, name);
Intent originalMimeTypeIntent = createViewIntentForContentUri(contentType, originalMimeTypeUri); Intent originalMimeTypeIntent = createViewIntentForContentUri(contentType, originalMimeTypeUri);
int originalMimeTypeActivitiesCount = getResolvedIntentActivitiesCount(originalMimeTypeIntent); int originalMimeTypeActivitiesCount = getResolvedIntentActivitiesCount(originalMimeTypeIntent);
@ -297,7 +297,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
activitiesCount = originalMimeTypeActivitiesCount; activitiesCount = originalMimeTypeActivitiesCount;
} else { } else {
Uri inferredMimeTypeUri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId(), Uri inferredMimeTypeUri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId(),
inferredMimeType); inferredMimeType, name);
Intent inferredMimeTypeIntent = createViewIntentForContentUri(inferredMimeType, inferredMimeTypeUri); Intent inferredMimeTypeIntent = createViewIntentForContentUri(inferredMimeType, inferredMimeTypeUri);
int inferredMimeTypeActivitiesCount = getResolvedIntentActivitiesCount(inferredMimeTypeIntent); int inferredMimeTypeActivitiesCount = getResolvedIntentActivitiesCount(inferredMimeTypeIntent);