diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt index ee44d1ff..5303feb6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt @@ -168,6 +168,7 @@ class MainActivity : SimpleActivity() { private fun showSortingDialog() { ChangeSortingDialog(this) { contacts_fragment.initContacts() + favorites_fragment.initContacts() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt index dcc1f257..54f2301c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt @@ -85,9 +85,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) Contact.sorting = config.sorting contacts.sort() - if (this is FavoritesFragment) { + contacts = if (this is FavoritesFragment) { val favorites = config.favorites - contacts = contacts.filter { favorites.contains(it.id.toString()) } as ArrayList + contacts.filter { favorites.contains(it.id.toString()) } as ArrayList + } else { + val contactSources = config.displayContactSources + contacts.filter { contactSources.contains(it.source) } as ArrayList } if (contacts.hashCode() != (fragment_list.adapter as? ContactsAdapter)?.contactItems?.hashCode()) { 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 775268d6..72dcd309 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -24,7 +24,6 @@ import com.simplemobiletools.contacts.models.Contact import com.simplemobiletools.contacts.models.Email import com.simplemobiletools.contacts.models.Event import com.simplemobiletools.contacts.models.PhoneNumber -import com.simplemobiletools.contacts.overloads.times import java.io.ByteArrayOutputStream import java.util.* @@ -32,16 +31,10 @@ class ContactsHelper(val activity: BaseSimpleActivity) { fun getContacts(callback: (ArrayList) -> Unit) { val contacts = SparseArray() Thread { - val sources = activity.config.displayContactSources - val questionMarks = ("?," * sources.size).trimEnd(',') val uri = ContactsContract.Data.CONTENT_URI val projection = getContactProjection() - var selection = "${ContactsContract.Data.MIMETYPE} = ?" - var selectionArgs = arrayOf(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) - if (!activity.config.showAllContacts()) { - selection += " AND ${ContactsContract.RawContacts.ACCOUNT_NAME} IN ($questionMarks)" - selectionArgs += sources.toTypedArray() - } + val selection = "${ContactsContract.Data.MIMETYPE} = ?" + val selectionArgs = arrayOf(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) val sortOrder = getSortString() var cursor: Cursor? = null