From f674a4b14d5cf940f00cf838b3cbf626701ea754 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 11 Feb 2022 12:36:28 +0100 Subject: [PATCH] Added option to use template name as subject --- .../java/eu/faircode/email/EntityRule.java | 11 ++++++++--- .../java/eu/faircode/email/FragmentRule.java | 12 ++++++++---- app/src/main/res/layout/fragment_rule.xml | 19 ++++++++++++++----- app/src/main/res/values/strings.xml | 3 ++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index fbbb76f18b..37005a9a20 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -676,7 +676,8 @@ public class EntityRule { long iid = jargs.getLong("identity"); long aid = jargs.getLong("answer"); - boolean add_text = jargs.optBoolean("text", true); + boolean answer_subject = jargs.optBoolean("answer_subject", false); + boolean original_text = jargs.optBoolean("original_text", true); String to = jargs.optString("to"); boolean cc = jargs.optBoolean("cc"); boolean attachments = jargs.optBoolean("attachments"); @@ -699,6 +700,7 @@ public class EntityRule { throw new IllegalArgumentException("Rule template missing name=" + rule.name); answer = new EntityAnswer(); + answer.name = message.subject; answer.text = ""; } else { answer = db.answer().getAnswer(aid); @@ -749,7 +751,10 @@ public class EntityRule { reply.cc = message.cc; reply.unsubscribe = "mailto:" + identity.email; reply.auto_submitted = true; - reply.subject = EntityMessage.getSubject(context, message.language, message.subject, !isReply); + reply.subject = EntityMessage.getSubject(context, + message.language, + answer_subject ? answer.name : message.subject, + !isReply); reply.received = new Date().getTime(); reply.sender = MessageHelper.getSortKey(reply.from); @@ -760,7 +765,7 @@ public class EntityRule { String body = answer.getHtml(message.from); - if (add_text) { + if (original_text) { Document msg = JsoupEx.parse(body); Element div = msg.createElement("div"); diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index 59dc861580..00f0eae7e5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -140,7 +140,8 @@ public class FragmentRule extends FragmentBase { private Spinner spIdent; private Spinner spAnswer; - private CheckBox cbIncludeMessageText; + private CheckBox cbAnswerSubject; + private CheckBox cbOriginalText; private EditText etTo; private ImageButton ibTo; private CheckBox cbCc; @@ -291,7 +292,8 @@ public class FragmentRule extends FragmentBase { spIdent = view.findViewById(R.id.spIdent); spAnswer = view.findViewById(R.id.spAnswer); - cbIncludeMessageText = view.findViewById(R.id.cbIncludeMessageText); + cbAnswerSubject = view.findViewById(R.id.cbAnswerSubject); + cbOriginalText = view.findViewById(R.id.cbOriginalText); etTo = view.findViewById(R.id.etTo); ibTo = view.findViewById(R.id.ibTo); cbCc = view.findViewById(R.id.cbCc); @@ -1139,7 +1141,8 @@ public class FragmentRule extends FragmentBase { break; } - cbIncludeMessageText.setChecked(jaction.optBoolean("text", true)); + cbAnswerSubject.setChecked(jaction.optBoolean("answer_subject", false)); + cbOriginalText.setChecked(jaction.optBoolean("original_text", true)); etTo.setText(jaction.optString("to")); cbCc.setChecked(jaction.optBoolean("cc")); @@ -1481,7 +1484,8 @@ public class FragmentRule extends FragmentBase { EntityAnswer answer = (EntityAnswer) spAnswer.getSelectedItem(); jaction.put("identity", identity == null ? -1 : identity.id); jaction.put("answer", answer == null || answer.id == null ? -1 : answer.id); - jaction.put("text", cbIncludeMessageText.isChecked()); + jaction.put("answer_subject", cbAnswerSubject.isChecked()); + jaction.put("original_text", cbOriginalText.isChecked()); jaction.put("to", etTo.getText().toString().trim()); jaction.put("cc", cbCc.isChecked()); jaction.put("attachments", cbWithAttachments.isChecked()); diff --git a/app/src/main/res/layout/fragment_rule.xml b/app/src/main/res/layout/fragment_rule.xml index 7a2331cbf1..36194a7476 100644 --- a/app/src/main/res/layout/fragment_rule.xml +++ b/app/src/main/res/layout/fragment_rule.xml @@ -841,14 +841,23 @@ app:layout_constraintTop_toBottomOf="@id/tvAnswerTemplate" /> + + + app:layout_constraintTop_toBottomOf="@id/cbAnswerSubject" /> + app:layout_constraintTop_toBottomOf="@id/cbOriginalText" /> + app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbAnswerSubject,cbOriginalText,tvTo,etTo,ibTo,cbCc,cbWithAttachments,tvAnswerRemark" /> All messages in same conversation and folder Identity Reply template - Include message text + Use template name as subject + Include original message text Forward to Reply to CC addresses With attachments