diff --git a/app/src/main/java/eu/faircode/email/AdapterRule.java b/app/src/main/java/eu/faircode/email/AdapterRule.java index 99e5cc22c2..22820d74c3 100644 --- a/app/src/main/java/eu/faircode/email/AdapterRule.java +++ b/app/src/main/java/eu/faircode/email/AdapterRule.java @@ -21,6 +21,7 @@ package eu.faircode.email; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -51,6 +52,7 @@ public class AdapterRule extends RecyclerView.Adapter { private TextView tvName; private TextView tvOrder; private ImageView ivStop; + private TextView tvCondition; private TextView tvAction; ViewHolder(View itemView) { @@ -60,6 +62,7 @@ public class AdapterRule extends RecyclerView.Adapter { tvName = itemView.findViewById(R.id.tvName); tvOrder = itemView.findViewById(R.id.tvOrder); ivStop = itemView.findViewById(R.id.ivStop); + tvCondition = itemView.findViewById(R.id.tvCondition); tvAction = itemView.findViewById(R.id.tvAction); } @@ -77,6 +80,22 @@ public class AdapterRule extends RecyclerView.Adapter { tvOrder.setText(Integer.toString(rule.order)); ivStop.setVisibility(rule.stop ? View.VISIBLE : View.INVISIBLE); + try { + List condition = new ArrayList<>(); + JSONObject jcondition = new JSONObject(rule.condition); + if (jcondition.has("sender")) + condition.add(context.getString(R.string.title_rule_sender)); + if (jcondition.has("recipient")) + condition.add(context.getString(R.string.title_rule_recipient)); + if (jcondition.has("subject")) + condition.add(context.getString(R.string.title_rule_subject)); + if (jcondition.has("header")) + condition.add(context.getString(R.string.title_rule_header)); + tvCondition.setText(TextUtils.join(", ", condition)); + } catch (Throwable ex) { + tvCondition.setText(ex.getMessage()); + } + try { JSONObject jaction = new JSONObject(rule.action); int type = jaction.getInt("type"); diff --git a/app/src/main/res/layout/item_rule.xml b/app/src/main/res/layout/item_rule.xml index 7c06f66cb5..92f3c73d4d 100644 --- a/app/src/main/res/layout/item_rule.xml +++ b/app/src/main/res/layout/item_rule.xml @@ -47,6 +47,15 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/tvCondition" /> \ No newline at end of file