Added rule condition has attachments

This commit is contained in:
M66B
2019-10-13 16:47:35 +02:00
parent 3446c88630
commit 7d3ccebc83
4 changed files with 57 additions and 3 deletions

View File

@@ -97,6 +97,8 @@ public class FragmentRule extends FragmentBase {
private EditText etSubject;
private CheckBox cbSubject;
private CheckBox cbAttachments;
private EditText etHeader;
private CheckBox cbHeader;
@@ -201,6 +203,8 @@ public class FragmentRule extends FragmentBase {
etSubject = view.findViewById(R.id.etSubject);
cbSubject = view.findViewById(R.id.cbSubject);
cbAttachments = view.findViewById(R.id.cbAttachments);
etHeader = view.findViewById(R.id.etHeader);
cbHeader = view.findViewById(R.id.cbHeader);
@@ -643,6 +647,8 @@ public class FragmentRule extends FragmentBase {
etSubject.setText(jsubject == null ? args.getString("subject") : jsubject.getString("value"));
cbSubject.setChecked(jsubject != null && jsubject.getBoolean("regex"));
cbAttachments.setChecked(jcondition.optBoolean("attachments"));
etHeader.setText(jheader == null ? null : jheader.getString("value"));
cbHeader.setChecked(jheader != null && jheader.getBoolean("regex"));
@@ -837,7 +843,12 @@ public class FragmentRule extends FragmentBase {
JSONObject jheader = jcondition.optJSONObject("header");
JSONObject jschedule = jcondition.optJSONObject("schedule");
if (jsender == null && jrecipient == null && jsubject == null && jheader == null && jschedule == null)
if (jsender == null &&
jrecipient == null &&
jsubject == null &&
!jcondition.optBoolean("attachments") &&
jheader == null &&
jschedule == null)
throw new IllegalArgumentException(context.getString(R.string.title_rule_condition_missing));
if (TextUtils.isEmpty(order))
@@ -916,6 +927,8 @@ public class FragmentRule extends FragmentBase {
jcondition.put("subject", jsubject);
}
jcondition.put("attachments", cbAttachments.isChecked());
String header = etHeader.getText().toString();
if (!TextUtils.isEmpty(header)) {
JSONObject jheader = new JSONObject();