Skip to content

Commit

Permalink
[i107] expose notification color (#4920)
Browse files Browse the repository at this point in the history
* [i107] expose notification color

* [i107] add CHANGELOG

---------

Co-authored-by: kanat <>
  • Loading branch information
kanat authored Aug 16, 2023
1 parent d3315de commit 3a93ba8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
19 changes: 19 additions & 0 deletions stream-chat-android-client/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-2023 Stream.io Inc. All rights reserved.
Licensed under the Stream License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<color name="stream_ic_notification">#00000000</color>
</resources>

0 comments on commit 3a93ba8

Please sign in to comment.