mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Added button to show unnamed and inline attachments
This commit is contained in:
parent
6d7f2b26b0
commit
2cb31a2fac
@ -285,6 +285,8 @@ Willkommen zum \"K-9 Mail\"-Setup. K-9 ist eine quelloffene E-Mail-Anwendung fü
|
|||||||
<string name="message_view_status_attachment_not_saved">Anhang konnte nicht auf SD-Karte gespeichert werden.</string>
|
<string name="message_view_status_attachment_not_saved">Anhang konnte nicht auf SD-Karte gespeichert werden.</string>
|
||||||
<string name="message_view_show_pictures_instructions">Wählen Sie \"Bilder anzeigen\", um eingebettete Bilder abzurufen.</string>
|
<string name="message_view_show_pictures_instructions">Wählen Sie \"Bilder anzeigen\", um eingebettete Bilder abzurufen.</string>
|
||||||
<string name="message_view_show_pictures_action">Bilder anzeigen</string>
|
<string name="message_view_show_pictures_action">Bilder anzeigen</string>
|
||||||
|
<string name="message_view_show_attachments_action">Zeige Anhänge</string>
|
||||||
|
<string name="message_view_show_more_attachments_action">Mehr…</string>
|
||||||
<string name="message_view_fetching_attachment_toast">Lade Anhang.</string>
|
<string name="message_view_fetching_attachment_toast">Lade Anhang.</string>
|
||||||
<string name="message_view_no_viewer">Es wurde kein Anzeigeprogramm für <xliff:g id="mimetype">%s</xliff:g> gefunden.</string>
|
<string name="message_view_no_viewer">Es wurde kein Anzeigeprogramm für <xliff:g id="mimetype">%s</xliff:g> gefunden.</string>
|
||||||
|
|
||||||
|
@ -2040,6 +2040,17 @@ public class MimeUtility {
|
|||||||
return DEFAULT_ATTACHMENT_MIME_TYPE;
|
return DEFAULT_ATTACHMENT_MIME_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getExtensionByMimeType(String mimeType) {
|
||||||
|
String lowerCaseMimeType = mimeType.toLowerCase(Locale.US);
|
||||||
|
for (String[] contentTypeMapEntry : MIME_TYPE_BY_EXTENSION_MAP) {
|
||||||
|
if (contentTypeMapEntry[1].equals(lowerCaseMimeType)) {
|
||||||
|
return contentTypeMapEntry[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert some wrong MIME types encountered in the wild to canonical MIME types.
|
* Convert some wrong MIME types encountered in the wild to canonical MIME types.
|
||||||
*
|
*
|
||||||
|
@ -34,6 +34,7 @@ import com.fsck.k9.helper.SizeFormatter;
|
|||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.Part;
|
import com.fsck.k9.mail.Part;
|
||||||
|
import com.fsck.k9.mail.internet.MimeHeader;
|
||||||
import com.fsck.k9.mail.internet.MimeUtility;
|
import com.fsck.k9.mail.internet.MimeUtility;
|
||||||
import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBodyPart;
|
import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBodyPart;
|
||||||
import com.fsck.k9.provider.AttachmentProvider;
|
import com.fsck.k9.provider.AttachmentProvider;
|
||||||
@ -101,7 +102,28 @@ public class AttachmentView extends FrameLayout {
|
|||||||
*/
|
*/
|
||||||
public void showFileBrowser(AttachmentView caller);
|
public void showFileBrowser(AttachmentView caller);
|
||||||
}
|
}
|
||||||
public boolean populateFromPart(Part inputPart, Message message, Account account, MessagingController controller, MessagingListener listener) {
|
|
||||||
|
/**
|
||||||
|
* Populates this view with information about the attachment.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This method also decides which attachments are displayed when the "show attachments" button
|
||||||
|
* is pressed, and which attachments are only displayed after the "show more attachments"
|
||||||
|
* button was pressed.<br>
|
||||||
|
* Inline attachments with content ID and unnamed attachments fall into the second category.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param inputPart
|
||||||
|
* @param message
|
||||||
|
* @param account
|
||||||
|
* @param controller
|
||||||
|
* @param listener
|
||||||
|
*
|
||||||
|
* @return {@code true} for a regular attachment. {@code false}, otherwise.
|
||||||
|
*/
|
||||||
|
public boolean populateFromPart(Part inputPart, Message message, Account account,
|
||||||
|
MessagingController controller, MessagingListener listener) {
|
||||||
|
boolean firstClassAttachment = true;
|
||||||
try {
|
try {
|
||||||
part = (LocalAttachmentBodyPart) inputPart;
|
part = (LocalAttachmentBodyPart) inputPart;
|
||||||
|
|
||||||
@ -112,8 +134,20 @@ public class AttachmentView extends FrameLayout {
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
|
name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return false;
|
firstClassAttachment = false;
|
||||||
|
String extension = MimeUtility.getExtensionByMimeType(contentType);
|
||||||
|
name = "noname" + ((extension != null) ? "." + extension : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inline parts with a content-id are almost certainly components of an HTML message
|
||||||
|
// not attachments. Only show them if the user pressed the button to show more
|
||||||
|
// attachments.
|
||||||
|
if (contentDisposition != null &&
|
||||||
|
MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)")
|
||||||
|
&& part.getHeader(MimeHeader.HEADER_CONTENT_ID) != null) {
|
||||||
|
firstClassAttachment = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
@ -180,7 +214,7 @@ public class AttachmentView extends FrameLayout {
|
|||||||
Log.e(K9.LOG_TAG, "error ", e);
|
Log.e(K9.LOG_TAG, "error ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return firstClassAttachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getPreviewIcon() {
|
private Bitmap getPreviewIcon() {
|
||||||
|
Loading…
Reference in New Issue
Block a user