mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +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!!)
|
notificationManager = NotificationManagerCompat.from(context!!)
|
||||||
|
|
||||||
|
|
||||||
pushMessage.timestamp = System.currentTimeMillis()
|
pushMessage.timestamp = System.currentTimeMillis()
|
||||||
|
|
||||||
Log.d(TAG, pushMessage.toString())
|
Log.d(TAG, pushMessage.toString())
|
||||||
|
@ -195,6 +196,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleCallPushMessage() {
|
private fun handleCallPushMessage() {
|
||||||
|
|
||||||
val fullScreenIntent = Intent(context, CallNotificationActivity::class.java)
|
val fullScreenIntent = Intent(context, CallNotificationActivity::class.java)
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(KEY_ROOM_TOKEN, pushMessage.id)
|
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 uri = Uri.parse(signatureVerification.user!!.baseUrl)
|
||||||
val baseUrl = uri.host
|
val baseUrl = uri.host
|
||||||
|
|
||||||
|
|
||||||
val notification =
|
val notification =
|
||||||
NotificationCompat.Builder(applicationContext, notificationChannelId)
|
NotificationCompat.Builder(applicationContext, notificationChannelId)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
|
@ -434,6 +437,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
val notificationBuilder = NotificationCompat.Builder(context!!, "1")
|
val notificationBuilder = NotificationCompat.Builder(context!!, "1")
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setCategory(category)
|
.setCategory(category)
|
||||||
|
.setGroup(signatureVerification.user!!.id.toString())
|
||||||
|
//.setGroupAlertBehavior(GROUP_ALERT_CHILDREN)
|
||||||
.setLargeIcon(getLargeIcon())
|
.setLargeIcon(getLargeIcon())
|
||||||
.setSmallIcon(R.drawable.ic_logo)
|
.setSmallIcon(R.drawable.ic_logo)
|
||||||
.setContentTitle(contentTitle)
|
.setContentTitle(contentTitle)
|
||||||
|
@ -471,8 +476,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationBuilder.setContentIntent(pendingIntent)
|
notificationBuilder.setContentIntent(pendingIntent)
|
||||||
val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
// val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
||||||
notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
// notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
||||||
val activeStatusBarNotification = findNotificationForRoom(
|
val activeStatusBarNotification = findNotificationForRoom(
|
||||||
context,
|
context,
|
||||||
signatureVerification.user!!,
|
signatureVerification.user!!,
|
||||||
|
@ -741,6 +746,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
|
|
||||||
private fun sendNotification(notificationId: Int, notification: Notification) {
|
private fun sendNotification(notificationId: Int, notification: Notification) {
|
||||||
Log.d(TAG, "show notification with id $notificationId")
|
Log.d(TAG, "show notification with id $notificationId")
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(
|
if (ActivityCompat.checkSelfPermission(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
|
@ -751,9 +757,19 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
// int[] grantResults)
|
// int[] grantResults)
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
// to handle the case where the user grants the permission. See the documentation
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
// for ActivityCompat#requestPermissions for more details.
|
||||||
|
|
||||||
return
|
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) {
|
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
|
// 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 {
|
object NotificationUtils {
|
||||||
|
|
||||||
const val TAG = "NotificationUtils"
|
const val TAG = "NotificationUtils"
|
||||||
|
//const val groupName = "1"
|
||||||
enum class NotificationChannels {
|
enum class NotificationChannels {
|
||||||
NOTIFICATION_CHANNEL_MESSAGES_V4,
|
NOTIFICATION_CHANNEL_MESSAGES_V4,
|
||||||
NOTIFICATION_CHANNEL_CALLS_V4,
|
NOTIFICATION_CHANNEL_CALLS_V4,
|
||||||
|
|
Loading…
Reference in a new issue