Added filter on deleted messages

pull/194/merge
M66B 3 years ago
parent 332e0d7c9b
commit 4e295f318b

@ -99,6 +99,7 @@ public interface DaoMessage {
" AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0)" +
" AND (NOT :filter_unknown OR SUM(message.avatar IS NOT NULL AND message.sender <> identity.email) > 0)" +
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_drafts + ")" +
" AND (NOT :filter_deleted OR NOT message.ui_deleted)" +
" AND (:filter_language IS NULL OR SUM(message.language = :filter_language) > 0)" +
" ORDER BY -IFNULL(message.importance, 1)" +
", account.category COLLATE NOCASE" +
@ -118,7 +119,7 @@ public interface DaoMessage {
String type,
boolean threading,
String sort, boolean ascending,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed, String filter_language,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed, boolean filter_deleted, String filter_language,
boolean found,
boolean debug);
@ -171,6 +172,7 @@ public interface DaoMessage {
" AND (NOT :filter_unknown OR SUM(message.avatar IS NOT NULL AND message.sender <> identity.email) > 0" +
" OR " + is_outbox + " OR " + is_drafts + " OR " + is_sent + ")" +
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_outbox + " OR " + is_drafts + ")" +
" AND (NOT :filter_deleted OR NOT message.ui_deleted)" +
" AND (:filter_language IS NULL OR SUM(message.language = :filter_language) > 0 OR " + is_outbox + ")" +
" ORDER BY -IFNULL(message.importance, 1)" +
", CASE" +
@ -188,7 +190,7 @@ public interface DaoMessage {
DataSource.Factory<Integer, TupleMessageEx> pagedFolder(
long folder, boolean threading,
String sort, boolean ascending,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed, String filter_language,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed, boolean filter_deleted, String filter_language,
boolean found,
boolean debug);

@ -4512,10 +4512,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean filter_unflagged = prefs.getBoolean(getFilter(context, "unflagged", viewType, type), false);
boolean filter_unknown = prefs.getBoolean(getFilter(context, "unknown", viewType, type), false);
boolean filter_snoozed = prefs.getBoolean(getFilter(context, "snoozed", viewType, type), true);
boolean filter_deleted = prefs.getBoolean(getFilter(context, "deleted", viewType, type), false);
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 perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
int padding = prefs.getInt("view_padding", compact ? 0 : 1);
@ -4603,6 +4605,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_filter_unflagged).setVisible(folder);
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_deleted).setVisible(folder && !perform_expunge);
menu.findItem(R.id.menu_filter_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_trash).setVisible(viewType == AdapterMessage.ViewType.THREAD);
@ -4610,6 +4613,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_filter_unflagged).setChecked(filter_unflagged);
menu.findItem(R.id.menu_filter_unknown).setChecked(filter_unknown);
menu.findItem(R.id.menu_filter_snoozed).setChecked(filter_snoozed);
menu.findItem(R.id.menu_filter_deleted).setChecked(filter_deleted);
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);
@ -4738,6 +4742,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} else if (itemId == R.id.menu_filter_snoozed) {
onMenuFilter(getFilter(getContext(), "snoozed", viewType, type), !item.isChecked());
return true;
} else if (itemId == R.id.menu_filter_deleted) {
onMenuFilter(getFilter(getContext(), "deleted", viewType, type), !item.isChecked());
return true;
} else if (itemId == R.id.menu_filter_language) {
onMenuFilterLanguage();
return true;

@ -128,6 +128,7 @@ public class ViewModelMessages extends ViewModel {
args.filter_unflagged,
args.filter_unknown,
args.filter_snoozed,
args.filter_deleted,
args.filter_language,
false,
args.debug),
@ -149,6 +150,7 @@ public class ViewModelMessages extends ViewModel {
args.filter_unflagged,
args.filter_unknown,
args.filter_snoozed,
args.filter_deleted,
args.filter_language,
false,
args.debug),
@ -182,7 +184,7 @@ public class ViewModelMessages extends ViewModel {
null,
args.threading,
"time", false,
false, false, false, false,
false, false, false, false, false,
null,
true,
args.debug),
@ -192,7 +194,7 @@ public class ViewModelMessages extends ViewModel {
db.message().pagedFolder(
args.folder, args.threading,
"time", false,
false, false, false, false,
false, false, false, false, false,
null,
true,
args.debug),
@ -483,6 +485,7 @@ public class ViewModelMessages extends ViewModel {
private boolean filter_unknown;
private boolean filter_snoozed;
private boolean filter_archive;
private boolean filter_deleted;
private String filter_language;
private boolean debug;
@ -510,6 +513,7 @@ public class ViewModelMessages extends ViewModel {
this.filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter(context, "unflagged", viewType, type), false);
this.filter_unknown = prefs.getBoolean(FragmentMessages.getFilter(context, "unknown", viewType, type), false);
this.filter_snoozed = prefs.getBoolean(FragmentMessages.getFilter(context, "snoozed", viewType, type), true);
this.filter_deleted = prefs.getBoolean(FragmentMessages.getFilter(context, "deleted", viewType, type), false);
boolean language_detection = prefs.getBoolean("language_detection", false);
String filter_language = prefs.getString("filter_language", null);
@ -538,6 +542,7 @@ public class ViewModelMessages extends ViewModel {
this.filter_unknown == other.filter_unknown &&
this.filter_snoozed == other.filter_snoozed &&
this.filter_archive == other.filter_archive &&
this.filter_deleted == other.filter_deleted &&
Objects.equals(this.filter_language, other.filter_language) &&
this.debug == other.debug);
} else

@ -110,6 +110,11 @@
android:checkable="true"
android:title="@string/title_filter_hidden" />
<item
android:id="@+id/menu_filter_deleted"
android:checkable="true"
android:title="@string/title_filter_deleted" />
<item
android:id="@+id/menu_filter_language"
android:title="@string/title_select_language">

@ -683,6 +683,7 @@
<string name="title_advanced_modseq" translatable="false">MODSEQ</string>
<string name="title_advanced_expunge" translatable="false">AUTO EXPUNGE</string>
<string name="title_advanced_uid_expunge" translatable="false">UID EXPUNGE</string>
<string name="title_advanced_hide_deleted" translatable="false">Hide deleted messages</string>
<string name="title_advanced_auth_plain" translatable="false">PLAIN</string>
<string name="title_advanced_auth_login" translatable="false">LOGIN</string>
<string name="title_advanced_auth_ntlm" translatable="false">NTLM</string>
@ -1419,6 +1420,7 @@
<string name="title_filter_unflagged">Unstarred</string>
<string name="title_filter_unknown">Unknown senders</string>
<string name="title_filter_hidden">Hidden</string>
<string name="title_filter_deleted">Deleted</string>
<string name="title_filter_duplicates">Duplicates</string>
<string name="title_filter_trash">Trashed</string>

Loading…
Cancel
Save