properly handle contact groups at editing, or inserting a new one
This commit is contained in:
parent
9d9495ea80
commit
6750512f11
|
@ -633,6 +633,24 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
operations.add(build())
|
||||
}
|
||||
|
||||
// delete groups
|
||||
ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).apply {
|
||||
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = ? "
|
||||
val selectionArgs = arrayOf(contact.id.toString(), CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE)
|
||||
withSelection(selection, selectionArgs)
|
||||
operations.add(build())
|
||||
}
|
||||
|
||||
// add groups
|
||||
contact.groups.forEach {
|
||||
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).apply {
|
||||
withValue(ContactsContract.Data.RAW_CONTACT_ID, contact.id)
|
||||
withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE)
|
||||
withValue(CommonDataKinds.GroupMembership.GROUP_ROW_ID, it.id)
|
||||
operations.add(build())
|
||||
}
|
||||
}
|
||||
|
||||
// favorite
|
||||
try {
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contact.contactId.toString())
|
||||
|
@ -767,6 +785,16 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
operations.add(build())
|
||||
}
|
||||
|
||||
// groups
|
||||
contact.groups.forEach {
|
||||
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).apply {
|
||||
withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE)
|
||||
withValue(CommonDataKinds.GroupMembership.GROUP_ROW_ID, it.id)
|
||||
operations.add(build())
|
||||
}
|
||||
}
|
||||
|
||||
// photo (inspired by https://gist.github.com/slightfoot/5985900)
|
||||
var fullSizePhotoData: ByteArray? = null
|
||||
var scaledSizePhotoData: ByteArray?
|
||||
|
|
Loading…
Reference in New Issue