mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-13 06:38:05 -05:00
Fixed issue 44
. Added content-type detection using file name extension . This adds better integration with OI File Manager which implements the ACTION_GET_CONTENT intent
This commit is contained in:
parent
aa18be9c96
commit
1a64826e32
@ -848,15 +848,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
private void addAttachment(Uri uri, int size, String name) {
|
private void addAttachment(Uri uri, int size, String name) {
|
||||||
ContentResolver contentResolver = getContentResolver();
|
ContentResolver contentResolver = getContentResolver();
|
||||||
|
|
||||||
String contentType = contentResolver.getType(uri);
|
|
||||||
|
|
||||||
if (contentType == null) {
|
|
||||||
contentType = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
Attachment attachment = new Attachment();
|
Attachment attachment = new Attachment();
|
||||||
attachment.name = name;
|
attachment.name = name;
|
||||||
attachment.contentType = contentType;
|
|
||||||
attachment.size = size;
|
attachment.size = size;
|
||||||
attachment.uri = uri;
|
attachment.uri = uri;
|
||||||
|
|
||||||
@ -882,6 +875,30 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
attachment.name = uri.getLastPathSegment();
|
attachment.name = uri.getLastPathSegment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String contentType = contentResolver.getType(uri);
|
||||||
|
|
||||||
|
if (contentType == null) {
|
||||||
|
boolean found = false;
|
||||||
|
if (attachment.name!=null) {
|
||||||
|
int index = attachment.name.lastIndexOf('.');
|
||||||
|
if (index!=-1) {
|
||||||
|
String extension = attachment.name.substring(index+1).toLowerCase();
|
||||||
|
for (int i=0; i<Email.CONTENT_TYPE_BY_EXTENSION_MAP.length; i++) {
|
||||||
|
if (Email.CONTENT_TYPE_BY_EXTENSION_MAP[i][0].equals(extension)) {
|
||||||
|
contentType = Email.CONTENT_TYPE_BY_EXTENSION_MAP[i][1];
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
contentType = "application/octet-stream";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attachment.contentType = contentType;
|
||||||
|
|
||||||
View view = getLayoutInflater().inflate( R.layout.message_compose_attachment, mAttachments, false);
|
View view = getLayoutInflater().inflate( R.layout.message_compose_attachment, mAttachments, false);
|
||||||
TextView nameView = (TextView)view.findViewById(R.id.attachment_name);
|
TextView nameView = (TextView)view.findViewById(R.id.attachment_name);
|
||||||
ImageButton delete = (ImageButton)view.findViewById(R.id.attachment_delete);
|
ImageButton delete = (ImageButton)view.findViewById(R.id.attachment_delete);
|
||||||
|
Loading…
Reference in New Issue
Block a user