Added option to show filter icon when rules were applied

This commit is contained in:
M66B 2023-04-20 08:37:16 +02:00
parent d57258888e
commit 7afe7bfa67
6 changed files with 36 additions and 2 deletions

View File

@ -289,6 +289,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private String sender_ellipsize;
private String subject_ellipsize;
private boolean show_filtered;
private boolean keywords_header;
private boolean labels_header;
private boolean flags;
@ -1460,7 +1461,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
ivFound.setVisibility(message.ui_found && found ? View.VISIBLE : View.GONE);
ivClassified.setVisibility(message.auto_classified ? View.VISIBLE : View.GONE);
ivClassified.setImageResource(message.isFiltered()
? R.drawable.twotone_filter_alt_24 : R.drawable.twotone_push_pin_24);
ivClassified.setVisibility(message.auto_classified || (show_filtered && message.isFiltered())
? View.VISIBLE : View.GONE);
int snoozy = (message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE
? R.drawable.twotone_visibility_off_24
@ -7627,6 +7631,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.sender_ellipsize = prefs.getString("sender_ellipsize", "end");
this.subject_ellipsize = prefs.getString("subject_ellipsize", "full");
this.show_filtered = prefs.getBoolean("show_filtered", false);
this.keywords_header = prefs.getBoolean("keywords_header", false);
this.labels_header = prefs.getBoolean("labels_header", true);
this.flags = prefs.getBoolean("flags", true);

View File

@ -361,6 +361,10 @@ public class EntityMessage implements Serializable {
return hasKeyword(MessageHelper.FLAG_FORWARDED);
}
boolean isFiltered() {
return hasKeyword(MessageHelper.FLAG_FILTERED);
}
boolean isSigned() {
return (EntityMessage.PGP_SIGNONLY.equals(ui_encrypt) ||
EntityMessage.SMIME_SIGNONLY.equals(ui_encrypt));

View File

@ -137,6 +137,7 @@ public class FragmentOptions extends FragmentBase {
"column_width",
"hide_toolbar", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
"indentation", "date", "date_week", "date_fixed", "date_bold", "threading", "threading_unread",
"show_filtered",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"authentication", "authentication_indicator",

View File

@ -119,6 +119,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SeekBar sbClassMinProbability;
private TextView tvClassMinDifference;
private SeekBar sbClassMinDifference;
private SwitchCompat swShowFiltered;
private ImageButton ibClassification;
private TextView tvFtsIndexed;
private TextView tvFtsPro;
@ -270,6 +271,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{
"sort_answers", "shortcuts", "fts",
"classification", "class_min_probability", "class_min_difference",
"show_filtered",
"language",
"lt_enabled", "lt_auto", "lt_picky", "lt_uri", "lt_user", "lt_key",
"deepl_enabled",
@ -359,6 +361,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
sbClassMinProbability = view.findViewById(R.id.sbClassMinProbability);
tvClassMinDifference = view.findViewById(R.id.tvClassMinDifference);
sbClassMinDifference = view.findViewById(R.id.sbClassMinDifference);
swShowFiltered = view.findViewById(R.id.swShowFiltered);
tvFtsIndexed = view.findViewById(R.id.tvFtsIndexed);
tvFtsPro = view.findViewById(R.id.tvFtsPro);
spLanguage = view.findViewById(R.id.spLanguage);
@ -647,6 +650,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swShowFiltered.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("show_filtered", isChecked).apply();
}
});
spLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -2339,6 +2349,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvClassMinDifference.setText(getString(R.string.title_advanced_class_min_difference, NF.format(class_min_difference)));
sbClassMinDifference.setProgress(class_min_difference);
swShowFiltered.setChecked(prefs.getBoolean("show_filtered", false));
int selected = -1;
String language = prefs.getString("language", null);
List<String> display = new ArrayList<>();

View File

@ -272,6 +272,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvClassMinDifference" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swShowFiltered"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_show_filtered"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbClassMinDifference"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvLanguage"
android:layout_width="0dp"
@ -283,7 +294,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbClassMinDifference" />
app:layout_constraintTop_toBottomOf="@id/swShowFiltered" />
<Spinner
android:id="@+id/spLanguage"

View File

@ -793,6 +793,7 @@
<string name="title_advanced_classification">Classify messages</string>
<string name="title_advanced_class_min_chance">Minimum class probability: %1$s %%</string>
<string name="title_advanced_class_min_difference">Minimum class difference: %1$s %%</string>
<string name="title_advanced_show_filtered">Show a filter icon when rules were applied</string>
<string name="title_advanced_language">Language</string>
<string name="title_advanced_language_system">System</string>
<string name="title_advanced_lt">LanguageTool integration</string>