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

Mime type rewriting must be done only when an attachment is viewed. Therefore, removed conflicting references to rewriting code from LocalStore.

This commit is contained in:
Apoorv Khatreja 2011-03-25 05:25:10 +08:00 committed by cketti
parent 80d99baf29
commit 168f6277da
3 changed files with 6 additions and 6 deletions

View File

@ -1183,16 +1183,16 @@ public class MimeUtility {
// If the MIME type set by the user's mailer is application/octet-stream, try to figure
// out whether there's a sane file type extension.
if (returnedType != null && !DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(returnedType)) {
return getCorrectedMimeType(returnedType);
return returnedType;
} else if (extension != null) {
for (String[] contentTypeMapEntry : MIME_TYPE_BY_EXTENSION_MAP) {
if (contentTypeMapEntry[0].equals(extension)) {
return getCorrectedMimeType(contentTypeMapEntry[1]);
return contentTypeMapEntry[1];
}
}
}
return getCorrectedMimeType(DEFAULT_ATTACHMENT_MIME_TYPE);
return DEFAULT_ATTACHMENT_MIME_TYPE;
}
/**
@ -1202,7 +1202,7 @@ public class MimeUtility {
* @param mimeType the MIME type
* @return the corrected MIME type
*/
public static String getCorrectedMimeType(String mimeType) {
public static String canonicalizeMimeType(String mimeType) {
for (String[] mimeTypeMapEntry : MIME_TYPE_REPLACEMENT_MAP) {
if (mimeTypeMapEntry[0].equals(mimeType)) {
return mimeTypeMapEntry[1];

View File

@ -1010,7 +1010,7 @@ public class LocalStore extends Store implements Serializable {
if (MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(type)) {
type = MimeUtility.getMimeTypeByExtension(name);
}
return MimeUtility.getCorrectedMimeType(type);
return type;
} finally {
if (cursor != null) {
cursor.close();

View File

@ -105,7 +105,7 @@ public class AttachmentProvider extends ContentProvider {
try {
final LocalStore localStore = LocalStore.getLocalInstance(account, K9.app);
return localStore.getAttachmentType(id);
return MimeUtility.canonicalizeMimeType(localStore.getAttachmentType(id));
} catch (MessagingException e) {
Log.e(K9.LOG_TAG, "Unable to retrieve LocalStore for " + account, e);