diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index 7d301d7e08..e1092de500 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -728,8 +728,9 @@ public class AdapterFolder extends RecyclerView.Adapter() { @Override @@ -180,8 +229,44 @@ public class FragmentRules extends FragmentBase { @Override protected void onException(Bundle args, Throwable ex) { - + Log.unexpectedError(getParentFragmentManager(), ex); } }.execute(this, args, "rule:move"); } + + private void onClear(Bundle args) { + new SimpleTask() { + @Override + protected Void onExecute(Context context, Bundle args) throws Throwable { + long fid = args.getLong("folder"); + + DB db = DB.getInstance(context); + EntityFolder folder = db.folder().getFolder(fid); + if (folder == null) + return null; + + EntityFolder junk = db.folder().getFolderByType(folder.account, EntityFolder.JUNK); + if (junk == null) + return null; + + List rules = db.rule().getRules(fid); + if (rules == null) + return null; + + for (EntityRule rule : rules) { + JSONObject jaction = new JSONObject(rule.action); + if (jaction.optInt("type", -1) == TYPE_MOVE && + jaction.optInt("target", -1) == junk.id) + db.rule().deleteRule(rule.id); + } + + return null; + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Log.unexpectedError(getParentFragmentManager(), ex); + } + }.execute(this, args, "rules:clear"); + } } diff --git a/app/src/main/res/menu/menu_rules.xml b/app/src/main/res/menu/menu_rules.xml new file mode 100644 index 0000000000..9d1654d9b6 --- /dev/null +++ b/app/src/main/res/menu/menu_rules.xml @@ -0,0 +1,8 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9112f76ae2..120fc16566 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1369,6 +1369,8 @@ Log Auto scroll Clear + Clear spam rules + Delete all rules moving messages to the spam folder? Debug info Please describe the problem and indicate the time of the problem: Please describe what you were doing when the app crashed: