Store contact’s photoUri

So much less complicated now!
This commit is contained in:
Moez Bhatti
2019-11-24 00:27:39 -05:00
parent a1fcecd79e
commit 573b01ff65
15 changed files with 36 additions and 173 deletions
@@ -154,11 +154,10 @@ class NotificationManagerImpl @Inject constructor(
.firstOrNull { phoneNumberUtils.compare(it.address, message.address) }
person.setName(recipient?.getDisplayName() ?: message.address)
person.setIcon(GlideApp.with(context)
.asBitmap()
.circleCrop()
.load("tel:${message.address}")
.load(recipient?.contact?.photoUri)
.submit(64.dpToPx(context), 64.dpToPx(context))
.let { futureGet -> tryOrNull(false) { futureGet.get() } }
?.let(IconCompat::createWithBitmap))
@@ -178,12 +177,12 @@ class NotificationManagerImpl @Inject constructor(
// Set the large icon
val avatar = conversation.recipients.takeIf { it.size == 1 }
?.first()?.address
?.let { address ->
?.first()?.contact?.photoUri
?.let { photoUri ->
GlideApp.with(context)
.asBitmap()
.circleCrop()
.load("tel:$address")
.load(photoUri)
.submit(64.dpToPx(context), 64.dpToPx(context))
}
?.let { futureGet -> tryOrNull(false) { futureGet.get() } }
@@ -52,13 +52,13 @@ class QkChooserTargetService : ChooserTargetService() {
}
private fun createShortcutForConversation(conversation: Conversation): ChooserTarget {
val icon = when {
conversation.recipients.size == 1 -> {
val address = conversation.recipients.first()!!.address
val icon = when (conversation.recipients.size) {
1 -> {
val photoUri = conversation.recipients.first()?.contact?.photoUri
val request = GlideApp.with(this)
.asBitmap()
.circleCrop()
.load("tel:$address")
.load(photoUri)
.submit()
val bitmap = tryOrNull(false) { request.get() }