mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
properly handle contact groups at editing, or inserting a new one
This commit is contained in:
@ -633,6 +633,24 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||||||
operations.add(build())
|
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
|
// favorite
|
||||||
try {
|
try {
|
||||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contact.contactId.toString())
|
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contact.contactId.toString())
|
||||||
@ -767,6 +785,16 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||||||
operations.add(build())
|
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)
|
// photo (inspired by https://gist.github.com/slightfoot/5985900)
|
||||||
var fullSizePhotoData: ByteArray? = null
|
var fullSizePhotoData: ByteArray? = null
|
||||||
var scaledSizePhotoData: ByteArray?
|
var scaledSizePhotoData: ByteArray?
|
||||||
|
Reference in New Issue
Block a user