From 7b076dfa881b697c33510e2c5d392277b1d3d8af Mon Sep 17 00:00:00 2001 From: Alvaro Marquina Date: Tue, 30 Jun 2015 15:57:28 -0430 Subject: [PATCH] Returns bounds into intent --- .../android/crop/CropImageActivity.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java b/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java index 62a1596a..ccbc1ddd 100644 --- a/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java +++ b/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java @@ -257,9 +257,9 @@ private void onSaveClicked() { isSaving = true; Bitmap croppedImage; - Rect r = cropView.getScaledCropRect(sampleSize); - int width = r.width(); - int height = r.height(); + Rect scaledCropRect = cropView.getScaledCropRect(sampleSize); + int width = scaledCropRect.width(); + int height = scaledCropRect.height(); int outWidth = width; int outHeight = height; @@ -275,7 +275,7 @@ private void onSaveClicked() { } try { - croppedImage = decodeRegionCrop(r, outWidth, outHeight); + croppedImage = decodeRegionCrop(scaledCropRect, outWidth, outHeight); } catch (IllegalArgumentException e) { setResultException(e); finish(); @@ -287,16 +287,16 @@ private void onSaveClicked() { imageView.center(true, true); imageView.highlightViews.clear(); } - saveImage(croppedImage); + saveImage(croppedImage, scaledCropRect); } - private void saveImage(Bitmap croppedImage) { + private void saveImage(Bitmap croppedImage, final Rect scaledCropRect) { if (croppedImage != null) { final Bitmap b = croppedImage; CropUtil.startBackgroundJob(this, null, getResources().getString(R.string.crop__saving), new Runnable() { public void run() { - saveOutput(b); + saveOutput(b, scaledCropRect); } }, handler ); @@ -363,7 +363,7 @@ private void clearImageView() { System.gc(); } - private void saveOutput(Bitmap croppedImage) { + private void saveOutput(Bitmap croppedImage, Rect scaledCropRect) { if (saveUri != null) { OutputStream outputStream = null; try { @@ -383,7 +383,7 @@ private void saveOutput(Bitmap croppedImage) { CropUtil.getFromMediaUri(this, getContentResolver(), saveUri) ); - setResultUri(saveUri); + setResultUri(saveUri, scaledCropRect); } final Bitmap b = croppedImage; @@ -414,8 +414,11 @@ public boolean isSaving() { return isSaving; } - private void setResultUri(Uri uri) { - setResult(RESULT_OK, new Intent().putExtra(MediaStore.EXTRA_OUTPUT, uri)); + private void setResultUri(Uri uri, Rect scaledCropRect) { + Intent intent = new Intent(); + intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); + intent.putExtra(Crop.BOUNDS, scaledCropRect); + setResult(RESULT_OK, intent); } private void setResultException(Throwable throwable) {