mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
fetch private contact data at the call screen
This commit is contained in:
@ -6,7 +6,10 @@ import android.net.Uri
|
|||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import android.telecom.InCallService
|
import android.telecom.InCallService
|
||||||
import android.telecom.VideoProfile
|
import android.telecom.VideoProfile
|
||||||
|
import com.simplemobiletools.commons.extensions.getMyContactsContentProviderCursorLoader
|
||||||
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.dialer.models.CallContact
|
import com.simplemobiletools.dialer.models.CallContact
|
||||||
|
|
||||||
// inspired by https://github.com/Chooloo/call_manage
|
// inspired by https://github.com/Chooloo/call_manage
|
||||||
@ -65,8 +68,20 @@ class CallManager {
|
|||||||
callContact.name = SimpleContactsHelper(context).getNameFromPhoneNumber(number)
|
callContact.name = SimpleContactsHelper(context).getNameFromPhoneNumber(number)
|
||||||
callContact.photoUri = SimpleContactsHelper(context).getPhotoUriFromPhoneNumber(number)
|
callContact.photoUri = SimpleContactsHelper(context).getPhotoUriFromPhoneNumber(number)
|
||||||
|
|
||||||
|
if (callContact.name != callContact.number) {
|
||||||
|
callback(callContact)
|
||||||
|
} else {
|
||||||
|
val privateCursor = context.getMyContactsContentProviderCursorLoader().loadInBackground()
|
||||||
|
ensureBackgroundThread {
|
||||||
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
||||||
|
val privateContact = privateContacts.firstOrNull { it.phoneNumber == callContact.number }
|
||||||
|
if (privateContact != null) {
|
||||||
|
callContact.name = privateContact.name
|
||||||
|
}
|
||||||
callback(callContact)
|
callback(callContact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user