mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Changes regarding call notifications
This commit is contained in:
parent
43c22b8ed5
commit
c447b2699c
4 changed files with 62 additions and 41 deletions
|
|
@ -473,7 +473,7 @@ class ContactsManager @UiThread constructor() {
|
|||
|
||||
val identity = account?.params?.identityAddress?.asStringUriOnly() ?: localAddress.asStringUriOnly()
|
||||
personBuilder.setKey(identity)
|
||||
personBuilder.setImportant(false)
|
||||
personBuilder.setImportant(true)
|
||||
return personBuilder.build()
|
||||
}
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ fun Friend.getPerson(): Person {
|
|||
|
||||
personBuilder.setKey(refKey)
|
||||
personBuilder.setUri(nativeUri)
|
||||
personBuilder.setImportant(starred)
|
||||
personBuilder.setImportant(true)
|
||||
return personBuilder.build()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ import org.linphone.core.Core
|
|||
import org.linphone.core.CoreForegroundService
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.call.CallActivity
|
||||
import org.linphone.ui.main.MainActivity
|
||||
|
|
@ -797,9 +798,9 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val isVideo = if (isConference) {
|
||||
true
|
||||
} else if (isIncoming) {
|
||||
call.remoteParams?.isVideoEnabled ?: false
|
||||
call.remoteParams?.isVideoEnabled == true && call.remoteParams?.videoDirection != MediaDirection.Inactive
|
||||
} else {
|
||||
call.currentParams.isVideoEnabled
|
||||
call.currentParams.isVideoEnabled && call.currentParams.videoDirection != MediaDirection.Inactive
|
||||
}
|
||||
|
||||
val smallIcon = if (isConference) {
|
||||
|
|
@ -864,7 +865,6 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
setWhen(System.currentTimeMillis())
|
||||
setAutoCancel(false)
|
||||
setShowWhen(true)
|
||||
setOngoing(true)
|
||||
setFullScreenIntent(pendingIntent, true)
|
||||
}
|
||||
|
|
@ -1109,6 +1109,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
AvatarGenerator(context).setInitials(AppUtils.getInitials(displayName)).buildIcon()
|
||||
)
|
||||
.setKey(displayName)
|
||||
.setImportant(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
@ -1117,13 +1118,14 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val id = context.getString(R.string.notification_channel_incoming_call_id)
|
||||
val name = context.getString(R.string.notification_channel_incoming_call_name)
|
||||
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel.description = name
|
||||
channel.lightColor = context.getColor(R.color.main1_500)
|
||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
channel.enableVibration(true)
|
||||
channel.enableLights(true)
|
||||
channel.setShowBadge(false)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH).apply {
|
||||
description = name
|
||||
lightColor = context.getColor(R.color.main1_500)
|
||||
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
enableVibration(true)
|
||||
enableLights(true)
|
||||
setShowBadge(false)
|
||||
}
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
@ -1132,13 +1134,14 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val id = context.getString(R.string.notification_channel_missed_call_id)
|
||||
val name = context.getString(R.string.notification_channel_missed_call_name)
|
||||
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel.description = name
|
||||
channel.lightColor = context.getColor(R.color.main1_500)
|
||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
channel.enableVibration(true)
|
||||
channel.enableLights(true)
|
||||
channel.setShowBadge(false)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH).apply {
|
||||
description = name
|
||||
lightColor = context.getColor(R.color.main1_500)
|
||||
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
enableVibration(true)
|
||||
enableLights(true)
|
||||
setShowBadge(false)
|
||||
}
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
@ -1147,12 +1150,13 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val id = context.getString(R.string.notification_channel_call_id)
|
||||
val name = context.getString(R.string.notification_channel_call_name)
|
||||
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_DEFAULT)
|
||||
channel.description = name
|
||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
channel.enableVibration(false)
|
||||
channel.enableLights(false)
|
||||
channel.setShowBadge(false)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_DEFAULT).apply {
|
||||
description = name
|
||||
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
enableVibration(false)
|
||||
enableLights(false)
|
||||
setShowBadge(false)
|
||||
}
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
@ -1161,13 +1165,14 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val id = context.getString(R.string.notification_channel_chat_id)
|
||||
val name = context.getString(R.string.notification_channel_chat_name)
|
||||
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel.description = name
|
||||
channel.lightColor = context.getColor(R.color.main1_500)
|
||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
channel.enableLights(true)
|
||||
channel.enableVibration(true)
|
||||
channel.setShowBadge(true)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH).apply {
|
||||
description = name
|
||||
lightColor = context.getColor(R.color.main1_500)
|
||||
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
enableLights(true)
|
||||
enableVibration(true)
|
||||
setShowBadge(true)
|
||||
}
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
@ -1176,11 +1181,12 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
val id = context.getString(R.string.notification_channel_service_id)
|
||||
val name = context.getString(R.string.notification_channel_service_name)
|
||||
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW)
|
||||
channel.description = name
|
||||
channel.enableVibration(false)
|
||||
channel.enableLights(false)
|
||||
channel.setShowBadge(false)
|
||||
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW).apply {
|
||||
description = name
|
||||
enableVibration(false)
|
||||
enableLights(false)
|
||||
setShowBadge(false)
|
||||
}
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
|||
import org.linphone.core.AudioDevice
|
||||
import org.linphone.core.Call
|
||||
import org.linphone.core.CallListenerStub
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.AudioUtils
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ class TelecomCallControlCallback constructor(
|
|||
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
|
||||
if (state == Call.State.Connected) {
|
||||
if (call.dir == Call.Dir.Incoming) {
|
||||
val videoEnabled = call.currentParams.isVideoEnabled
|
||||
val videoEnabled = call.currentParams.isVideoEnabled && call.currentParams.videoDirection != MediaDirection.Inactive
|
||||
scope.launch {
|
||||
val type = if (videoEnabled) {
|
||||
CallAttributesCompat.CALL_TYPE_VIDEO_CALL
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.linphone.core.AudioDevice
|
|||
import org.linphone.core.Call
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
|
|
@ -55,17 +56,26 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
|||
val address = call.remoteAddress
|
||||
val friend = coreContext.contactsManager.findContactByAddress(address)
|
||||
val displayName = friend?.name ?: LinphoneUtils.getDisplayName(address)
|
||||
|
||||
val uri = Uri.parse(address.asStringUriOnly())
|
||||
|
||||
val direction = if (call.dir == Call.Dir.Outgoing) {
|
||||
CallAttributesCompat.DIRECTION_OUTGOING
|
||||
} else {
|
||||
CallAttributesCompat.DIRECTION_INCOMING
|
||||
}
|
||||
val type = if (core.isVideoEnabled) {
|
||||
|
||||
val params = if (call.dir == Call.Dir.Outgoing) {
|
||||
call.params
|
||||
} else {
|
||||
call.remoteParams
|
||||
}
|
||||
val type = if (params?.isVideoEnabled == true && params.videoDirection != MediaDirection.Inactive) {
|
||||
CallAttributesCompat.CALL_TYPE_VIDEO_CALL
|
||||
} else {
|
||||
CallAttributesCompat.CALL_TYPE_AUDIO_CALL
|
||||
}
|
||||
|
||||
val capabilities = CallAttributesCompat.SUPPORTS_SET_INACTIVE or CallAttributesCompat.SUPPORTS_TRANSFER
|
||||
|
||||
val callAttributes = CallAttributesCompat(
|
||||
|
|
@ -138,9 +148,13 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
|||
|
||||
init {
|
||||
callsManager.registerAppWithTelecom(
|
||||
CallsManager.Companion.CAPABILITY_SUPPORTS_VIDEO_CALLING
|
||||
CallsManager.CAPABILITY_BASELINE or
|
||||
CallsManager.Companion.CAPABILITY_SUPPORTS_VIDEO_CALLING
|
||||
)
|
||||
val hasTelecomFeature = context.packageManager.hasSystemFeature("android.software.telecom")
|
||||
Log.i(
|
||||
"$TAG App has been registered with Telecom, android.software.telecom feature is [${if (hasTelecomFeature) "available" else "not available"}]"
|
||||
)
|
||||
Log.i("$TAG App has been registered with Telecom")
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue