mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 13:47:05 +02:00
Added text contains filter rule condition
This commit is contained in:
@@ -105,6 +105,9 @@ public class FragmentRule extends FragmentBase {
|
||||
private EditText etHeader;
|
||||
private CheckBox cbHeader;
|
||||
|
||||
private EditText etBody;
|
||||
private CheckBox cbBody;
|
||||
|
||||
private TextView tvDateAfter;
|
||||
private TextView tvDateBefore;
|
||||
private Button btnDateAfter;
|
||||
@@ -240,6 +243,9 @@ public class FragmentRule extends FragmentBase {
|
||||
etHeader = view.findViewById(R.id.etHeader);
|
||||
cbHeader = view.findViewById(R.id.cbHeader);
|
||||
|
||||
etBody = view.findViewById(R.id.etBody);
|
||||
cbBody = view.findViewById(R.id.cbBody);
|
||||
|
||||
tvDateAfter = view.findViewById(R.id.tvDateAfter);
|
||||
tvDateBefore = view.findViewById(R.id.tvDateBefore);
|
||||
btnDateAfter = view.findViewById(R.id.btnDateAfter);
|
||||
@@ -877,6 +883,7 @@ public class FragmentRule extends FragmentBase {
|
||||
JSONObject jrecipient = jcondition.optJSONObject("recipient");
|
||||
JSONObject jsubject = jcondition.optJSONObject("subject");
|
||||
JSONObject jheader = jcondition.optJSONObject("header");
|
||||
JSONObject jbody = jcondition.optJSONObject("body");
|
||||
JSONObject jdate = jcondition.optJSONObject("date");
|
||||
JSONObject jschedule = jcondition.optJSONObject("schedule");
|
||||
|
||||
@@ -905,6 +912,9 @@ public class FragmentRule extends FragmentBase {
|
||||
etHeader.setText(jheader == null ? null : jheader.getString("value"));
|
||||
cbHeader.setChecked(jheader != null && jheader.getBoolean("regex"));
|
||||
|
||||
etBody.setText(jbody == null ? null : jbody.getString("value"));
|
||||
cbBody.setChecked(jbody != null && jbody.getBoolean("regex"));
|
||||
|
||||
long after = (jdate != null && jdate.has("after") ? jdate.getLong("after") : 0);
|
||||
long before = (jdate != null && jdate.has("before") ? jdate.getLong("before") : 0);
|
||||
|
||||
@@ -1118,6 +1128,7 @@ public class FragmentRule extends FragmentBase {
|
||||
JSONObject jrecipient = jcondition.optJSONObject("recipient");
|
||||
JSONObject jsubject = jcondition.optJSONObject("subject");
|
||||
JSONObject jheader = jcondition.optJSONObject("header");
|
||||
JSONObject jbody = jcondition.optJSONObject("body");
|
||||
JSONObject jdate = jcondition.optJSONObject("date");
|
||||
JSONObject jschedule = jcondition.optJSONObject("schedule");
|
||||
|
||||
@@ -1126,6 +1137,7 @@ public class FragmentRule extends FragmentBase {
|
||||
jsubject == null &&
|
||||
!jcondition.optBoolean("attachments") &&
|
||||
jheader == null &&
|
||||
jbody == null &&
|
||||
jdate == null &&
|
||||
jschedule == null)
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_rule_condition_missing));
|
||||
@@ -1220,6 +1232,14 @@ public class FragmentRule extends FragmentBase {
|
||||
jcondition.put("header", jheader);
|
||||
}
|
||||
|
||||
String body = etBody.getText().toString();
|
||||
if (!TextUtils.isEmpty(body)) {
|
||||
JSONObject jbody = new JSONObject();
|
||||
jbody.put("value", body);
|
||||
jbody.put("regex", cbBody.isChecked());
|
||||
jcondition.put("body", jbody);
|
||||
}
|
||||
|
||||
Object hafter = tvDateAfter.getTag();
|
||||
Object hbefore = tvDateBefore.getTag();
|
||||
|
||||
@@ -1441,7 +1461,7 @@ public class FragmentRule extends FragmentBase {
|
||||
if (message == null)
|
||||
continue;
|
||||
|
||||
if (rule.matches(context, message, null))
|
||||
if (rule.matches(context, message, null, null))
|
||||
if (rule.execute(context, message))
|
||||
applied++;
|
||||
|
||||
@@ -1501,7 +1521,7 @@ public class FragmentRule extends FragmentBase {
|
||||
if (message == null)
|
||||
continue;
|
||||
|
||||
if (rule.matches(context, message, null))
|
||||
if (rule.matches(context, message, null, null))
|
||||
matching.add(message);
|
||||
|
||||
if (matching.size() >= MAX_CHECK)
|
||||
|
||||
Reference in New Issue
Block a user