check if no message came from a privately stored contact in Simple Contacts

This commit is contained in:
tibbi 2020-05-18 23:22:27 +02:00
parent 910aa365ac
commit db90f0f08c
3 changed files with 13 additions and 1 deletions

View file

@ -144,8 +144,19 @@ class MainActivity : SimpleActivity() {
private fun initMessenger() {
storeStateVariables()
val privateCursor = getMyContactsContentProviderCursorLoader().loadInBackground()
ensureBackgroundThread {
val conversations = getConversations()
// check if no message came from a privately stored contact in Simple Contacts
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
conversation.title = name
}
}
runOnUiThread {
val hasConversations = conversations.isNotEmpty()
conversations_list.beVisibleIf(hasConversations)