diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 8f0ec78c38..8ee52e6a16 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -209,6 +209,7 @@ public class AdapterMessage extends RecyclerView.Adapter 1 && + EntityFolder.TRASH.equals(message.folderType)) + return R.layout.item_message_duplicate; + return (compact ? R.layout.item_message_compact : R.layout.item_message_normal); } @@ -6696,11 +6710,18 @@ public class AdapterMessage extends RecyclerView.Adapter 1 && + EntityFolder.TRASH.equals(message.folderType))) { holder.card.setCardBackgroundColor(message.folderColor == null ? Color.TRANSPARENT : ColorUtils.setAlphaComponent(message.folderColor, 128)); - holder.tvFolder.setText(context.getString(R.string.title_duplicate_in, message.getFolderName(context))); + if (filter_duplicates && message.duplicate) + holder.tvFolder.setText(context.getString(R.string.title_duplicate_in, + message.getFolderName(context))); + else + holder.tvFolder.setText(context.getString(R.string.title_trashed_from, + MessageHelper.formatAddresses(message.from, false, false))); holder.tvFolder.setTypeface(message.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); holder.tvFolder.setTextColor(message.unseen > 0 ? colorUnread : colorRead); holder.tvFolder.setAlpha(Helper.LOW_LIGHT); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 6503e95ba7..f31e3c9e0f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -843,10 +843,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. boolean ascending = prefs.getBoolean( viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false); boolean filter_duplicates = prefs.getBoolean("filter_duplicates", true); + boolean filter_trash = prefs.getBoolean("filter_trash", false); + + if (viewType != AdapterMessage.ViewType.THREAD) + filter_trash = false; adapter = new AdapterMessage( this, type, found, viewType, - compact, zoom, sort, ascending, filter_duplicates, + compact, zoom, sort, ascending, + filter_duplicates, filter_trash, iProperties); if (viewType == AdapterMessage.ViewType.THREAD) adapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT); @@ -4427,6 +4432,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. boolean filter_unknown = prefs.getBoolean(getFilter("unknown", type), false); boolean filter_snoozed = prefs.getBoolean(getFilter("snoozed", type), true); boolean filter_duplicates = prefs.getBoolean("filter_duplicates", true); + boolean filter_trash = prefs.getBoolean("filter_trash", false); boolean language_detection = prefs.getBoolean("language_detection", false); String filter_language = prefs.getString("filter_language", null); boolean compact = prefs.getBoolean("compact", false); @@ -4517,6 +4523,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. menu.findItem(R.id.menu_filter_unknown).setVisible(folder && !drafts && !sent); menu.findItem(R.id.menu_filter_snoozed).setVisible(folder && !drafts); menu.findItem(R.id.menu_filter_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD); + menu.findItem(R.id.menu_filter_trash).setVisible(viewType == AdapterMessage.ViewType.THREAD); menu.findItem(R.id.menu_filter_seen).setChecked(filter_seen); menu.findItem(R.id.menu_filter_unflagged).setChecked(filter_unflagged); @@ -4524,6 +4531,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. menu.findItem(R.id.menu_filter_snoozed).setChecked(filter_snoozed); menu.findItem(R.id.menu_filter_language).setVisible(language_detection && folder); menu.findItem(R.id.menu_filter_duplicates).setChecked(filter_duplicates); + menu.findItem(R.id.menu_filter_trash).setChecked(filter_trash); SpannableStringBuilder ssbZoom = new SpannableStringBuilder(getString(R.string.title_zoom)); ssbZoom.append(' '); @@ -4647,6 +4655,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } else if (itemId == R.id.menu_filter_duplicates) { onMenuFilterDuplicates(!item.isChecked()); return true; + } else if (itemId == R.id.menu_filter_trash) { + onMenuFilterTrash(!item.isChecked()); + return true; } else if (itemId == R.id.menu_zoom) { onMenuZoom(); return true; @@ -4895,6 +4906,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. adapter.setFilterDuplicates(filter); } + private void onMenuFilterTrash(boolean filter) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + prefs.edit().putBoolean("filter_trash", filter).apply(); + invalidateOptionsMenu(); + adapter.setFilterTrash(filter); + } + private void onMenuZoom() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); boolean compact = prefs.getBoolean("compact", false); diff --git a/app/src/main/res/menu/menu_messages.xml b/app/src/main/res/menu/menu_messages.xml index fb8898f002..4305fe9f42 100644 --- a/app/src/main/res/menu/menu_messages.xml +++ b/app/src/main/res/menu/menu_messages.xml @@ -120,6 +120,11 @@ android:id="@+id/menu_filter_duplicates" android:checkable="true" android:title="@string/title_filter_duplicates" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e8930e807e..80cbde42bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1016,6 +1016,7 @@ No messages One or more filters active Duplicate message in %1$s + Trashed message from %1$s Re: %1$s Fwd: %1$s @@ -1391,6 +1392,7 @@ Unknown senders Hidden Duplicates + Trashed Compact view Text size