mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fix #164, removing some glitches related to picking new contact photos
This commit is contained in:
parent
458b735eb5
commit
50897fe6c9
@ -114,7 +114,7 @@ class EditContactActivity : ContactActivity() {
|
|||||||
super.onActivityResult(requestCode, resultCode, resultData)
|
super.onActivityResult(requestCode, resultCode, resultData)
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri)
|
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri, resultData?.data)
|
||||||
INTENT_CROP_PHOTO -> updateContactPhoto(lastPhotoIntentUri.toString(), contact_photo)
|
INTENT_CROP_PHOTO -> updateContactPhoto(lastPhotoIntentUri.toString(), contact_photo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,15 +260,21 @@ class EditContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startCropPhotoIntent(uri: Uri?) {
|
private fun startCropPhotoIntent(primaryUri: Uri?, backupUri: Uri?) {
|
||||||
if (uri == null) {
|
if (primaryUri == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var imageUri = primaryUri
|
||||||
|
val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, primaryUri)
|
||||||
|
if (bitmap == null) {
|
||||||
|
imageUri = backupUri
|
||||||
|
}
|
||||||
|
|
||||||
lastPhotoIntentUri = getCachePhotoUri()
|
lastPhotoIntentUri = getCachePhotoUri()
|
||||||
Intent("com.android.camera.action.CROP").apply {
|
Intent("com.android.camera.action.CROP").apply {
|
||||||
setDataAndType(uri, "image/*")
|
setDataAndType(imageUri, "image/*")
|
||||||
putExtra(MediaStore.EXTRA_OUTPUT, lastPhotoIntentUri)
|
putExtra(MediaStore.EXTRA_OUTPUT, lastPhotoIntentUri)
|
||||||
putExtra("outputX", 720)
|
putExtra("outputX", 720)
|
||||||
putExtra("outputY", 720)
|
putExtra("outputY", 720)
|
||||||
@ -277,7 +283,7 @@ class EditContactActivity : ContactActivity() {
|
|||||||
putExtra("crop", "true")
|
putExtra("crop", "true")
|
||||||
putExtra("scale", "true")
|
putExtra("scale", "true")
|
||||||
putExtra("scaleUpIfNeeded", "true")
|
putExtra("scaleUpIfNeeded", "true")
|
||||||
clipData = ClipData("Attachment", arrayOf("text/uri-list"), ClipData.Item(lastPhotoIntentUri))
|
clipData = ClipData("Attachment", arrayOf("text/primaryUri-list"), ClipData.Item(lastPhotoIntentUri))
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||||
if (resolveActivity(packageManager) != null) {
|
if (resolveActivity(packageManager) != null) {
|
||||||
startActivityForResult(this, INTENT_CROP_PHOTO)
|
startActivityForResult(this, INTENT_CROP_PHOTO)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user