Added option to use template name as subject

pull/194/merge
M66B 3 years ago
parent e0a379ee8d
commit f674a4b14d

@ -676,7 +676,8 @@ public class EntityRule {
long iid = jargs.getLong("identity"); long iid = jargs.getLong("identity");
long aid = jargs.getLong("answer"); 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"); String to = jargs.optString("to");
boolean cc = jargs.optBoolean("cc"); boolean cc = jargs.optBoolean("cc");
boolean attachments = jargs.optBoolean("attachments"); boolean attachments = jargs.optBoolean("attachments");
@ -699,6 +700,7 @@ public class EntityRule {
throw new IllegalArgumentException("Rule template missing name=" + rule.name); throw new IllegalArgumentException("Rule template missing name=" + rule.name);
answer = new EntityAnswer(); answer = new EntityAnswer();
answer.name = message.subject;
answer.text = ""; answer.text = "";
} else { } else {
answer = db.answer().getAnswer(aid); answer = db.answer().getAnswer(aid);
@ -749,7 +751,10 @@ public class EntityRule {
reply.cc = message.cc; reply.cc = message.cc;
reply.unsubscribe = "mailto:" + identity.email; reply.unsubscribe = "mailto:" + identity.email;
reply.auto_submitted = true; 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.received = new Date().getTime();
reply.sender = MessageHelper.getSortKey(reply.from); reply.sender = MessageHelper.getSortKey(reply.from);
@ -760,7 +765,7 @@ public class EntityRule {
String body = answer.getHtml(message.from); String body = answer.getHtml(message.from);
if (add_text) { if (original_text) {
Document msg = JsoupEx.parse(body); Document msg = JsoupEx.parse(body);
Element div = msg.createElement("div"); Element div = msg.createElement("div");

@ -140,7 +140,8 @@ public class FragmentRule extends FragmentBase {
private Spinner spIdent; private Spinner spIdent;
private Spinner spAnswer; private Spinner spAnswer;
private CheckBox cbIncludeMessageText; private CheckBox cbAnswerSubject;
private CheckBox cbOriginalText;
private EditText etTo; private EditText etTo;
private ImageButton ibTo; private ImageButton ibTo;
private CheckBox cbCc; private CheckBox cbCc;
@ -291,7 +292,8 @@ public class FragmentRule extends FragmentBase {
spIdent = view.findViewById(R.id.spIdent); spIdent = view.findViewById(R.id.spIdent);
spAnswer = view.findViewById(R.id.spAnswer); 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); etTo = view.findViewById(R.id.etTo);
ibTo = view.findViewById(R.id.ibTo); ibTo = view.findViewById(R.id.ibTo);
cbCc = view.findViewById(R.id.cbCc); cbCc = view.findViewById(R.id.cbCc);
@ -1139,7 +1141,8 @@ public class FragmentRule extends FragmentBase {
break; 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")); etTo.setText(jaction.optString("to"));
cbCc.setChecked(jaction.optBoolean("cc")); cbCc.setChecked(jaction.optBoolean("cc"));
@ -1481,7 +1484,8 @@ public class FragmentRule extends FragmentBase {
EntityAnswer answer = (EntityAnswer) spAnswer.getSelectedItem(); EntityAnswer answer = (EntityAnswer) spAnswer.getSelectedItem();
jaction.put("identity", identity == null ? -1 : identity.id); jaction.put("identity", identity == null ? -1 : identity.id);
jaction.put("answer", answer == null || answer.id == null ? -1 : answer.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("to", etTo.getText().toString().trim());
jaction.put("cc", cbCc.isChecked()); jaction.put("cc", cbCc.isChecked());
jaction.put("attachments", cbWithAttachments.isChecked()); jaction.put("attachments", cbWithAttachments.isChecked());

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

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

Loading…
Cancel
Save