From a09b77e5454e6b3d4c479f5689c53faa97f85d11 Mon Sep 17 00:00:00 2001 From: Tiebe Groosman Date: Sun, 14 Apr 2024 14:29:29 +0200 Subject: [PATCH] Message content on notification --- .../nl/tiebe/otarium/utils/BackgroundManager.android.kt | 3 ++- .../commonMain/kotlin/nl/tiebe/otarium/magister/Messages.kt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shared/src/androidMain/kotlin/nl/tiebe/otarium/utils/BackgroundManager.android.kt b/shared/src/androidMain/kotlin/nl/tiebe/otarium/utils/BackgroundManager.android.kt index 606f2335..868bf96a 100644 --- a/shared/src/androidMain/kotlin/nl/tiebe/otarium/utils/BackgroundManager.android.kt +++ b/shared/src/androidMain/kotlin/nl/tiebe/otarium/utils/BackgroundManager.android.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.graphics.toArgb import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.core.text.HtmlCompat import androidx.work.* import com.google.common.util.concurrent.Futures import com.google.common.util.concurrent.ListenableFuture @@ -187,7 +188,7 @@ fun sendNotificationAndroid(context: Context, title: String, message: String) { .setColor(Color(nl.tiebe.otarium.Data.customDarkTheme.primary).toArgb()) if (message != "") { - builder.setContentText(message) + builder.setContentText(HtmlCompat.fromHtml(message, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()) } if (ActivityCompat.checkSelfPermission( diff --git a/shared/src/commonMain/kotlin/nl/tiebe/otarium/magister/Messages.kt b/shared/src/commonMain/kotlin/nl/tiebe/otarium/magister/Messages.kt index c38f6e32..8602f0cb 100644 --- a/shared/src/commonMain/kotlin/nl/tiebe/otarium/magister/Messages.kt +++ b/shared/src/commonMain/kotlin/nl/tiebe/otarium/magister/Messages.kt @@ -20,8 +20,10 @@ suspend fun MagisterAccount.refreshMessages(notification: (String, String) -> Un updated.add(message) if (message.hasBeenRead) continue@newMessages + val content = MessageFlow.getMessageData(Url(tenantUrl), tokens.accessToken, message.links.self?.href ?: continue@newMessages) + notification( - "Nieuw bericht van ${message.sender?.name?.trim()}: ${message.subject.trim()}", "" + "Nieuw bericht van ${message.sender?.name?.trim()}: ${message.subject.trim()}", content.content ) }