mirror of
				https://github.com/SimpleMobileTools/Simple-Contacts.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	do not try inserting the contact thumbnail, it will be generated
This commit is contained in:
		| @@ -1301,30 +1301,15 @@ class ContactsHelper(val context: Context) { | ||||
|  | ||||
|             // photo (inspired by https://gist.github.com/slightfoot/5985900) | ||||
|             var fullSizePhotoData: ByteArray? = null | ||||
|             var scaledSizePhotoData: ByteArray? | ||||
|             if (contact.photoUri.isNotEmpty()) { | ||||
|                 val photoUri = Uri.parse(contact.photoUri) | ||||
|                 val bitmap = MediaStore.Images.Media.getBitmap(context.contentResolver, photoUri) | ||||
|  | ||||
|                 val thumbnailSize = context.getPhotoThumbnailSize() | ||||
|                 val scaledPhoto = Bitmap.createScaledBitmap(bitmap, thumbnailSize, thumbnailSize, false) | ||||
|                 scaledSizePhotoData = scaledPhoto.getByteArray() | ||||
|  | ||||
|                 fullSizePhotoData = bitmap.getByteArray() | ||||
|                 scaledPhoto.recycle() | ||||
|                 bitmap.recycle() | ||||
|  | ||||
|                 ContentProviderOperation.newInsert(Data.CONTENT_URI).apply { | ||||
|                     withValueBackReference(Data.RAW_CONTACT_ID, 0) | ||||
|                     withValue(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE) | ||||
|                     withValue(Photo.PHOTO, scaledSizePhotoData) | ||||
|                     operations.add(build()) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             val results: Array<ContentProviderResult> | ||||
|             try { | ||||
|                 results = context.contentResolver.applyBatch(AUTHORITY, operations) | ||||
|             val results = context.contentResolver.applyBatch(AUTHORITY, operations) | ||||
|  | ||||
|             // storing contacts on some devices seems to be messed up and they move on Phone instead, or disappear completely | ||||
|             // try storing a lighter contact version with this oldschool version too just so it wont disappear, future edits work well | ||||
| @@ -1336,9 +1321,6 @@ class ContactsHelper(val context: Context) { | ||||
|                     context.contentResolver.insert(simUri, this) | ||||
|                 } | ||||
|             } | ||||
|             } finally { | ||||
|                 scaledSizePhotoData = null | ||||
|             } | ||||
|  | ||||
|             // fullsize photo | ||||
|             val rawId = ContentUris.parseId(results[0].uri) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user