Commit 0846097e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Notifications below on Android below Nougat should only be grouped if there is...

Notifications below on Android below Nougat should only be grouped if there is more than one message
parent b3483561
...@@ -145,16 +145,21 @@ object PushManager { ...@@ -145,16 +145,21 @@ object PushManager {
manager.notify(groupTuple.first, groupNotification) manager.notify(groupTuple.first, groupNotification)
} else { } else {
val notification = createSingleNotification(context, lastPushMessage) val notification = createSingleNotification(context, lastPushMessage)
val groupNotification = createGroupNotification(context, lastPushMessage) val pushMessageList = hostToPushMessageList.get(host)
NotificationManagerCompat.from(context).notify(notId, notification) NotificationManagerCompat.from(context).notify(notId, notification)
NotificationManagerCompat.from(context).notify(groupTuple.first, groupNotification) pushMessageList?.let {
if (pushMessageList.size > 1) {
val groupNotification = createGroupNotification(context, lastPushMessage)
NotificationManagerCompat.from(context).notify(groupTuple.first, groupNotification)
}
}
} }
} }
private fun createGroupNotification(context: Context, lastPushMessage: PushMessage): Notification { private fun createGroupNotification(context: Context, lastPushMessage: PushMessage): Notification {
with(lastPushMessage) { with(lastPushMessage) {
val id = lastPushMessage.notificationId.toInt() val id = lastPushMessage.notificationId.toInt()
val contentIntent = getContentIntent(context, id, lastPushMessage, grouped = true) val contentIntent = getContentIntent(context, id, lastPushMessage)
val deleteIntent = getDismissIntent(context, lastPushMessage) val deleteIntent = getDismissIntent(context, lastPushMessage)
val builder = NotificationCompat.Builder(context) val builder = NotificationCompat.Builder(context)
.setWhen(createdAt) .setWhen(createdAt)
...@@ -297,7 +302,6 @@ object PushManager { ...@@ -297,7 +302,6 @@ object PushManager {
.setDeleteIntent(deleteIntent) .setDeleteIntent(deleteIntent)
.setContentIntent(contentIntent) .setContentIntent(contentIntent)
.setMessageNotification() .setMessageNotification()
.addReplyAction(lastPushMessage)
val subText = RocketChatCache(context).getHostSiteName(lastPushMessage.host) val subText = RocketChatCache(context).getHostSiteName(lastPushMessage.host)
if (subText.isNotEmpty()) { if (subText.isNotEmpty()) {
...@@ -309,10 +313,10 @@ object PushManager { ...@@ -309,10 +313,10 @@ object PushManager {
pushMessageList?.let { pushMessageList?.let {
if (pushMessageList.isNotEmpty()) { if (pushMessageList.isNotEmpty()) {
val messageCount = pushMessageList.size val messageCount = pushMessageList.size
val bigText = NotificationCompat.BigTextStyle() val bigText = NotificationCompat.BigTextStyle()
.bigText(pushMessageList.last().message.fromHtml()) .bigText(pushMessageList.last().message.fromHtml())
.setBigContentTitle(pushMessageList.last().title.fromHtml()) .setBigContentTitle(pushMessageList.last().title.fromHtml())
builder.setStyle(bigText).setNumber(messageCount) builder.setStyle(bigText).setNumber(messageCount)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment