mirror of https://github.com/M66B/FairEmail.git
Show redacted new messages notification on lock screen
This commit is contained in:
parent
47da72c70b
commit
06117eaf85
|
@ -70,12 +70,14 @@ public class ApplicationEx extends Application {
|
||||||
NotificationManager.IMPORTANCE_MIN);
|
NotificationManager.IMPORTANCE_MIN);
|
||||||
service.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
service.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
||||||
service.setShowBadge(false);
|
service.setShowBadge(false);
|
||||||
|
service.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||||
nm.createNotificationChannel(service);
|
nm.createNotificationChannel(service);
|
||||||
|
|
||||||
NotificationChannel notification = new NotificationChannel(
|
NotificationChannel notification = new NotificationChannel(
|
||||||
"notification",
|
"notification",
|
||||||
getString(R.string.channel_notification),
|
getString(R.string.channel_notification),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
notification.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
nm.createNotificationChannel(notification);
|
nm.createNotificationChannel(notification);
|
||||||
|
|
||||||
NotificationChannel error = new NotificationChannel(
|
NotificationChannel error = new NotificationChannel(
|
||||||
|
@ -83,6 +85,7 @@ public class ApplicationEx extends Application {
|
||||||
getString(R.string.channel_error),
|
getString(R.string.channel_error),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
error.setShowBadge(false);
|
error.setShowBadge(false);
|
||||||
|
error.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||||
nm.createNotificationChannel(error);
|
nm.createNotificationChannel(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,24 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
clear.setAction("clear");
|
clear.setAction("clear");
|
||||||
PendingIntent piClear = PendingIntent.getService(this, PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent piClear = PendingIntent.getService(this, PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
|
// Build public notification
|
||||||
|
Notification.Builder pbuilder;
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
||||||
|
pbuilder = new Notification.Builder(this);
|
||||||
|
else
|
||||||
|
pbuilder = new Notification.Builder(this, "notification");
|
||||||
|
|
||||||
|
pbuilder
|
||||||
|
.setSmallIcon(R.drawable.baseline_email_white_24)
|
||||||
|
.setContentTitle(getResources().getQuantityString(R.plurals.title_notification_unseen, messages.size(), messages.size()))
|
||||||
|
.setContentIntent(piView)
|
||||||
|
.setNumber(messages.size())
|
||||||
|
.setShowWhen(false)
|
||||||
|
.setDeleteIntent(piClear)
|
||||||
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
||||||
|
.setCategory(Notification.CATEGORY_STATUS)
|
||||||
|
.setVisibility(Notification.VISIBILITY_PUBLIC);
|
||||||
|
|
||||||
// Build notification
|
// Build notification
|
||||||
Notification.Builder builder;
|
Notification.Builder builder;
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
||||||
|
@ -386,7 +404,6 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
builder
|
builder
|
||||||
.setSmallIcon(R.drawable.baseline_email_white_24)
|
.setSmallIcon(R.drawable.baseline_email_white_24)
|
||||||
.setContentTitle(getResources().getQuantityString(R.plurals.title_notification_unseen, messages.size(), messages.size()))
|
.setContentTitle(getResources().getQuantityString(R.plurals.title_notification_unseen, messages.size(), messages.size()))
|
||||||
.setContentText("")
|
|
||||||
.setContentIntent(piView)
|
.setContentIntent(piView)
|
||||||
.setNumber(messages.size())
|
.setNumber(messages.size())
|
||||||
.setShowWhen(false)
|
.setShowWhen(false)
|
||||||
|
@ -394,6 +411,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
.setPriority(Notification.PRIORITY_DEFAULT)
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
||||||
.setCategory(Notification.CATEGORY_STATUS)
|
.setCategory(Notification.CATEGORY_STATUS)
|
||||||
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
||||||
|
.setPublicVersion(pbuilder.build())
|
||||||
.setGroup(BuildConfig.APPLICATION_ID)
|
.setGroup(BuildConfig.APPLICATION_ID)
|
||||||
.setGroupSummary(true);
|
.setGroupSummary(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue