From 3646314a13048d279bbca265ebaf951be94c0680 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 20 May 2020 14:11:55 +0200 Subject: [PATCH] support notification badge/dot --- .../securesms/notifications/NotificationCenter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/org/thoughtcrime/securesms/notifications/NotificationCenter.java b/src/org/thoughtcrime/securesms/notifications/NotificationCenter.java index a1e787f39..4890dcedd 100644 --- a/src/org/thoughtcrime/securesms/notifications/NotificationCenter.java +++ b/src/org/thoughtcrime/securesms/notifications/NotificationCenter.java @@ -235,6 +235,7 @@ public class NotificationCenter { channel.setDescription("Informs about new messages."); channel.setGroup(getNotificationChannelGroup(notificationManager)); channel.enableVibration(defaultVibrate); + channel.setShowBadge(true); if (!ledColor.equals("none")) { channel.enableLights(true); @@ -347,6 +348,14 @@ public class NotificationCenter { } } catch (Exception e) { Log.w(TAG, e); } + // messages count, some os make some use of that + // - do not use setSubText() as this is displayed together with setContentInfo() eg. on Lollipop + // - setNumber() may overwrite setContentInfo(), should be called last + // weird stuff. + int cnt = dcContext.getFreshMsgCount(chatId); + builder.setContentInfo(String.valueOf(cnt)); + builder.setNumber(cnt); + // add notification, we use one notification per chat, // esp. older android are not that great at grouping notificationManager.notify(ID_MSG_OFFSET+chatId, builder.build());