diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 688cd9ec4e..9d69d300f7 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -1177,7 +1177,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB onMenuOutbox(); } else if (action.startsWith("thread")) { - intent.putExtra("id", Long.parseLong(action.split(":", 2)[1])); + long id = Long.parseLong(action.split(":", 2)[1]); + boolean ignore = intent.getBooleanExtra("ignore", false); + if (ignore) + ServiceUI.ignore(this, id); + intent.putExtra("id", id); onViewThread(intent); } else if (action.equals("widget")) { diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 0ec34bc39a..bd3d13f03d 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -4341,24 +4341,16 @@ class Core { args.putLong("id", id); // Build pending intents - PendingIntent piContent; - if (notify_remove) { - Intent thread = new Intent(context, ServiceUI.class); - thread.setAction("ignore:" + message.id); - thread.putExtra("view", true); - piContent = PendingIntentCompat.getService( - context, ServiceUI.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); - } else { - Intent thread = new Intent(context, ActivityView.class); - thread.setAction("thread:" + message.id); - thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - thread.putExtra("account", message.account); - thread.putExtra("folder", message.folder); - thread.putExtra("thread", message.thread); - thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(message.folderType)); - piContent = PendingIntentCompat.getActivity( - context, ActivityView.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); - } + Intent thread = new Intent(context, ActivityView.class); + thread.setAction("thread:" + message.id); + thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + thread.putExtra("account", message.account); + thread.putExtra("folder", message.folder); + thread.putExtra("thread", message.thread); + thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(message.folderType)); + thread.putExtra("ignore", notify_remove); + PendingIntent piContent = PendingIntentCompat.getActivity( + context, ActivityView.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); Intent ignore = new Intent(context, ServiceUI.class).setAction("ignore:" + message.id); PendingIntent piIgnore = PendingIntentCompat.getService( diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index f8b3792b8c..5260f53f41 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -150,8 +150,7 @@ public class ServiceUI extends IntentService { break; case "ignore": - boolean view = intent.getBooleanExtra("view", false); - onIgnore(id, view); + onIgnore(id); break; case "wakeup": @@ -427,7 +426,7 @@ public class ServiceUI extends IntentService { } } - private void onIgnore(long id, boolean open) { + private void onIgnore(long id) { EntityMessage message; EntityFolder folder; @@ -449,17 +448,6 @@ public class ServiceUI extends IntentService { } finally { db.endTransaction(); } - - if (open) { - Intent thread = new Intent(this, ActivityView.class); - thread.setAction("thread:" + message.id); - thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - thread.putExtra("account", message.account); - thread.putExtra("folder", message.folder); - thread.putExtra("thread", message.thread); - thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(folder.type)); - startActivity(thread); - } } private void onSync(long aid) { @@ -484,8 +472,9 @@ public class ServiceUI extends IntentService { static void sync(Context context, Long account) { try { - context.startService(new Intent(context, ServiceUI.class) - .setAction(account == null ? "sync" : "sync:" + account)); + Intent sync = new Intent(context, ServiceUI.class) + .setAction(account == null ? "sync" : "sync:" + account); + context.startService(sync); } catch (Throwable ex) { Log.e(ex); /* @@ -499,4 +488,14 @@ public class ServiceUI extends IntentService { */ } } + + static void ignore(Context context, long id) { + try { + Intent ignore = new Intent(context, ServiceUI.class) + .setAction("ignore:" + id); + context.startService(ignore); + } catch (Throwable ex) { + Log.e(ex); + } + } }