POP3: load alt / charset

pull/215/head
M66B 6 months ago
parent 5cbfebeabc
commit d71fd3d2ec

@ -6416,14 +6416,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP ||
EntityFolder.INBOX.equals(message.folderType));
popupMenu.getMenu().findItem(R.id.menu_charset)
.setEnabled(message.uid != null)
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
.setEnabled(message.uid != null ||
message.accountProtocol == EntityAccount.TYPE_POP)
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP ||
EntityFolder.INBOX.equals(message.folderType));
popupMenu.getMenu().findItem(R.id.menu_alternative)
.setTitle(message.isPlainOnly()
? R.string.title_alternative_html : R.string.title_alternative_text)
.setEnabled(message.uid != null && message.hasAlt() && !message.isEncrypted())
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
.setEnabled(message.hasAlt() && !message.isEncrypted() &&
(message.uid != null || message.accountProtocol == EntityAccount.TYPE_POP))
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP ||
EntityFolder.INBOX.equals(message.folderType));
popupMenu.insertIcons(context);

@ -2234,31 +2234,40 @@ class Core {
}
private static void onBody(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder, POP3Store istore) throws MessagingException, IOException {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean download_plain = prefs.getBoolean("download_plain", false);
boolean plain_text = jargs.optBoolean(0, download_plain);
String charset = (jargs.isNull(1) ? null : jargs.optString(1, null));
if (!EntityFolder.INBOX.equals(folder.type))
throw new IllegalArgumentException("Not INBOX");
if (message.content && message.isPlainOnly() == plain_text && charset == null)
return;
Map<EntityMessage, Message> map = findMessages(context, folder, Arrays.asList(message), istore, ifolder);
if (map.get(message) == null)
throw new IllegalArgumentException("Message not found msgid=" + message.msgid);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean download_plain = prefs.getBoolean("download_plain", false);
MessageHelper helper = new MessageHelper((MimeMessage) map.entrySet().iterator().next().getValue(), context);
MessageHelper.MessageParts parts = helper.getMessageParts();
String body = parts.getHtml(context, download_plain);
String body = parts.getHtml(context, plain_text, charset);
File file = message.getFile(context);
Helper.writeText(file, body);
String text = HtmlHelper.getFullText(body, true);
message.preview = HtmlHelper.getPreview(text);
message.language = HtmlHelper.getLanguage(context, message.subject, text);
Integer plain_only = parts.isPlainOnly();
if (plain_text)
plain_only = 1 | (plain_only == null ? 0 : plain_only & 0x80);
DB db = DB.getInstance(context);
db.message().setMessageContent(message.id,
true,
message.language,
parts.isPlainOnly(download_plain),
plain_only,
message.preview,
parts.getWarnings(message.warning));
}

Loading…
Cancel
Save