Added rule action option to include message text

pull/194/merge
M66B 3 years ago
parent 6943a7a250
commit 9a1c3b04fe

@ -676,6 +676,7 @@ public class EntityRule {
long iid = jargs.getLong("identity");
long aid = jargs.getLong("answer");
boolean add_text = jargs.optBoolean("text", true);
String to = jargs.optString("to");
boolean cc = jargs.optBoolean("cc");
boolean attachments = jargs.optBoolean("attachments");
@ -758,26 +759,29 @@ public class EntityRule {
reply.id = db.message().insertMessage(reply);
String body = answer.getHtml(message.from);
Document msg = JsoupEx.parse(body);
Element div = msg.createElement("div");
if (add_text) {
Document msg = JsoupEx.parse(body);
Element p = message.getReplyHeader(context, msg, separate_reply, extended_reply);
div.appendChild(p);
Element div = msg.createElement("div");
Document answering = JsoupEx.parse(message.getFile(context));
Element e = answering.body();
if (quote) {
String style = e.attr("style");
style = HtmlHelper.mergeStyles(style, HtmlHelper.getQuoteStyle(e));
e.tagName("blockquote").attr("style", style);
} else
e.tagName("p");
div.appendChild(e);
Element p = message.getReplyHeader(context, msg, separate_reply, extended_reply);
div.appendChild(p);
Document answering = JsoupEx.parse(message.getFile(context));
Element e = answering.body();
if (quote) {
String style = e.attr("style");
style = HtmlHelper.mergeStyles(style, HtmlHelper.getQuoteStyle(e));
e.tagName("blockquote").attr("style", style);
} else
e.tagName("p");
div.appendChild(e);
msg.body().appendChild(div);
msg.body().appendChild(div);
body = msg.outerHtml();
body = msg.outerHtml();
}
File file = reply.getFile(context);
Helper.writeText(file, body);

@ -140,6 +140,7 @@ public class FragmentRule extends FragmentBase {
private Spinner spIdent;
private Spinner spAnswer;
private CheckBox cbIncludeMessageText;
private EditText etTo;
private ImageButton ibTo;
private CheckBox cbCc;
@ -290,6 +291,7 @@ public class FragmentRule extends FragmentBase {
spIdent = view.findViewById(R.id.spIdent);
spAnswer = view.findViewById(R.id.spAnswer);
cbIncludeMessageText = view.findViewById(R.id.cbIncludeMessageText);
etTo = view.findViewById(R.id.etTo);
ibTo = view.findViewById(R.id.ibTo);
cbCc = view.findViewById(R.id.cbCc);
@ -1137,6 +1139,8 @@ public class FragmentRule extends FragmentBase {
break;
}
cbIncludeMessageText.setChecked(jaction.optBoolean("text", true));
etTo.setText(jaction.optString("to"));
cbCc.setChecked(jaction.optBoolean("cc"));
cbWithAttachments.setChecked(jaction.optBoolean("attachments"));
@ -1477,6 +1481,7 @@ 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("to", etTo.getText().toString().trim());
jaction.put("cc", cbCc.isChecked());
jaction.put("attachments", cbWithAttachments.isChecked());

@ -840,6 +840,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAnswerTemplate" />
<CheckBox
android:id="@+id/cbIncludeMessageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_rule_include_message_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spAnswer" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvTo"
android:layout_width="wrap_content"
@ -849,7 +859,7 @@
android:text="@string/title_rule_forward_to"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spAnswer" />
app:layout_constraintTop_toBottomOf="@id/cbIncludeMessageText" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etTo"
@ -1065,7 +1075,7 @@
android:id="@+id/grpAnswer"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,tvTo,etTo,ibTo,cbCc,cbWithAttachments,tvAnswerRemark" />
app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbIncludeMessageText,tvTo,etTo,ibTo,cbCc,cbWithAttachments,tvAnswerRemark" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpTts"

@ -1545,6 +1545,7 @@
<string name="title_rule_thread">All messages in same conversation and folder</string>
<string name="title_rule_identity">Identity</string>
<string name="title_rule_template">Reply template</string>
<string name="title_rule_include_message_text">Include message text</string>
<string name="title_rule_forward_to">Forward to</string>
<string name="title_rule_cc">Reply to CC addresses</string>
<string name="title_rule_with_attachments">With attachments</string>

Loading…
Cancel
Save