Android 12: fixed ignore notification trampoline

This commit is contained in:
M66B 2021-07-15 13:38:19 +02:00
parent c0def22f5a
commit 6ec0494f39
3 changed files with 30 additions and 35 deletions

View File

@ -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")) {

View File

@ -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(

View File

@ -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);
}
}
}