Added dedicated notification channel for missed calls with low priority and removed wrong use of Event category
This commit is contained in:
parent
bb5b098007
commit
80e5a7830d
6 changed files with 37 additions and 22 deletions
|
@ -168,8 +168,8 @@ dependencies {
|
|||
implementation 'androidx.media:media:1.2.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.5'
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||
|
|
|
@ -52,12 +52,9 @@ class Api26Compatibility {
|
|||
fun createServiceChannel(context: Context, notificationManager: NotificationManagerCompat) {
|
||||
// Create service notification channel
|
||||
val id = context.getString(R.string.notification_channel_service_id)
|
||||
val name: CharSequence =
|
||||
context.getString(R.string.notification_channel_service_name)
|
||||
val description =
|
||||
context.getString(R.string.notification_channel_service_name)
|
||||
val channel =
|
||||
NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW)
|
||||
val name = context.getString(R.string.notification_channel_service_name)
|
||||
val description = context.getString(R.string.notification_channel_service_name)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW)
|
||||
channel.description = description
|
||||
channel.enableVibration(false)
|
||||
channel.enableLights(false)
|
||||
|
@ -65,18 +62,31 @@ class Api26Compatibility {
|
|||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
fun createMissedCallChannel(
|
||||
context: Context,
|
||||
notificationManager: NotificationManagerCompat
|
||||
) {
|
||||
val id = context.getString(R.string.notification_channel_missed_call_id)
|
||||
val name = context.getString(R.string.notification_channel_missed_call_name)
|
||||
val description = context.getString(R.string.notification_channel_missed_call_name)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW)
|
||||
channel.description = description
|
||||
channel.lightColor = context.getColor(R.color.notification_led_color)
|
||||
channel.enableVibration(true)
|
||||
channel.enableLights(true)
|
||||
channel.setShowBadge(true)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
fun createIncomingCallChannel(
|
||||
context: Context,
|
||||
notificationManager: NotificationManagerCompat
|
||||
) {
|
||||
// Create incoming calls notification channel
|
||||
val id = context.getString(R.string.notification_channel_incoming_call_id)
|
||||
val name: CharSequence =
|
||||
context.getString(R.string.notification_channel_incoming_call_name)
|
||||
val description =
|
||||
context.getString(R.string.notification_channel_incoming_call_name)
|
||||
val channel =
|
||||
NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
val name = context.getString(R.string.notification_channel_incoming_call_name)
|
||||
val description = context.getString(R.string.notification_channel_incoming_call_name)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel.description = description
|
||||
channel.lightColor = context.getColor(R.color.notification_led_color)
|
||||
channel.enableVibration(true)
|
||||
|
@ -85,13 +95,15 @@ class Api26Compatibility {
|
|||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
fun createMessageChannel(context: Context, notificationManager: NotificationManagerCompat) {
|
||||
fun createMessageChannel(
|
||||
context: Context,
|
||||
notificationManager: NotificationManagerCompat
|
||||
) {
|
||||
// Create messages notification channel
|
||||
val id = context.getString(R.string.notification_channel_chat_id)
|
||||
val name = context.getString(R.string.notification_channel_chat_name)
|
||||
val description = context.getString(R.string.notification_channel_chat_name)
|
||||
val channel =
|
||||
NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel.description = description
|
||||
channel.lightColor = context.getColor(R.color.notification_led_color)
|
||||
channel.enableLights(true)
|
||||
|
|
|
@ -80,6 +80,7 @@ class Compatibility {
|
|||
) {
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||
Api26Compatibility.createServiceChannel(context, notificationManager)
|
||||
Api26Compatibility.createMissedCallChannel(context, notificationManager)
|
||||
Api26Compatibility.createIncomingCallChannel(context, notificationManager)
|
||||
Api26Compatibility.createMessageChannel(context, notificationManager)
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ class NotificationsManager(private val context: Context) {
|
|||
.setContentText(if (useAutoStartDescription) context.getString(R.string.service_auto_start_description) else context.getString(R.string.service_description))
|
||||
.setSmallIcon(R.drawable.topbar_service_notification)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setCategory(Notification.CATEGORY_SERVICE)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setShowWhen(true)
|
||||
|
@ -419,13 +419,13 @@ class NotificationsManager(private val context: Context) {
|
|||
.createPendingIntent()
|
||||
|
||||
val notification = NotificationCompat.Builder(
|
||||
context, context.getString(R.string.notification_channel_incoming_call_id))
|
||||
context, context.getString(R.string.notification_channel_missed_call_id))
|
||||
.setContentTitle(context.getString(R.string.missed_call_notification_title))
|
||||
.setContentText(body)
|
||||
.setSmallIcon(R.drawable.topbar_missed_call_notification)
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setCategory(Notification.CATEGORY_EVENT)
|
||||
// .setCategory(NotificationCompat.CATEGORY_EVENT) No one really matches "missed call"
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setShowWhen(true)
|
||||
|
@ -488,7 +488,7 @@ class NotificationsManager(private val context: Context) {
|
|||
.setLargeIcon(roundPicture)
|
||||
.setAutoCancel(false)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setCategory(Notification.CATEGORY_CALL)
|
||||
.setCategory(NotificationCompat.CATEGORY_CALL)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
|
|
|
@ -542,9 +542,11 @@
|
|||
|
||||
<!-- Notifications -->
|
||||
<string name="notification_channel_service_id" translatable="false">linphone_notification_service_id</string>
|
||||
<string name="notification_channel_missed_call_id" translatable="false">linphone_notification_missed_call_id</string>
|
||||
<string name="notification_channel_incoming_call_id" translatable="false">linphone_notification_call_id</string>
|
||||
<string name="notification_channel_chat_id" translatable="false">linphone_notification_chat_id</string>
|
||||
<string name="notification_channel_service_name">&appName; service notification</string>
|
||||
<string name="notification_channel_missed_call_name">&appName; missed calls notifications</string>
|
||||
<string name="notification_channel_incoming_call_name">&appName; incoming calls notifications</string>
|
||||
<string name="notification_channel_chat_name">&appName; instant messages notifications</string>
|
||||
<string name="incoming_call_notification_title">Call incoming</string>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.20'
|
||||
ext.kotlin_version = '1.4.21'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
|
Loading…
Reference in a new issue