Android 12: fixed ignore notification trampoline

pull/200/head
M66B 4 years ago
parent c0def22f5a
commit 6ec0494f39

@ -1177,7 +1177,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
onMenuOutbox(); onMenuOutbox();
} else if (action.startsWith("thread")) { } 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); onViewThread(intent);
} else if (action.equals("widget")) { } else if (action.equals("widget")) {

@ -4341,24 +4341,16 @@ class Core {
args.putLong("id", id); args.putLong("id", id);
// Build pending intents // Build pending intents
PendingIntent piContent; Intent thread = new Intent(context, ActivityView.class);
if (notify_remove) { thread.setAction("thread:" + message.id);
Intent thread = new Intent(context, ServiceUI.class); thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
thread.setAction("ignore:" + message.id); thread.putExtra("account", message.account);
thread.putExtra("view", true); thread.putExtra("folder", message.folder);
piContent = PendingIntentCompat.getService( thread.putExtra("thread", message.thread);
context, ServiceUI.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(message.folderType));
} else { thread.putExtra("ignore", notify_remove);
Intent thread = new Intent(context, ActivityView.class); PendingIntent piContent = PendingIntentCompat.getActivity(
thread.setAction("thread:" + message.id); context, ActivityView.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);
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 ignore = new Intent(context, ServiceUI.class).setAction("ignore:" + message.id); Intent ignore = new Intent(context, ServiceUI.class).setAction("ignore:" + message.id);
PendingIntent piIgnore = PendingIntentCompat.getService( PendingIntent piIgnore = PendingIntentCompat.getService(

@ -150,8 +150,7 @@ public class ServiceUI extends IntentService {
break; break;
case "ignore": case "ignore":
boolean view = intent.getBooleanExtra("view", false); onIgnore(id);
onIgnore(id, view);
break; break;
case "wakeup": 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; EntityMessage message;
EntityFolder folder; EntityFolder folder;
@ -449,17 +448,6 @@ public class ServiceUI extends IntentService {
} finally { } finally {
db.endTransaction(); 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) { private void onSync(long aid) {
@ -484,8 +472,9 @@ public class ServiceUI extends IntentService {
static void sync(Context context, Long account) { static void sync(Context context, Long account) {
try { try {
context.startService(new Intent(context, ServiceUI.class) Intent sync = new Intent(context, ServiceUI.class)
.setAction(account == null ? "sync" : "sync:" + account)); .setAction(account == null ? "sync" : "sync:" + account);
context.startService(sync);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(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);
}
}
} }

Loading…
Cancel
Save