Suppress notification content when using biometric authentication

pull/157/head
M66B 6 years ago
parent 955c997736
commit cb5fd98909

@ -1799,6 +1799,7 @@ class Core {
return; return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false);
boolean badge = prefs.getBoolean("badge", true); boolean badge = prefs.getBoolean("badge", true);
boolean pro = Helper.isPro(context); boolean pro = Helper.isPro(context);
@ -1883,7 +1884,7 @@ class Core {
for (Notification notification : notifications) { for (Notification notification : notifications) {
long id = notification.extras.getLong("id", 0); long id = notification.extras.getLong("id", 0);
if ((id == 0 && add.size() + remove.size() > 0) || add.contains(id)) { if ((id == 0 && add.size() + remove.size() > 0) || (add.contains(id) && !biometrics)) {
String tag = "unseen." + group + "." + Math.abs(id); String tag = "unseen." + group + "." + Math.abs(id);
Log.i("Notifying tag=" + tag + Log.i("Notifying tag=" + tag +
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId())); (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId()));
@ -1928,6 +1929,7 @@ class Core {
boolean pro = Helper.isPro(context); boolean pro = Helper.isPro(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false);
boolean flags = prefs.getBoolean("flags", true); boolean flags = prefs.getBoolean("flags", true);
boolean notify_preview = prefs.getBoolean("notify_preview", true); boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro); boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro);
@ -1965,16 +1967,18 @@ class Core {
.setDeleteIntent(piClear) .setDeleteIntent(piClear)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
.setGroup(group)
.setGroupSummary(true)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
Notification pub = builder.build(); Notification pub = builder.build();
builder builder
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setPublicVersion(pub); .setPublicVersion(pub);
if (!biometrics) {
builder.setGroup(group)
.setGroupSummary(true)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT); DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (EntityMessage message : messages) { for (EntityMessage message : messages) {
@ -1988,6 +1992,7 @@ class Core {
builder.setStyle(new NotificationCompat.BigTextStyle() builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(HtmlHelper.fromHtml(sb.toString())) .bigText(HtmlHelper.fromHtml(sb.toString()))
.setSummaryText(title)); .setSummaryText(title));
}
notifications.add(builder.build()); notifications.add(builder.build());

Loading…
Cancel
Save