mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +00:00
List rule conditions
This commit is contained in:
parent
0b6be960fc
commit
46cb74f49c
2 changed files with 29 additions and 1 deletions
|
@ -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<AdapterRule.ViewHolder> {
|
|||
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<AdapterRule.ViewHolder> {
|
|||
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<AdapterRule.ViewHolder> {
|
|||
tvOrder.setText(Integer.toString(rule.order));
|
||||
ivStop.setVisibility(rule.stop ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
try {
|
||||
List<String> 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");
|
||||
|
|
|
@ -47,6 +47,15 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCondition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Condition"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAction"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -54,7 +63,7 @@
|
|||
android:text="Action"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCondition" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
Loading…
Reference in a new issue