From 8b1a8094643aae5898feac0dc696550cc36ddc56 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 24 Feb 2023 10:05:17 +0100 Subject: [PATCH] Handle new subject for call recording notification see https://github.com/nextcloud/spreed/pull/8837 Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/jobs/NotificationWorker.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt index fc5f1b77a..80da76747 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt @@ -347,8 +347,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor if ("recording" == ncNotification.objectType) { val notificationDialogData = NotificationDialogData() - notificationDialogData.title = context?.getString(R.string.record_file_available).orEmpty() - notificationDialogData.text = ncNotification.subject.orEmpty() + notificationDialogData.title = pushMessage.subject + notificationDialogData.text = pushMessage.text.orEmpty() for (action in ncNotification.actions!!) { if (action.primary) { @@ -371,9 +371,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor } private fun enrichPushMessageByNcNotificationData( - ncNotification: com.nextcloud.talk.models.json.notifications.Notification? + ncNotification: com.nextcloud.talk.models.json.notifications.Notification ) { - if (ncNotification!!.messageRichParameters != null && + pushMessage.objectId = ncNotification.objectId + pushMessage.timestamp = ncNotification.datetime!!.millis + + if (ncNotification.messageRichParameters != null && ncNotification.messageRichParameters!!.size > 0 ) { pushMessage.text = getParsedMessage( @@ -385,9 +388,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor } val subjectRichParameters = ncNotification.subjectRichParameters - - pushMessage.timestamp = ncNotification.datetime!!.millis - if (subjectRichParameters != null && subjectRichParameters.size > 0) { val callHashMap = subjectRichParameters["call"] val userHashMap = subjectRichParameters["user"] @@ -408,9 +408,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor if (callHashMap.containsKey("call-type")) { conversationType = callHashMap["call-type"] } - if ("recording" == ncNotification.objectType) { - conversationType = "recording" - } } val notificationUser = NotificationUser() if (userHashMap != null && userHashMap.isNotEmpty()) { @@ -424,8 +421,13 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor notificationUser.name = guestHashMap["name"] pushMessage.notificationUser = notificationUser } + } else { + pushMessage.subject = ncNotification.subject.orEmpty() + } + + if ("recording" == ncNotification.objectType) { + conversationType = "recording" } - pushMessage.objectId = ncNotification.objectId } @Suppress("MagicNumber") @@ -487,13 +489,13 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor .setSmallIcon(smallIcon) .setCategory(category) .setPriority(priority) + .setContentTitle(contentTitle) + .setContentText(contentText) .setSubText(baseUrl) .setWhen(pushMessage.timestamp) .setShowWhen(true) .setContentIntent(pendingIntent) .setAutoCancel(true) - .setContentTitle(contentTitle) - .setContentText(contentText) .setColor(context!!.resources.getColor(R.color.colorPrimary)) val notificationInfoBundle = Bundle()