From c707ffceec59eeb472da1c4ee0e456e56c13dd87 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 30 Apr 2018 15:09:06 +0200 Subject: [PATCH] do not use the raw_contact_id at fetching group members --- .../contacts/helpers/ContactsHelper.kt | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 66191515..3c229d62 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -268,39 +268,6 @@ class ContactsHelper(val activity: BaseSimpleActivity) { return addresses } - private fun getQuestionMarks() = "?,".times(displayContactSources.size).trimEnd(',') - - private fun getSourcesSelection(addMimeType: Boolean = false, addContactId: Boolean = false): String { - val strings = ArrayList() - if (addMimeType) { - strings.add("${ContactsContract.Data.MIMETYPE} = ?") - } - - if (addContactId) { - strings.add("${ContactsContract.Data.RAW_CONTACT_ID} = ?") - } else { - strings.add("${ContactsContract.RawContacts.ACCOUNT_NAME} IN (${getQuestionMarks()})") - } - - return TextUtils.join(" AND ", strings) - } - - private fun getSourcesSelectionArgs(mimetype: String? = null, contactId: Int? = null): Array { - val args = ArrayList() - - if (mimetype != null) { - args.add(mimetype) - } - - if (contactId != null) { - args.add(contactId.toString()) - } else { - args.addAll(displayContactSources) - } - - return args.toTypedArray() - } - private fun getEvents(contactId: Int? = null): SparseArray> { val events = SparseArray>() val uri = ContactsContract.Data.CONTENT_URI @@ -448,7 +415,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) { ContactsContract.Data.DATA1 ) - val selection = getSourcesSelection(true, contactId != null) + val selection = getSourcesSelection(true, contactId != null, false) val selectionArgs = getSourcesSelectionArgs(CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE, contactId) var cursor: Cursor? = null @@ -476,6 +443,39 @@ class ContactsHelper(val activity: BaseSimpleActivity) { return groups } + private fun getQuestionMarks() = "?,".times(displayContactSources.size).trimEnd(',') + + private fun getSourcesSelection(addMimeType: Boolean = false, addContactId: Boolean = false, useRawContactId: Boolean = true): String { + val strings = ArrayList() + if (addMimeType) { + strings.add("${ContactsContract.Data.MIMETYPE} = ?") + } + + if (addContactId) { + strings.add("${if (useRawContactId) ContactsContract.Data.RAW_CONTACT_ID else ContactsContract.Data.CONTACT_ID} = ?") + } else { + strings.add("${ContactsContract.RawContacts.ACCOUNT_NAME} IN (${getQuestionMarks()})") + } + + return TextUtils.join(" AND ", strings) + } + + private fun getSourcesSelectionArgs(mimetype: String? = null, contactId: Int? = null): Array { + val args = ArrayList() + + if (mimetype != null) { + args.add(mimetype) + } + + if (contactId != null) { + args.add(contactId.toString()) + } else { + args.addAll(displayContactSources) + } + + return args.toTypedArray() + } + fun getStoredGroups(): ArrayList { val groups = getDeviceStoredGroups() groups.addAll(activity.dbHelper.getGroups())