mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 12:35:30 +03:00
Grouping Notification Messages for same users
This commit is contained in:
parent
318499ca24
commit
cddf7c9189
2 changed files with 20 additions and 4 deletions
|
@ -155,6 +155,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
|
||||
notificationManager = NotificationManagerCompat.from(context!!)
|
||||
|
||||
|
||||
pushMessage.timestamp = System.currentTimeMillis()
|
||||
|
||||
Log.d(TAG, pushMessage.toString())
|
||||
|
@ -195,6 +196,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
}
|
||||
|
||||
private fun handleCallPushMessage() {
|
||||
|
||||
val fullScreenIntent = Intent(context, CallNotificationActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ROOM_TOKEN, pushMessage.id)
|
||||
|
@ -222,6 +224,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
val uri = Uri.parse(signatureVerification.user!!.baseUrl)
|
||||
val baseUrl = uri.host
|
||||
|
||||
|
||||
val notification =
|
||||
NotificationCompat.Builder(applicationContext, notificationChannelId)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
|
@ -434,6 +437,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
val notificationBuilder = NotificationCompat.Builder(context!!, "1")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setCategory(category)
|
||||
.setGroup(signatureVerification.user!!.id.toString())
|
||||
//.setGroupAlertBehavior(GROUP_ALERT_CHILDREN)
|
||||
.setLargeIcon(getLargeIcon())
|
||||
.setSmallIcon(R.drawable.ic_logo)
|
||||
.setContentTitle(contentTitle)
|
||||
|
@ -471,8 +476,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
}
|
||||
|
||||
notificationBuilder.setContentIntent(pendingIntent)
|
||||
val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
||||
notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
||||
// val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
||||
// notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
||||
val activeStatusBarNotification = findNotificationForRoom(
|
||||
context,
|
||||
signatureVerification.user!!,
|
||||
|
@ -741,6 +746,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
|
||||
private fun sendNotification(notificationId: Int, notification: Notification) {
|
||||
Log.d(TAG, "show notification with id $notificationId")
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
applicationContext,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
|
@ -751,9 +757,19 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
|
||||
return
|
||||
}
|
||||
notificationManager.notify(notificationId, notification)
|
||||
|
||||
val summaryNotification = NotificationCompat.Builder(context!!, "1")
|
||||
.setContentTitle("Talk app notifications")
|
||||
//.setGroup(signatureVerification.user!!.id.toString())
|
||||
.setGroup(signatureVerification.user!!.id.toString())
|
||||
.setGroupSummary(true)
|
||||
.build()
|
||||
|
||||
notificationManager.notify(pushMessage.notificationId!!.toInt(), notification)
|
||||
notificationManager.notify(1, summaryNotification)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// On devices with Android 8.0 (Oreo) or later, notification sound will be handled by the system
|
||||
|
|
|
@ -52,7 +52,7 @@ import java.io.IOException
|
|||
object NotificationUtils {
|
||||
|
||||
const val TAG = "NotificationUtils"
|
||||
|
||||
//const val groupName = "1"
|
||||
enum class NotificationChannels {
|
||||
NOTIFICATION_CHANNEL_MESSAGES_V4,
|
||||
NOTIFICATION_CHANNEL_CALLS_V4,
|
||||
|
|
Loading…
Reference in a new issue