mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
Debug: rule needs headers/body
This commit is contained in:
parent
7b67d308da
commit
7e4c9731b2
3 changed files with 50 additions and 1 deletions
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
|
@ -45,6 +46,7 @@ import androidx.lifecycle.LifecycleObserver;
|
|||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -57,6 +59,7 @@ import java.text.Collator;
|
|||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -70,6 +73,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
private LifecycleOwner owner;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
private boolean debug;
|
||||
private DateFormat DF;
|
||||
private NumberFormat NF = NumberFormat.getNumberInstance();
|
||||
|
||||
|
@ -82,6 +86,8 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
private View view;
|
||||
private ImageView ivDaily;
|
||||
private ImageView ivHeaders;
|
||||
private ImageView ivBody;
|
||||
private TextView tvName;
|
||||
private TextView tvOrder;
|
||||
private ImageView ivStop;
|
||||
|
@ -97,6 +103,8 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
ivDaily = itemView.findViewById(R.id.ivDaily);
|
||||
ivHeaders = itemView.findViewById(R.id.ivHeaders);
|
||||
ivBody = itemView.findViewById(R.id.ivBody);
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
tvOrder = itemView.findViewById(R.id.tvOrder);
|
||||
ivStop = itemView.findViewById(R.id.ivStop);
|
||||
|
@ -117,8 +125,15 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
}
|
||||
|
||||
private void bindTo(TupleRuleEx rule) {
|
||||
boolean needsHeaders = (debug || BuildConfig.DEBUG) &&
|
||||
EntityRule.needsHeaders(Arrays.asList(rule));
|
||||
boolean needsBody = (debug || BuildConfig.DEBUG) &&
|
||||
EntityRule.needsBody(Arrays.asList(rule));
|
||||
|
||||
view.setActivated(!rule.enabled);
|
||||
ivDaily.setVisibility(rule.daily ? View.VISIBLE : View.GONE);
|
||||
ivHeaders.setVisibility(needsHeaders ? View.VISIBLE : View.GONE);
|
||||
ivBody.setVisibility(needsBody ? View.VISIBLE : View.GONE);
|
||||
tvName.setText(rule.name);
|
||||
tvOrder.setText(Integer.toString(rule.order));
|
||||
ivStop.setVisibility(rule.stop ? View.VISIBLE : View.INVISIBLE);
|
||||
|
@ -586,6 +601,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
this.owner = parentFragment.getViewLifecycleOwner();
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
this.DF = Helper.getDateTimeInstance(this.context);
|
||||
|
||||
setHasStableIds(true);
|
||||
|
|
|
@ -141,12 +141,20 @@ public class EntityRule {
|
|||
private static final int MAX_NOTES_LENGTH = 512; // characters
|
||||
|
||||
static boolean needsHeaders(EntityMessage message, List<EntityRule> rules) {
|
||||
return needsHeaders(rules);
|
||||
}
|
||||
|
||||
static boolean needsHeaders(List<EntityRule> rules) {
|
||||
return needs(rules, "header");
|
||||
}
|
||||
|
||||
static boolean needsBody(EntityMessage message, List<EntityRule> rules) {
|
||||
if (message.encrypt != null && !EntityMessage.ENCRYPT_NONE.equals(message.encrypt))
|
||||
return false;
|
||||
return needsBody(rules);
|
||||
}
|
||||
|
||||
static boolean needsBody(List<EntityRule> rules) {
|
||||
return needs(rules, "body") || needs(rules, "notes_jsoup");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,33 @@
|
|||
android:layout_height="24dp"
|
||||
android:contentDescription="@string/title_rule_daily"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivStop"
|
||||
app:layout_constraintEnd_toStartOf="@id/ivHeaders"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/ivStop"
|
||||
app:srcCompat="@drawable/twotone_hourglass_top_24" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHeaders"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="@string/title_rule_daily"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivStop"
|
||||
app:layout_constraintStart_toEndOf="@id/ivDaily"
|
||||
app:layout_constraintTop_toTopOf="@+id/ivStop"
|
||||
app:srcCompat="@drawable/twotone_code_24"
|
||||
app:tint="?attr/colorWarning" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivBody"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="@string/title_rule_daily"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivStop"
|
||||
app:layout_constraintStart_toEndOf="@id/ivHeaders"
|
||||
app:layout_constraintTop_toTopOf="@+id/ivStop"
|
||||
app:srcCompat="@drawable/twotone_text_snippet_24"
|
||||
app:tint="?attr/colorWarning" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvName"
|
||||
android:layout_width="0dp"
|
||||
|
@ -37,7 +60,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivStop"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvOrder"
|
||||
app:layout_constraintStart_toEndOf="@id/ivDaily"
|
||||
app:layout_constraintStart_toEndOf="@id/ivBody"
|
||||
app:layout_constraintTop_toTopOf="@+id/ivStop" />
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue