mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -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:
parent
80d99baf29
commit
168f6277da
@ -1183,16 +1183,16 @@ public class MimeUtility {
|
|||||||
// If the MIME type set by the user's mailer is application/octet-stream, try to figure
|
// 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.
|
// out whether there's a sane file type extension.
|
||||||
if (returnedType != null && !DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(returnedType)) {
|
if (returnedType != null && !DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(returnedType)) {
|
||||||
return getCorrectedMimeType(returnedType);
|
return returnedType;
|
||||||
} else if (extension != null) {
|
} else if (extension != null) {
|
||||||
for (String[] contentTypeMapEntry : MIME_TYPE_BY_EXTENSION_MAP) {
|
for (String[] contentTypeMapEntry : MIME_TYPE_BY_EXTENSION_MAP) {
|
||||||
if (contentTypeMapEntry[0].equals(extension)) {
|
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
|
* @param mimeType the MIME type
|
||||||
* @return the corrected 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) {
|
for (String[] mimeTypeMapEntry : MIME_TYPE_REPLACEMENT_MAP) {
|
||||||
if (mimeTypeMapEntry[0].equals(mimeType)) {
|
if (mimeTypeMapEntry[0].equals(mimeType)) {
|
||||||
return mimeTypeMapEntry[1];
|
return mimeTypeMapEntry[1];
|
||||||
|
@ -1010,7 +1010,7 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
if (MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(type)) {
|
if (MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(type)) {
|
||||||
type = MimeUtility.getMimeTypeByExtension(name);
|
type = MimeUtility.getMimeTypeByExtension(name);
|
||||||
}
|
}
|
||||||
return MimeUtility.getCorrectedMimeType(type);
|
return type;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -105,7 +105,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final LocalStore localStore = LocalStore.getLocalInstance(account, K9.app);
|
final LocalStore localStore = LocalStore.getLocalInstance(account, K9.app);
|
||||||
return localStore.getAttachmentType(id);
|
return MimeUtility.canonicalizeMimeType(localStore.getAttachmentType(id));
|
||||||
|
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
Log.e(K9.LOG_TAG, "Unable to retrieve LocalStore for " + account, e);
|
Log.e(K9.LOG_TAG, "Unable to retrieve LocalStore for " + account, e);
|
||||||
|
Loading…
Reference in New Issue
Block a user