diff --git a/app/src/main/java/org/linphone/activities/voip/data/CallData.kt b/app/src/main/java/org/linphone/activities/voip/data/CallData.kt index 5776b8ea1..ca625483c 100644 --- a/app/src/main/java/org/linphone/activities/voip/data/CallData.kt +++ b/app/src/main/java/org/linphone/activities/voip/data/CallData.kt @@ -113,12 +113,6 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) { displayableAddress.value = clone.asStringUriOnly() update() - - val conferenceInfo = coreContext.core.findConferenceInformationFromUri(call.remoteAddress) - if (conferenceInfo != null) { - Log.i("[Call] Found matching conference info with subject: ${conferenceInfo.subject}") - remoteConferenceSubject.value = conferenceInfo.subject - } } override fun destroy() { @@ -228,6 +222,7 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) { val conference = call.conference isInRemoteConference.value = conference != null if (conference != null) { + Log.d("[Call] Found conference attached to call") remoteConferenceSubject.value = if (conference.subject.isNullOrEmpty()) { if (conference.me.isFocus) { AppUtils.getString(R.string.conference_local_title) @@ -238,6 +233,15 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) { conference.subject } Log.d("[Call] Found conference related to this call with subject [${remoteConferenceSubject.value}]") + } else { + val remoteContact = call.remoteContact + Log.d("[Call] Call's remote contact is $remoteContact") + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null + if (conferenceInfo != null) { + Log.d("[Call] Found matching conference info with subject: ${conferenceInfo.subject}") + remoteConferenceSubject.value = conferenceInfo.subject + } } } diff --git a/app/src/main/java/org/linphone/compatibility/Api26Compatibility.kt b/app/src/main/java/org/linphone/compatibility/Api26Compatibility.kt index af76ec673..c2ce5398c 100644 --- a/app/src/main/java/org/linphone/compatibility/Api26Compatibility.kt +++ b/app/src/main/java/org/linphone/compatibility/Api26Compatibility.kt @@ -149,15 +149,36 @@ class Api26Compatibility { pendingIntent: PendingIntent, notificationsManager: NotificationsManager ): Notification { - val contact: Friend? = coreContext.contactsManager.findContactByAddress(call.remoteAddress) - val roundPicture = ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) - val displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) - val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + val contact: Friend? + val roundPicture: Bitmap? + val displayName: String + val address: String + val info: String + + val remoteContact = call.remoteContact + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null + if (conferenceInfo == null) { + Log.i("[Notifications Manager] No conference info found for remote contact address $remoteContact") + contact = coreContext.contactsManager.findContactByAddress(call.remoteAddress) + roundPicture = + ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) + displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) + address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + info = context.getString(R.string.incoming_call_notification_title) + } else { + contact = null + displayName = conferenceInfo.subject ?: context.getString(R.string.conference) + address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + roundPicture = BitmapFactory.decodeResource(context.resources, R.drawable.voip_multiple_contacts_avatar_alt) + info = context.getString(R.string.incoming_group_call_notification_title) + Log.i("[Notifications Manager] Displaying incoming group call notification with subject $displayName for remote contact address $remoteContact") + } val notificationLayoutHeadsUp = RemoteViews(context.packageName, R.layout.call_incoming_notification_heads_up) notificationLayoutHeadsUp.setTextViewText(R.id.caller, displayName) notificationLayoutHeadsUp.setTextViewText(R.id.sip_uri, address) - notificationLayoutHeadsUp.setTextViewText(R.id.incoming_call_info, context.getString(R.string.incoming_call_notification_title)) + notificationLayoutHeadsUp.setTextViewText(R.id.incoming_call_info, info) if (roundPicture != null) { notificationLayoutHeadsUp.setImageViewBitmap(R.id.caller_picture, roundPicture) @@ -203,7 +224,9 @@ class Api26Compatibility { val title: String val person: Person - val conferenceInfo = coreContext.core.findConferenceInformationFromUri(call.remoteAddress) + val remoteContact = call.remoteContact + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null if (conferenceInfo == null) { val contact: Friend? = coreContext.contactsManager.findContactByAddress(call.remoteAddress) diff --git a/app/src/main/java/org/linphone/compatibility/Api31Compatibility.kt b/app/src/main/java/org/linphone/compatibility/Api31Compatibility.kt index b64247e0e..332b4d1ab 100644 --- a/app/src/main/java/org/linphone/compatibility/Api31Compatibility.kt +++ b/app/src/main/java/org/linphone/compatibility/Api31Compatibility.kt @@ -51,18 +51,37 @@ class Api31Compatibility { pendingIntent: PendingIntent, notificationsManager: NotificationsManager ): Notification { - val contact = coreContext.contactsManager.findContactByAddress(call.remoteAddress) - val roundPicture = ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) - val displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) + val remoteContact = call.remoteContact + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null + if (conferenceInfo != null) { + Log.i("[Notifications Manager] Displaying incoming group call notification with subject ${conferenceInfo.subject} and remote contact address $remoteContact") + } else { + Log.i("[Notifications Manager] No conference info found for remote contact address $remoteContact") + } - val person = notificationsManager.getPerson(contact, displayName, roundPicture) - val caller = Person.Builder() - .setName(person.name) - .setIcon(person.icon?.toIcon(context)) - .setUri(person.uri) - .setKey(person.key) - .setImportant(person.isImportant) - .build() + val caller = if (conferenceInfo == null) { + val contact = + coreContext.contactsManager.findContactByAddress(call.remoteAddress) + val roundPicture = + ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) + val displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) + + val person = notificationsManager.getPerson(contact, displayName, roundPicture) + Person.Builder() + .setName(person.name) + .setIcon(person.icon?.toIcon(context)) + .setUri(person.uri) + .setKey(person.key) + .setImportant(person.isImportant) + .build() + } else { + Person.Builder() + .setName(conferenceInfo.subject) + .setIcon(coreContext.contactsManager.groupAvatar.toIcon(context)) + .setImportant(false) + .build() + } val declineIntent = notificationsManager.getCallDeclinePendingIntent(notifiable) val answerIntent = notificationsManager.getCallAnswerPendingIntent(notifiable) @@ -98,7 +117,15 @@ class Api31Compatibility { channel: String, notificationsManager: NotificationsManager ): Notification { - val conferenceInfo = coreContext.core.findConferenceInformationFromUri(call.remoteAddress) + val remoteContact = call.remoteContact + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null + if (conferenceInfo != null) { + Log.i("[Notifications Manager] Displaying incoming group call notification with subject ${conferenceInfo.subject} and remote contact address $remoteContact") + } else { + Log.i("[Notifications Manager] No conference info found for remote contact address $remoteContact") + } + val caller = if (conferenceInfo == null) { val contact = coreContext.contactsManager.findContactByAddress(call.remoteAddress) diff --git a/app/src/main/java/org/linphone/compatibility/XiaomiCompatibility.kt b/app/src/main/java/org/linphone/compatibility/XiaomiCompatibility.kt index 202159f58..88da4013a 100644 --- a/app/src/main/java/org/linphone/compatibility/XiaomiCompatibility.kt +++ b/app/src/main/java/org/linphone/compatibility/XiaomiCompatibility.kt @@ -22,6 +22,7 @@ package org.linphone.compatibility import android.annotation.TargetApi import android.app.* import android.content.Context +import android.graphics.Bitmap import android.graphics.BitmapFactory import androidx.core.app.NotificationCompat import androidx.core.content.ContextCompat @@ -30,6 +31,8 @@ import org.linphone.LinphoneApplication.Companion.corePreferences import org.linphone.R import org.linphone.contact.getThumbnailUri import org.linphone.core.Call +import org.linphone.core.Friend +import org.linphone.core.tools.Log import org.linphone.notifications.Notifiable import org.linphone.notifications.NotificationsManager import org.linphone.utils.ImageUtils @@ -45,10 +48,31 @@ class XiaomiCompatibility { pendingIntent: PendingIntent, notificationsManager: NotificationsManager ): Notification { - val contact = coreContext.contactsManager.findContactByAddress(call.remoteAddress) - val roundPicture = ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) - val displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) - val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + val contact: Friend? + val roundPicture: Bitmap? + val displayName: String + val address: String + val info: String + + val remoteContact = call.remoteContact + val conferenceAddress = if (remoteContact != null) coreContext.core.interpretUrl(remoteContact) else null + val conferenceInfo = if (conferenceAddress != null) coreContext.core.findConferenceInformationFromUri(conferenceAddress) else null + if (conferenceInfo == null) { + Log.i("[Notifications Manager] No conference info found for remote contact address $remoteContact") + contact = coreContext.contactsManager.findContactByAddress(call.remoteAddress) + roundPicture = + ImageUtils.getRoundBitmapFromUri(context, contact?.getThumbnailUri()) + displayName = contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress) + address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + info = context.getString(R.string.incoming_call_notification_title) + } else { + contact = null + displayName = conferenceInfo.subject ?: context.getString(R.string.conference) + address = LinphoneUtils.getDisplayableAddress(call.remoteAddress) + roundPicture = BitmapFactory.decodeResource(context.resources, R.drawable.voip_multiple_contacts_avatar_alt) + info = context.getString(R.string.incoming_group_call_notification_title) + Log.i("[Notifications Manager] Displaying incoming group call notification with subject $displayName and remote contact address $remoteContact") + } val builder = NotificationCompat.Builder(context, context.getString(R.string.notification_channel_incoming_call_id)) .addPerson(notificationsManager.getPerson(contact, displayName, roundPicture)) @@ -56,7 +80,7 @@ class XiaomiCompatibility { .setLargeIcon(roundPicture ?: BitmapFactory.decodeResource(context.resources, R.drawable.voip_single_contact_avatar_alt)) .setContentTitle(displayName) .setContentText(address) - .setSubText(context.getString(R.string.incoming_call_notification_title)) + .setSubText(info) .setCategory(NotificationCompat.CATEGORY_CALL) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setPriority(NotificationCompat.PRIORITY_HIGH) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 318ef81bb..c0c7d6809 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -722,4 +722,5 @@ Sujet de l\'appel de groupe Informations de l\'appel de groupe Démarrer l\'appel de groupe + Appel de groupe entrant \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 062ffea09..7be8be079 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -681,7 +681,8 @@ &appName; missed calls notifications &appName; incoming calls notifications &appName; instant messages notifications - Call incoming + Incoming call + Incoming group call Hangup Answer Reply