Move notification_accent_color from resource file to NotificationConfig
This commit is contained in:
@@ -28,6 +28,7 @@ anvil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(libs.androidx.annotationjvm)
|
||||||
implementation(libs.dagger)
|
implementation(libs.dagger)
|
||||||
implementation(projects.libraries.di)
|
implementation(projects.libraries.di)
|
||||||
implementation(projects.libraries.matrix.api)
|
implementation(projects.libraries.matrix.api)
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package io.element.android.appconfig
|
package io.element.android.appconfig
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
|
||||||
object NotificationConfig {
|
object NotificationConfig {
|
||||||
// TODO EAx Implement and set to true at some point
|
// TODO EAx Implement and set to true at some point
|
||||||
const val SUPPORT_MARK_AS_READ_ACTION = false
|
const val SUPPORT_MARK_AS_READ_ACTION = false
|
||||||
@@ -25,4 +28,7 @@ object NotificationConfig {
|
|||||||
|
|
||||||
// TODO EAx Implement and set to true at some point
|
// TODO EAx Implement and set to true at some point
|
||||||
const val SUPPORT_QUICK_REPLY_ACTION = false
|
const val SUPPORT_QUICK_REPLY_ACTION = false
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
val NOTIFICATION_ACCENT_COLOR: Int = Color.parseColor("#FF368BD6")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import android.os.Build
|
|||||||
import androidx.annotation.ChecksSdkIntAtLeast
|
import androidx.annotation.ChecksSdkIntAtLeast
|
||||||
import androidx.core.app.NotificationChannelCompat
|
import androidx.core.app.NotificationChannelCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
|
import io.element.android.appconfig.NotificationConfig
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
import io.element.android.libraries.di.ApplicationContext
|
||||||
import io.element.android.libraries.di.SingleIn
|
import io.element.android.libraries.di.SingleIn
|
||||||
@@ -89,7 +89,7 @@ class DefaultNotificationChannels @Inject constructor(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
val accentColor = NotificationConfig.NOTIFICATION_ACCENT_COLOR
|
||||||
|
|
||||||
// Migration - the noisy channel was deleted and recreated when sound preference was changed (id was DEFAULT_NOISY_NOTIFICATION_CHANNEL_ID_BASE
|
// Migration - the noisy channel was deleted and recreated when sound preference was changed (id was DEFAULT_NOISY_NOTIFICATION_CHANNEL_ID_BASE
|
||||||
// + currentTimeMillis).
|
// + currentTimeMillis).
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import androidx.annotation.DrawableRes
|
|||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationCompat.MessagingStyle
|
import androidx.core.app.NotificationCompat.MessagingStyle
|
||||||
import androidx.core.app.Person
|
import androidx.core.app.Person
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
@@ -107,6 +106,8 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
private val acceptInvitationActionFactory: AcceptInvitationActionFactory,
|
private val acceptInvitationActionFactory: AcceptInvitationActionFactory,
|
||||||
private val rejectInvitationActionFactory: RejectInvitationActionFactory
|
private val rejectInvitationActionFactory: RejectInvitationActionFactory
|
||||||
) : NotificationCreator {
|
) : NotificationCreator {
|
||||||
|
private val accentColor = NotificationConfig.NOTIFICATION_ACCENT_COLOR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a notification for a Room.
|
* Create a notification for a Room.
|
||||||
*/
|
*/
|
||||||
@@ -121,7 +122,6 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
imageLoader: ImageLoader,
|
imageLoader: ImageLoader,
|
||||||
events: List<NotifiableMessageEvent>,
|
events: List<NotifiableMessageEvent>,
|
||||||
): Notification {
|
): Notification {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
|
||||||
// Build the pending intent for when the notification is clicked
|
// Build the pending intent for when the notification is clicked
|
||||||
val openIntent = when {
|
val openIntent = when {
|
||||||
threadId != null -> pendingIntentFactory.createOpenThreadPendingIntent(roomInfo, threadId)
|
threadId != null -> pendingIntentFactory.createOpenThreadPendingIntent(roomInfo, threadId)
|
||||||
@@ -228,7 +228,6 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
override fun createRoomInvitationNotification(
|
override fun createRoomInvitationNotification(
|
||||||
inviteNotifiableEvent: InviteNotifiableEvent
|
inviteNotifiableEvent: InviteNotifiableEvent
|
||||||
): Notification {
|
): Notification {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
|
||||||
val smallIcon = CommonDrawables.ic_notification_small
|
val smallIcon = CommonDrawables.ic_notification_small
|
||||||
val channelId = notificationChannels.getChannelIdForMessage(inviteNotifiableEvent.noisy)
|
val channelId = notificationChannels.getChannelIdForMessage(inviteNotifiableEvent.noisy)
|
||||||
return NotificationCompat.Builder(context, channelId)
|
return NotificationCompat.Builder(context, channelId)
|
||||||
@@ -273,7 +272,6 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
override fun createSimpleEventNotification(
|
override fun createSimpleEventNotification(
|
||||||
simpleNotifiableEvent: SimpleNotifiableEvent,
|
simpleNotifiableEvent: SimpleNotifiableEvent,
|
||||||
): Notification {
|
): Notification {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
|
||||||
val smallIcon = CommonDrawables.ic_notification_small
|
val smallIcon = CommonDrawables.ic_notification_small
|
||||||
|
|
||||||
val channelId = notificationChannels.getChannelIdForMessage(simpleNotifiableEvent.noisy)
|
val channelId = notificationChannels.getChannelIdForMessage(simpleNotifiableEvent.noisy)
|
||||||
@@ -307,7 +305,6 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
override fun createFallbackNotification(
|
override fun createFallbackNotification(
|
||||||
fallbackNotifiableEvent: FallbackNotifiableEvent,
|
fallbackNotifiableEvent: FallbackNotifiableEvent,
|
||||||
): Notification {
|
): Notification {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
|
||||||
val smallIcon = CommonDrawables.ic_notification_small
|
val smallIcon = CommonDrawables.ic_notification_small
|
||||||
|
|
||||||
val channelId = notificationChannels.getChannelIdForMessage(false)
|
val channelId = notificationChannels.getChannelIdForMessage(false)
|
||||||
@@ -344,7 +341,6 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
noisy: Boolean,
|
noisy: Boolean,
|
||||||
lastMessageTimestamp: Long
|
lastMessageTimestamp: Long
|
||||||
): Notification {
|
): Notification {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
|
||||||
val smallIcon = CommonDrawables.ic_notification_small
|
val smallIcon = CommonDrawables.ic_notification_small
|
||||||
val channelId = notificationChannels.getChannelIdForMessage(noisy)
|
val channelId = notificationChannels.getChannelIdForMessage(noisy)
|
||||||
return NotificationCompat.Builder(context, channelId)
|
return NotificationCompat.Builder(context, channelId)
|
||||||
@@ -384,7 +380,7 @@ class DefaultNotificationCreator @Inject constructor(
|
|||||||
.setContentText(stringProvider.getString(R.string.notification_test_push_notification_content))
|
.setContentText(stringProvider.getString(R.string.notification_test_push_notification_content))
|
||||||
.setSmallIcon(CommonDrawables.ic_notification_small)
|
.setSmallIcon(CommonDrawables.ic_notification_small)
|
||||||
.setLargeIcon(getBitmap(R.drawable.element_logo_green))
|
.setLargeIcon(getBitmap(R.drawable.element_logo_green))
|
||||||
.setColor(ContextCompat.getColor(context, R.color.notification_accent_color))
|
.setColor(accentColor)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setCategory(NotificationCompat.CATEGORY_STATUS)
|
.setCategory(NotificationCompat.CATEGORY_STATUS)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
~ Copyright (c) 2023 New Vector Ltd
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ 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="notification_accent_color">#368BD6</color>
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
Reference in New Issue
Block a user