mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-25 14:58:42 +02:00
do not try inserting the contact thumbnail, it will be generated
This commit is contained in:
parent
fa05c304e9
commit
9860b8118c
@ -1301,43 +1301,25 @@ class ContactsHelper(val context: Context) {
|
|||||||
|
|
||||||
// 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?
|
|
||||||
if (contact.photoUri.isNotEmpty()) {
|
if (contact.photoUri.isNotEmpty()) {
|
||||||
val photoUri = Uri.parse(contact.photoUri)
|
val photoUri = Uri.parse(contact.photoUri)
|
||||||
val bitmap = MediaStore.Images.Media.getBitmap(context.contentResolver, 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()
|
fullSizePhotoData = bitmap.getByteArray()
|
||||||
scaledPhoto.recycle()
|
|
||||||
bitmap.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>
|
val results = context.contentResolver.applyBatch(AUTHORITY, operations)
|
||||||
try {
|
|
||||||
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
|
// 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
|
// try storing a lighter contact version with this oldschool version too just so it wont disappear, future edits work well
|
||||||
if (getContactSourceType(contact.source).contains(".sim")) {
|
if (getContactSourceType(contact.source).contains(".sim")) {
|
||||||
val simUri = Uri.parse("content://icc/adn")
|
val simUri = Uri.parse("content://icc/adn")
|
||||||
ContentValues().apply {
|
ContentValues().apply {
|
||||||
put("number", contact.phoneNumbers.firstOrNull()?.value ?: "")
|
put("number", contact.phoneNumbers.firstOrNull()?.value ?: "")
|
||||||
put("tag", contact.getNameToDisplay())
|
put("tag", contact.getNameToDisplay())
|
||||||
context.contentResolver.insert(simUri, this)
|
context.contentResolver.insert(simUri, this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
scaledSizePhotoData = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fullsize photo
|
// fullsize photo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user