From bba731e1e5cb88c1920a17e25eaae0a57dda044f Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 20 Jun 2021 10:07:31 +0200 Subject: [PATCH] Fixed enabling junk filter for non inbox folders --- .../eu/faircode/email/FragmentDialogJunk.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java index b9b0a43d58..e0dc854c6a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java @@ -162,33 +162,36 @@ public class FragmentDialogJunk extends FragmentDialogBase { new SimpleTask() { @Override protected Void onExecute(Context context, Bundle args) throws Throwable { - long account = args.getLong("account"); + long aid = args.getLong("account"); + long fid = args.getLong("folder"); boolean filter = args.getBoolean("filter"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); DB db = DB.getInstance(context); - EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); - if (inbox == null) + EntityFolder folder = db.folder().getFolder(fid); + if (folder == null) return null; - EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK); + EntityFolder junk = db.folder().getFolderByType(aid, EntityFolder.JUNK); if (junk == null) return null; try { db.beginTransaction(); - db.folder().setFolderDownload( - inbox.id, inbox.download || filter); - db.folder().setFolderAutoClassify( - inbox.id, inbox.auto_classify_source || filter, inbox.auto_classify_target); + db.folder().setFolderDownload(folder.id, + folder.download || filter); + db.folder().setFolderAutoClassify(folder.id, + folder.auto_classify_source || filter, + folder.auto_classify_target); - db.folder().setFolderDownload( - junk.id, junk.download || filter); - db.folder().setFolderAutoClassify( - junk.id, junk.auto_classify_source || filter, filter); + db.folder().setFolderDownload(junk.id, + junk.download || filter); + db.folder().setFolderAutoClassify(junk.id, + junk.auto_classify_source || filter, + filter); db.setTransactionSuccessful(); } finally { @@ -251,22 +254,23 @@ public class FragmentDialogJunk extends FragmentDialogBase { @Override protected Boolean onExecute(Context context, Bundle args) throws Throwable { - long account = args.getLong("account"); + long aid = args.getLong("account"); + long fid = args.getLong("folder"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean classification = prefs.getBoolean("classification", false); DB db = DB.getInstance(context); - EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); - if (inbox == null) - return false; + EntityFolder folder = db.folder().getFolder(fid); + if (folder == null) + return null; - EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK); + EntityFolder junk = db.folder().getFolderByType(aid, EntityFolder.JUNK); if (junk == null) - return false; + return null; return (classification && - inbox.download && inbox.auto_classify_source && + folder.download && folder.auto_classify_source && junk.download && junk.auto_classify_source && junk.auto_classify_target); }