Added opening contact details from the conversation view (#104)
This commit is contained in:
parent
0774e0cb0f
commit
67f5404f26
3 changed files with 49 additions and 0 deletions
|
|
@ -684,6 +684,20 @@ fun Context.getNameFromAddress(address: String, privateCursor: Cursor?): String
|
|||
return sender
|
||||
}
|
||||
|
||||
fun Context.getContactFromAddress(address: String, callback: ((contact: SimpleContact?) -> Unit)) {
|
||||
val privateCursor = getMyContactsCursor(false, true)?.loadInBackground()
|
||||
SimpleContactsHelper(this).getAvailableContacts(false) {
|
||||
val contact = it.firstOrNull { it.doesHavePhoneNumber(address) }
|
||||
if (contact == null) {
|
||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||
val privateContact = privateContacts.firstOrNull { it.doesHavePhoneNumber(address) }
|
||||
callback(privateContact)
|
||||
} else {
|
||||
callback(contact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun Context.showMessageNotification(address: String, body: String, threadId: Long, bitmap: Bitmap?, sender: String) {
|
||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue