mirror of
				https://github.com/SimpleMobileTools/Simple-Contacts.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	change the way contacts are fetched, use type blacklist instead of whitelist
This commit is contained in:
		| @@ -125,10 +125,12 @@ class ContactsHelper(val context: Context) { | |||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         val ignoredSources = context.config.ignoredContactSources | ||||||
|         val uri = ContactsContract.Data.CONTENT_URI |         val uri = ContactsContract.Data.CONTENT_URI | ||||||
|         val projection = getContactProjection() |         val projection = getContactProjection() | ||||||
|         val selection = getSourcesSelection(true) |  | ||||||
|         val selectionArgs = getSourcesSelectionArgs(CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) |         val selection = "${ContactsContract.Data.MIMETYPE} = ?" | ||||||
|  |         val selectionArgs = arrayOf(CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) | ||||||
|         val sortOrder = getSortString() |         val sortOrder = getSortString() | ||||||
|  |  | ||||||
|         var cursor: Cursor? = null |         var cursor: Cursor? = null | ||||||
| @@ -136,6 +138,11 @@ class ContactsHelper(val context: Context) { | |||||||
|             cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, sortOrder) |             cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, sortOrder) | ||||||
|             if (cursor?.moveToFirst() == true) { |             if (cursor?.moveToFirst() == true) { | ||||||
|                 do { |                 do { | ||||||
|  |                     val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: "" | ||||||
|  |                     if (ignoredSources.contains(accountName)) { | ||||||
|  |                         continue | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID) |                     val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID) | ||||||
|                     val prefix = cursor.getStringValue(CommonDataKinds.StructuredName.PREFIX) ?: "" |                     val prefix = cursor.getStringValue(CommonDataKinds.StructuredName.PREFIX) ?: "" | ||||||
|                     val firstName = cursor.getStringValue(CommonDataKinds.StructuredName.GIVEN_NAME) ?: "" |                     val firstName = cursor.getStringValue(CommonDataKinds.StructuredName.GIVEN_NAME) ?: "" | ||||||
| @@ -148,7 +155,6 @@ class ContactsHelper(val context: Context) { | |||||||
|                     val emails = ArrayList<Email>() |                     val emails = ArrayList<Email>() | ||||||
|                     val addresses = ArrayList<Address>() |                     val addresses = ArrayList<Address>() | ||||||
|                     val events = ArrayList<Event>() |                     val events = ArrayList<Event>() | ||||||
|                     val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: "" |  | ||||||
|                     val starred = cursor.getIntValue(CommonDataKinds.StructuredName.STARRED) |                     val starred = cursor.getIntValue(CommonDataKinds.StructuredName.STARRED) | ||||||
|                     val contactId = cursor.getIntValue(ContactsContract.Data.CONTACT_ID) |                     val contactId = cursor.getIntValue(ContactsContract.Data.CONTACT_ID) | ||||||
|                     val thumbnailUri = cursor.getStringValue(CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI) ?: "" |                     val thumbnailUri = cursor.getStringValue(CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI) ?: "" | ||||||
| @@ -839,9 +845,6 @@ class ContactsHelper(val context: Context) { | |||||||
|         accounts.forEach { |         accounts.forEach { | ||||||
|             if (ContentResolver.getIsSyncable(it, ContactsContract.AUTHORITY) == 1) { |             if (ContentResolver.getIsSyncable(it, ContactsContract.AUTHORITY) == 1) { | ||||||
|                 val contactSource = ContactSource(it.name, it.type) |                 val contactSource = ContactSource(it.name, it.type) | ||||||
|                 if (it.type == TELEGRAM_PACKAGE) { |  | ||||||
|                     contactSource.name += " (${context.getString(R.string.telegram)})" |  | ||||||
|                 } |  | ||||||
|                 sources.add(contactSource) |                 sources.add(contactSource) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user