Bumped dependencies + add Person to call notifications
This commit is contained in:
parent
bef8884f11
commit
0c6f000da7
2 changed files with 25 additions and 16 deletions
|
@ -223,12 +223,15 @@ dependencies {
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.media:media:1.2.0'
|
implementation 'androidx.media:media:1.2.0'
|
||||||
// Don't update to fragment-ktx:1.3.2 for now, will break some animations
|
// Don't update to fragment-ktx:1.3.2 (nor 1.3.3) for now, will break some animations
|
||||||
// https://developer.android.com/jetpack/androidx/releases/fragment#version_132_2
|
// https://developer.android.com/jetpack/androidx/releases/fragment#version_132_2
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.3.1'
|
implementation 'androidx.fragment:fragment-ktx:1.3.1'
|
||||||
implementation 'androidx.core:core-ktx:1.5.0-beta03'
|
implementation 'androidx.core:core-ktx:1.5.0-beta03'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
|
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
|
def nav_version = "2.3.5"
|
||||||
|
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
|
||||||
|
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
||||||
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
||||||
|
|
|
@ -355,6 +355,22 @@ class NotificationsManager(private val context: Context) {
|
||||||
return notifiable
|
return notifiable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getPerson(contact: Contact?, displayName: String, picture: Bitmap?): Person {
|
||||||
|
return if (contact != null) {
|
||||||
|
contact.getPerson()
|
||||||
|
} else {
|
||||||
|
val builder = Person.Builder().setName(displayName)
|
||||||
|
val userIcon =
|
||||||
|
if (picture != null) {
|
||||||
|
IconCompat.createWithAdaptiveBitmap(picture)
|
||||||
|
} else {
|
||||||
|
IconCompat.createWithResource(context, R.drawable.avatar)
|
||||||
|
}
|
||||||
|
if (userIcon != null) builder.setIcon(userIcon)
|
||||||
|
builder.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun displayIncomingCallNotification(call: Call, useAsForeground: Boolean = false) {
|
private fun displayIncomingCallNotification(call: Call, useAsForeground: Boolean = false) {
|
||||||
val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress)
|
val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress)
|
||||||
val notifiable = getNotifiableForCall(call)
|
val notifiable = getNotifiableForCall(call)
|
||||||
|
@ -384,6 +400,7 @@ class NotificationsManager(private val context: Context) {
|
||||||
|
|
||||||
val builder = NotificationCompat.Builder(context, context.getString(R.string.notification_channel_incoming_call_id))
|
val builder = NotificationCompat.Builder(context, context.getString(R.string.notification_channel_incoming_call_id))
|
||||||
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
|
.addPerson(getPerson(contact, displayName, roundPicture))
|
||||||
.setSmallIcon(R.drawable.topbar_call_notification)
|
.setSmallIcon(R.drawable.topbar_call_notification)
|
||||||
.setContentTitle(displayName)
|
.setContentTitle(displayName)
|
||||||
.setContentText(context.getString(R.string.incoming_call_notification_title))
|
.setContentText(context.getString(R.string.incoming_call_notification_title))
|
||||||
|
@ -508,6 +525,7 @@ class NotificationsManager(private val context: Context) {
|
||||||
.setContentText(context.getString(stringResourceId))
|
.setContentText(context.getString(stringResourceId))
|
||||||
.setSmallIcon(iconResourceId)
|
.setSmallIcon(iconResourceId)
|
||||||
.setLargeIcon(roundPicture)
|
.setLargeIcon(roundPicture)
|
||||||
|
.addPerson(getPerson(contact, displayName, roundPicture))
|
||||||
.setAutoCancel(false)
|
.setAutoCancel(false)
|
||||||
.setCategory(NotificationCompat.CATEGORY_CALL)
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
@ -668,19 +686,7 @@ class NotificationsManager(private val context: Context) {
|
||||||
var lastPerson: Person? = null
|
var lastPerson: Person? = null
|
||||||
for (message in notifiable.messages) {
|
for (message in notifiable.messages) {
|
||||||
val contact = message.contact
|
val contact = message.contact
|
||||||
val person = if (contact != null) {
|
val person = getPerson(contact, message.sender, message.senderAvatar)
|
||||||
contact.getPerson()
|
|
||||||
} else {
|
|
||||||
val builder = Person.Builder().setName(message.sender)
|
|
||||||
val userIcon =
|
|
||||||
if (message.senderAvatar != null) {
|
|
||||||
IconCompat.createWithAdaptiveBitmap(message.senderAvatar)
|
|
||||||
} else {
|
|
||||||
IconCompat.createWithResource(context, R.drawable.avatar)
|
|
||||||
}
|
|
||||||
if (userIcon != null) builder.setIcon(userIcon)
|
|
||||||
builder.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't want to see our own avatar
|
// We don't want to see our own avatar
|
||||||
if (!message.isOutgoing) {
|
if (!message.isOutgoing) {
|
||||||
|
|
Loading…
Reference in a new issue