From 3f3fe497672df7ef88c61ae59d230b17e860504f Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 6 Nov 2018 09:45:10 +0000 Subject: [PATCH] Add person to notification --- .../java/eu/faircode/email/ServiceSynchronize.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 5fd78710d4..8029740d40 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -24,6 +24,7 @@ import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.app.Person; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentUris; @@ -401,7 +402,7 @@ public class ServiceSynchronize extends LifecycleService { else builder.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN); - if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O && + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && prefs.getBoolean("light", false)) { builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS); builder.setLights(0xff00ff00, 1000, 1000); @@ -482,7 +483,7 @@ public class ServiceSynchronize extends LifecycleService { .setWhen(message.sent == null ? message.received : message.sent) .setDeleteIntent(piDelete) .setPriority(Notification.PRIORITY_DEFAULT) - .setCategory(Notification.CATEGORY_STATUS) + .setCategory(Notification.CATEGORY_MESSAGE) .setVisibility(Notification.VISIBILITY_PRIVATE) .setGroup(BuildConfig.APPLICATION_ID) .setGroupSummary(false) @@ -494,6 +495,12 @@ public class ServiceSynchronize extends LifecycleService { if (!TextUtils.isEmpty(message.subject)) mbuilder.setContentText(message.subject); + if (!TextUtils.isEmpty(message.avatar)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) + mbuilder.addPerson(new Person.Builder().setUri(message.avatar).build()); + else + mbuilder.addPerson(message.avatar); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) mbuilder.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);