PlatformContactsHelper

class PlatformContactsHelper(    context: Context,     sourceName: String = ACCOUNT_SOURCE_NAME,     sourceType: String = ACCOUNT_SOURCE_TYPE)

Util class to add and remove contacts in Android ContactsProvider using a contentResolver. Each contact added with it is tagged with the sourceName and the sourceType.

sourceName and the sourceType can be used to simulate different source of contact like for example different Bluetooth devices.

Requires permission android.permission.WRITE_CONTACTS Requires permission android.permission.WRITE_CALL_LOG

Constructors

Link copied to clipboard
fun PlatformContactsHelper(    context: Context,     sourceName: String = ACCOUNT_SOURCE_NAME,     sourceType: String = ACCOUNT_SOURCE_TYPE)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
interface PlatformContactsHelperEvents : TraceEventListener

Functions

Link copied to clipboard
suspend fun addContact(    prefix: String = "",     firstName: String,     middleName: String = "",     lastName: String,     suffix: String = "",     asFavorite: Boolean = false,     typedPhoneNumbers: List<TypedPhoneNumber>,     photo: Bitmap?,     companyName: String?,     addresses: List<TypedAddress>?)

Add a single contact with a name, contact details and a photo. Each TypedPhoneNumber is a pair value (phone number, phone type) with a none blank phone number.

Link copied to clipboard
suspend fun addRecentCallsEntry(typedCall: TypedCall, callTime: Instant)

Add a single call with a name. Each TypedCall is a pair value (phone number, call type) with a none blank phone number.

Link copied to clipboard
suspend fun deleteAllContacts()

Delete all the contacts added by this PlatformContactsHelper with the corresponding sourceName and sourceType from ContactsProvider.

Link copied to clipboard
suspend fun deleteRecentCalls()

Delete all the calls added by this PlatformContactsHelper with the corresponding sourceName and sourceType from ContactsProvider.

Link copied to clipboard
fun generateBitmapsFromResources(@DrawableRes resourceList: List<Int>): List<Bitmap>

Generate a list of Bitmaps based on a list of drawable resources.

Link copied to clipboard
suspend fun generateRandomContacts(    numberOfContacts: Int,     numberOfPhoneNumbers: Int,     numberOfAddress: Int,     photos: List<Bitmap>?,     asFavorite: Boolean,     seed: Random = Random,     onContactGenerated: (Int) -> Unit? = null)

Generate numberOfContacts contacts with a random name. Each contact is generated with numberOfPhoneNumbers random phone number with random phone type.

Link copied to clipboard
suspend fun generateRandomRecentCallsEntry(    minimumTime: Instant,     maximumTime: Instant,     callType: Int,     seed: Random = Random)

Generate a call with random call time between minimumTime, maximumTime time.