mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +00:00
List rule action type
This commit is contained in:
parent
b017bc897d
commit
eb85e8eab7
2 changed files with 40 additions and 0 deletions
|
@ -34,6 +34,8 @@ import androidx.recyclerview.widget.DiffUtil;
|
|||
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -49,6 +51,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
private TextView tvName;
|
||||
private TextView tvOrder;
|
||||
private ImageView ivStop;
|
||||
private TextView tvAction;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
@ -57,6 +60,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);
|
||||
tvAction = itemView.findViewById(R.id.tvAction);
|
||||
}
|
||||
|
||||
private void wire() {
|
||||
|
@ -72,6 +76,32 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
tvName.setText(rule.name);
|
||||
tvOrder.setText(Integer.toString(rule.order));
|
||||
ivStop.setVisibility(rule.stop ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
try {
|
||||
JSONObject jaction = new JSONObject(rule.action);
|
||||
int type = jaction.getInt("type");
|
||||
switch (type) {
|
||||
case EntityRule.TYPE_SEEN:
|
||||
tvAction.setText(R.string.title_seen);
|
||||
break;
|
||||
case EntityRule.TYPE_UNSEEN:
|
||||
tvAction.setText(R.string.title_unseen);
|
||||
break;
|
||||
case EntityRule.TYPE_MOVE:
|
||||
tvAction.setText(R.string.title_move);
|
||||
break;
|
||||
case EntityRule.TYPE_ANSWER:
|
||||
tvAction.setText(R.string.title_answer_reply);
|
||||
break;
|
||||
case EntityRule.TYPE_AUTOMATION:
|
||||
tvAction.setText(R.string.title_rule_automation);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown action type=" + type);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
tvAction.setText(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,5 +46,15 @@
|
|||
android:src="@drawable/baseline_stop_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Action"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
Loading…
Reference in a new issue