From 3a93ba85daf042a86c6fdcf2f1a90726fe1b2c0f Mon Sep 17 00:00:00 2001 From: Kanat Kiialbaev Date: Wed, 16 Aug 2023 14:28:39 -0700 Subject: [PATCH] [i107] expose notification color (#4920) * [i107] expose notification color * [i107] add CHANGELOG --------- Co-authored-by: kanat <> --- CHANGELOG.md | 1 + .../handler/ChatNotificationHandler.kt | 2 ++ .../MessagingStyleNotificationHandler.kt | 2 ++ .../src/main/res/values/colors.xml | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 stream-chat-android-client/src/main/res/values/colors.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cbd1a5fb64..3a7664e5989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### ⬆️ Improved ### ✅ Added +- Added `R.color.stream_ic_notification` to the list of resources that can be overridden. [#4920](https://github.com/GetStream/stream-chat-android/pull/4920) ### ⚠️ Changed diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/ChatNotificationHandler.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/ChatNotificationHandler.kt index aa74f15ecfb..f13179d5b60 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/ChatNotificationHandler.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/ChatNotificationHandler.kt @@ -25,6 +25,7 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Build import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat import androidx.core.content.edit import io.getstream.chat.android.client.R import io.getstream.chat.android.client.extensions.getUsersExcludingCurrent @@ -165,6 +166,7 @@ internal class ChatNotificationHandler( .setDefaults(NotificationCompat.DEFAULT_ALL) .setAutoCancel(true) .setSmallIcon(R.drawable.stream_ic_notification) + .setColor(ContextCompat.getColor(context, R.color.stream_ic_notification)) .setContentTitle(contentTitle) .setContentText(contentText) .setPriority(NotificationCompat.PRIORITY_HIGH) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/MessagingStyleNotificationHandler.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/MessagingStyleNotificationHandler.kt index 0c3d03cb063..8886ccda207 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/MessagingStyleNotificationHandler.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/handler/MessagingStyleNotificationHandler.kt @@ -26,6 +26,7 @@ import android.os.Build import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat import androidx.core.app.Person +import androidx.core.content.ContextCompat import androidx.core.content.edit import io.getstream.chat.android.client.ChatClient import io.getstream.chat.android.client.R @@ -90,6 +91,7 @@ internal class MessagingStyleNotificationHandler( val initialMessagingStyle = restoreMessagingStyle(channel) ?: createMessagingStyle(currentUser, channel) val notification = NotificationCompat.Builder(context, getNotificationChannelId()) .setSmallIcon(R.drawable.stream_ic_notification) + .setColor(ContextCompat.getColor(context, R.color.stream_ic_notification)) .setStyle(initialMessagingStyle.addMessage(message.toMessagingStyleMessage(context))) .setContentIntent(contentPendingIntent) .addAction(NotificationMessageReceiver.createReadAction(context, notificationId, channel, message)) diff --git a/stream-chat-android-client/src/main/res/values/colors.xml b/stream-chat-android-client/src/main/res/values/colors.xml new file mode 100644 index 00000000000..7b5bb22f7ce --- /dev/null +++ b/stream-chat-android-client/src/main/res/values/colors.xml @@ -0,0 +1,19 @@ + + + + #00000000 +