Try to handle IMAP/POP mime types better
* When we get a "generic" type, try to infer a better one from the filename extension (as Exchange already does) * Also, remove unused method Bug: 6713335 Change-Id: I540a92aabd13bc1d30ce1838129a86f5eaf3564e
This commit is contained in:
parent
1d229f54bf
commit
9218bd8c88
@ -238,23 +238,6 @@ public class AttachmentUtilities {
|
||||
return resultType.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mime-type for a {@link Uri}.
|
||||
* - Use {@link ContentResolver#getType} for a content: URI.
|
||||
* - Use {@link #inferMimeType} for a file: URI.
|
||||
* - Otherwise throw {@link IllegalArgumentException}.
|
||||
*/
|
||||
public static String inferMimeTypeForUri(Context context, Uri uri) {
|
||||
final String scheme = uri.getScheme();
|
||||
if ("content".equals(scheme)) {
|
||||
return context.getContentResolver().getType(uri);
|
||||
} else if ("file".equals(scheme)) {
|
||||
return inferMimeType(uri.getLastPathSegment(), "");
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and return filename's extension, converted to lower case, and not including the "."
|
||||
*
|
||||
|
@ -213,8 +213,11 @@ public class LegacyConversions {
|
||||
String[] partIds = part.getHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA);
|
||||
String partId = partIds != null ? partIds[0] : null;
|
||||
|
||||
// Run the mime type through inferMimeType in case we have something generic and can do
|
||||
// better using the filename extension
|
||||
String mimeType = AttachmentUtilities.inferMimeType(name, part.getMimeType());
|
||||
localAttachment.mMimeType = mimeType;
|
||||
localAttachment.mFileName = name;
|
||||
localAttachment.mMimeType = part.getMimeType();
|
||||
localAttachment.mSize = size; // May be reset below if file handled
|
||||
localAttachment.mContentId = part.getContentId();
|
||||
localAttachment.mContentUri = null; // Will be rewritten by saveAttachmentBody
|
||||
|
Loading…
Reference in New Issue
Block a user