From b829e09b244e8bc93f513b817866b8996dd8af53 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 10 Dec 2020 09:49:10 +0100 Subject: [PATCH] Added edit rules from spam --- .../eu/faircode/email/AdapterMessage.java | 50 ++++++++++++++++--- app/src/main/res/layout/dialog_junk.xml | 2 +- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 90f41a9e97..05666083b4 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -6365,14 +6365,48 @@ public class AdapterMessage extends RecyclerView.Adapter() { + @Override + protected EntityFolder onExecute(Context context, Bundle args) throws Throwable { + long account = args.getLong("account"); + + DB db = DB.getInstance(context); + EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); + + if (inbox == null) + throw new IllegalArgumentException(context.getString(R.string.title_no_inbox)); + + return inbox; + } + + @Override + protected void onExecuted(Bundle args, EntityFolder inbox) { + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); + lbm.sendBroadcast( + new Intent(ActivityView.ACTION_EDIT_RULES) + .putExtra("account", account) + .putExtra("protocol", protocol) + .putExtra("folder", inbox.id) + .putExtra("type", inbox.type)); + dismiss(); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Log.unexpectedError(getParentFragmentManager(), ex); + } + }.execute(FragmentDialogJunk.this, getArguments(), "junk"); + } else { + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); + lbm.sendBroadcast( + new Intent(ActivityView.ACTION_EDIT_RULES) + .putExtra("account", account) + .putExtra("protocol", protocol) + .putExtra("folder", folder) + .putExtra("type", type)); + dismiss(); + } } }); diff --git a/app/src/main/res/layout/dialog_junk.xml b/app/src/main/res/layout/dialog_junk.xml index 94448513cc..c02a864afa 100644 --- a/app/src/main/res/layout/dialog_junk.xml +++ b/app/src/main/res/layout/dialog_junk.xml @@ -88,6 +88,6 @@ android:id="@+id/grpInJunk" android:layout_width="0dp" android:layout_height="0dp" - app:constraint_referenced_ids="tvMessage,tvJunkHint,ibInfo,btnEditRules" /> + app:constraint_referenced_ids="tvMessage,tvJunkHint,ibInfo" /> \ No newline at end of file