mirror of https://github.com/M66B/FairEmail.git
Plain text only with alt content
This commit is contained in:
parent
125be871be
commit
f277f5abeb
|
@ -2170,7 +2170,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibExpanderAddress.setImageLevel(show_addresses ? 0 /* less */ : 1 /* more */);
|
||||
ibExpanderAddress.setContentDescription(context.getString(show_addresses ? R.string.title_accessibility_hide_addresses : R.string.title_accessibility_show_addresses));
|
||||
|
||||
ivPlain.setVisibility(show_addresses && message.plain_only != null && message.plain_only ? View.VISIBLE : View.GONE);
|
||||
ivPlain.setVisibility(show_addresses && message.isPlainOnly() ? View.VISIBLE : View.GONE);
|
||||
ibReceipt.setVisibility(message.receipt_request != null && message.receipt_request ? View.VISIBLE : View.GONE);
|
||||
ibReceipt.setImageTintList(ColorStateList.valueOf(message.ui_answered ? colorControlNormal : colorError));
|
||||
ivAutoSubmitted.setVisibility(show_addresses && message.auto_submitted != null && message.auto_submitted ? View.VISIBLE : View.GONE);
|
||||
|
@ -2675,7 +2675,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
.appendElement("em")
|
||||
.text(context.getString(R.string.title_truncated));
|
||||
|
||||
if (Boolean.TRUE.equals(message.plain_only)) {
|
||||
if (message.isPlainOnly()) {
|
||||
document.select("body")
|
||||
.attr("style", "margin:0; padding:0;");
|
||||
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
|
||||
|
@ -4793,7 +4793,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Document document = JsoupEx.parse(file);
|
||||
HtmlHelper.cleanup(document);
|
||||
|
||||
if (Boolean.TRUE.equals(message.plain_only) && monospaced_pre)
|
||||
if (message.isPlainOnly() && monospaced_pre)
|
||||
HtmlHelper.restorePre(document);
|
||||
HtmlHelper.guessSchemes(document);
|
||||
HtmlHelper.autoLink(document);
|
||||
|
@ -5110,7 +5110,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
EntityFolder.INBOX.equals(message.folderType));
|
||||
|
||||
popupMenu.getMenu().findItem(R.id.menu_alternative)
|
||||
.setEnabled(message.uid != null && message.plain_only != null)
|
||||
.setEnabled(message.uid != null && message.hasAlt())
|
||||
.setVisible(BuildConfig.DEBUG);
|
||||
|
||||
popupMenu.insertIcons(context);
|
||||
|
@ -5623,7 +5623,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
if (message == null)
|
||||
return null;
|
||||
|
||||
EntityOperation.queue(context, message, EntityOperation.BODY, !message.plain_only);
|
||||
EntityOperation.queue(context, message, EntityOperation.BODY, !message.isPlainOnly());
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
|
@ -6333,7 +6333,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
if (expanded) {
|
||||
if (message.receipt_request != null && message.receipt_request)
|
||||
result.add(context.getString(R.string.title_legend_receipt));
|
||||
if (message.plain_only != null && message.plain_only)
|
||||
if (message.isPlainOnly())
|
||||
result.add(context.getString(R.string.title_legend_plain_only));
|
||||
if (message.ui_browsed)
|
||||
result.add(context.getString(R.string.title_legend_browsed));
|
||||
|
|
|
@ -1937,8 +1937,7 @@ class Core {
|
|||
// Download message body
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
if (message.content &&
|
||||
Objects.equals(message.plain_only, plain_text))
|
||||
if (message.content && message.isPlainOnly() == plain_text)
|
||||
return;
|
||||
|
||||
// Get message
|
||||
|
@ -1954,10 +1953,13 @@ class Core {
|
|||
String text = HtmlHelper.getFullText(body);
|
||||
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.message().setMessageContent(message.id,
|
||||
true,
|
||||
message.language,
|
||||
plain_text || parts.isPlainOnly(),
|
||||
plain_only,
|
||||
message.preview,
|
||||
parts.getWarnings(message.warning));
|
||||
MessageClassifier.classify(message, folder, null, context);
|
||||
|
|
|
@ -788,7 +788,7 @@ public interface DaoMessage {
|
|||
" OR NOT (plain_only IS :plain_only)" +
|
||||
" OR NOT (preview IS :preview)" +
|
||||
" OR NOT (warning IS :warning))")
|
||||
int setMessageContent(long id, boolean content, String language, Boolean plain_only, String preview, String warning);
|
||||
int setMessageContent(long id, boolean content, String language, Integer plain_only, String preview, String warning);
|
||||
|
||||
@Query("UPDATE message" +
|
||||
" SET notes = :notes, notes_color = :color" +
|
||||
|
@ -812,7 +812,7 @@ public interface DaoMessage {
|
|||
int setMessageStored(long id, long stored);
|
||||
|
||||
@Query("UPDATE message SET plain_only = :plain_only WHERE id = :id AND NOT (plain_only IS :plain_only)")
|
||||
int setMessagePlainOnly(long id, boolean plain_only);
|
||||
int setMessagePlainOnly(long id, Integer plain_only);
|
||||
|
||||
@Query("UPDATE message SET encrypt = :encrypt WHERE id = :id AND NOT (encrypt IS :encrypt)")
|
||||
int setMessageEncrypt(long id, Integer encrypt);
|
||||
|
|
|
@ -181,7 +181,7 @@ public class EntityMessage implements Serializable {
|
|||
@NonNull
|
||||
public Boolean content = false;
|
||||
public String language = null; // classified
|
||||
public Boolean plain_only = null;
|
||||
public Integer plain_only = null; // 1=true; 0x80=alt
|
||||
public Boolean resend = null;
|
||||
public Integer encrypt = null;
|
||||
public Integer ui_encrypt = null;
|
||||
|
@ -257,6 +257,14 @@ public class EntityMessage implements Serializable {
|
|||
return "<" + UUID.randomUUID() + "@" + domain + '>';
|
||||
}
|
||||
|
||||
boolean isPlainOnly() {
|
||||
return (this.plain_only != null && (this.plain_only & 1) != 0);
|
||||
}
|
||||
|
||||
boolean hasAlt() {
|
||||
return (this.plain_only != null && (this.plain_only & 0x80) != 0);
|
||||
}
|
||||
|
||||
boolean replySelf(List<TupleIdentityEx> identities, long account) {
|
||||
Address[] senders = (reply == null || reply.length == 0 ? from : reply);
|
||||
if (identities != null && senders != null)
|
||||
|
|
|
@ -796,7 +796,7 @@ public class EntityRule {
|
|||
db.message().setMessageContent(reply.id,
|
||||
true,
|
||||
reply.language,
|
||||
false,
|
||||
0,
|
||||
reply.preview,
|
||||
null);
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
private long working = -1;
|
||||
private State state = State.NONE;
|
||||
private boolean show_images = false;
|
||||
private Boolean last_plain_only = null;
|
||||
private Integer last_plain_only = null;
|
||||
private List<EntityAttachment> last_attachments = null;
|
||||
private boolean saved = false;
|
||||
private String subject = null;
|
||||
|
@ -2743,7 +2743,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
return null;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
db.message().setMessagePlainOnly(id, false);
|
||||
db.message().setMessagePlainOnly(id, 0);
|
||||
|
||||
args.putInt("start", start);
|
||||
|
||||
|
@ -4269,7 +4269,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (plain_only &&
|
||||
!"resend".equals(action) &&
|
||||
!"editasnew".equals(action))
|
||||
data.draft.plain_only = true;
|
||||
data.draft.plain_only = 1;
|
||||
|
||||
if (encrypt_default || selected.encrypt_default)
|
||||
if (selected.encrypt == 0)
|
||||
|
@ -4524,8 +4524,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
data.draft.sensitivity = ref.sensitivity;
|
||||
|
||||
// Plain-only
|
||||
if (ref.plain_only != null && ref.plain_only)
|
||||
data.draft.plain_only = true;
|
||||
if (ref.isPlainOnly())
|
||||
data.draft.plain_only = 1;
|
||||
|
||||
// Encryption
|
||||
List<Address> recipients = new ArrayList<>();
|
||||
|
@ -5177,7 +5177,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
? View.VISIBLE : View.GONE);
|
||||
|
||||
tvPlainTextOnly.setVisibility(
|
||||
draft.plain_only != null && draft.plain_only && !plain_only
|
||||
draft.isPlainOnly() && !plain_only
|
||||
? View.VISIBLE : View.GONE);
|
||||
|
||||
tvNoInternet.setTag(draft.content);
|
||||
|
@ -5579,7 +5579,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
dirty = true;
|
||||
} else if (action == R.id.action_send) {
|
||||
if (draft.plain_only == null || !draft.plain_only) {
|
||||
if (!draft.isPlainOnly()) {
|
||||
// Remove unused inline images
|
||||
List<String> cids = new ArrayList<>();
|
||||
Document d = JsoupEx.parse(body);
|
||||
|
@ -6036,7 +6036,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
remind_dsn || remind_size || remind_pgp || remind_smime ||
|
||||
remind_to || remind_noreply || remind_external ||
|
||||
recipients > RECIPIENTS_WARNING ||
|
||||
(formatted && (draft.plain_only != null && draft.plain_only)) ||
|
||||
(formatted && draft.isPlainOnly()) ||
|
||||
(send_reminders &&
|
||||
(remind_extra || remind_subject || remind_text || remind_attachment))) {
|
||||
setBusy(false);
|
||||
|
@ -6982,7 +6982,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
boolean plain_only = args.getBoolean("plain_only");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
db.message().setMessagePlainOnly(id, plain_only);
|
||||
db.message().setMessagePlainOnly(id, plain_only ? 1 : 0);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -7252,7 +7252,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
tvViaTitle.setTextColor(draft.identityColor);
|
||||
tvVia.setText(draft.identityEmail);
|
||||
|
||||
cbPlainOnly.setChecked(draft.plain_only != null && draft.plain_only && !dsn);
|
||||
cbPlainOnly.setChecked(draft.isPlainOnly() && !dsn);
|
||||
cbReceipt.setChecked(draft.receipt_request != null && draft.receipt_request && !dsn);
|
||||
|
||||
int encrypt = (draft.ui_encrypt == null || dsn ? EntityMessage.ENCRYPT_NONE : draft.ui_encrypt);
|
||||
|
|
|
@ -8714,7 +8714,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
Document document = JsoupEx.parse(file);
|
||||
|
||||
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
|
||||
if (Boolean.TRUE.equals(message.plain_only) && monospaced_pre)
|
||||
if (message.isPlainOnly() && monospaced_pre)
|
||||
HtmlHelper.restorePre(document);
|
||||
|
||||
HtmlHelper.embedInlineImages(context, id, document, true);
|
||||
|
|
|
@ -1656,7 +1656,7 @@ public class Log {
|
|||
|
||||
File file = draft.getFile(context);
|
||||
Helper.writeText(file, body);
|
||||
db.message().setMessageContent(draft.id, true, null, false, null, null);
|
||||
db.message().setMessageContent(draft.id, true, null, 0, null, null);
|
||||
|
||||
attachSettings(context, draft.id, 1);
|
||||
attachAccounts(context, draft.id, 2);
|
||||
|
|
|
@ -927,7 +927,7 @@ public class MessageHelper {
|
|||
document.select("div[fairemail=reference]").removeAttr("fairemail");
|
||||
|
||||
Elements reply = document.select("div[fairemail=reply]");
|
||||
if (message.plain_only != null && message.plain_only)
|
||||
if (message.isPlainOnly())
|
||||
reply.select("strong").tagName("span");
|
||||
reply.removeAttr("fairemail");
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
if (availableAttachments == 0)
|
||||
if (message.plain_only != null && message.plain_only)
|
||||
if (message.isPlainOnly())
|
||||
imessage.setContent(plainContent, plainContentType);
|
||||
else
|
||||
imessage.setContent(altMultiPart);
|
||||
|
@ -1066,7 +1066,7 @@ public class MessageHelper {
|
|||
Multipart relatedMultiPart = new MimeMultipart("related");
|
||||
|
||||
BodyPart bodyPart;
|
||||
if (message.plain_only != null && message.plain_only)
|
||||
if (message.isPlainOnly())
|
||||
bodyPart = plainPart;
|
||||
else {
|
||||
bodyPart = new MimeBodyPart();
|
||||
|
@ -2774,19 +2774,21 @@ public class MessageHelper {
|
|||
return protected_subject;
|
||||
}
|
||||
|
||||
Boolean isPlainOnly() {
|
||||
if (text.size() + extra.size() == 0)
|
||||
return null;
|
||||
|
||||
boolean has = false;
|
||||
Integer isPlainOnly() {
|
||||
int html = 0;
|
||||
int plain = 0;
|
||||
for (PartHolder h : text) {
|
||||
if (h.isHtml())
|
||||
return false;
|
||||
html++;
|
||||
if (h.isPlainText())
|
||||
has = true;
|
||||
plain++;
|
||||
}
|
||||
|
||||
return (has ? true : null);
|
||||
if (html + plain == 0)
|
||||
return null;
|
||||
if (html == 0)
|
||||
return 1;
|
||||
return (plain > 0 ? 0x80 : 0);
|
||||
}
|
||||
|
||||
boolean hasBody() throws MessagingException {
|
||||
|
@ -2802,8 +2804,8 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
void normalize() {
|
||||
Boolean plain = isPlainOnly();
|
||||
if (plain == null || plain)
|
||||
Integer plain = isPlainOnly();
|
||||
if (plain != null && (plain & 1) != 0)
|
||||
for (AttachmentPart apart : attachments)
|
||||
if (!TextUtils.isEmpty(apart.attachment.cid) ||
|
||||
!Part.ATTACHMENT.equals(apart.attachment.disposition)) {
|
||||
|
@ -2855,8 +2857,8 @@ public class MessageHelper {
|
|||
|
||||
List<PartHolder> parts = new ArrayList<>();
|
||||
|
||||
Boolean plain = isPlainOnly();
|
||||
if (plain != null && plain)
|
||||
Integer plain = isPlainOnly();
|
||||
if (plain != null && (plain & 1) != 0)
|
||||
parts.addAll(text);
|
||||
else
|
||||
for (PartHolder h : text)
|
||||
|
|
|
@ -598,8 +598,8 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
|
||||
MessageHelper.MessageParts parts = helper.getMessageParts();
|
||||
String body = parts.getHtml(this);
|
||||
Boolean plain = parts.isPlainOnly();
|
||||
if (plain != null && plain)
|
||||
Integer plain = parts.isPlainOnly();
|
||||
if (plain != null && (plain & 1) != 0)
|
||||
body = body.replace("<div x-plain=\"true\">", "<div>");
|
||||
|
||||
String text = HtmlHelper.getFullText(body);
|
||||
|
|
|
@ -352,7 +352,7 @@ public class ServiceUI extends IntentService {
|
|||
db.message().setMessageContent(reply.id,
|
||||
true,
|
||||
language,
|
||||
plain_only || ref.plain_only,
|
||||
plain_only || ref.isPlainOnly() ? 1 : 0,
|
||||
preview,
|
||||
null);
|
||||
|
||||
|
|
Loading…
Reference in New Issue