From 04283e3677a7a214262d3d164137dd10f092eb71 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 20 Aug 2013 10:21:02 -0400 Subject: [PATCH 1/2] Fix SDK version condition for setLayerType call Method requires API level 11; previously, this checked only for >11. --- .../src/eu/janmuller/android/simplecropimage/CropImage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java b/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java index b3c57fb..d92c22c 100644 --- a/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java +++ b/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java @@ -119,9 +119,9 @@ public void onCreate(Bundle icicle) { if (extras.getString(CIRCLE_CROP) != null) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - } + } mCircleCrop = true; mAspectX = 1; From 1aab8bca4c038fc2890a57a517ad40145c5a36ae Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 20 Aug 2013 12:31:10 -0400 Subject: [PATCH 2/2] Allow cropping without overwriting supplied image On the CropImage intent, send SAVE_IMAGE_PATH extra with path to a temporary file to save final cropped image to, e.g. intent.putExtra(CropImage.SAVE_IMAGE_PATH, Environment.getExternalStorageDirectory() + File.separator + "MyApp" + File.separator + "cropped-image.jpg"); --- .../eu/janmuller/android/simplecropimage/CropImage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java b/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java index d92c22c..a88f562 100644 --- a/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java +++ b/simple-crop-image-lib/src/eu/janmuller/android/simplecropimage/CropImage.java @@ -60,6 +60,7 @@ public class CropImage extends MonitoredActivity { private static final String TAG = "CropImage"; public static final String IMAGE_PATH = "image-path"; + public static final String SAVE_IMAGE_PATH = "save-image-path"; public static final String SCALE = "scale"; public static final String ORIENTATION_IN_DEGREES = "orientation_in_degrees"; public static final String ASPECT_X = "aspectX"; @@ -88,6 +89,7 @@ public class CropImage extends MonitoredActivity { private ContentResolver mContentResolver; private Bitmap mBitmap; private String mImagePath; + private String mSaveImagePath; boolean mWaitingToPick; // Whether we are wait the user to pick a face. boolean mSaving; // Whether the "save" button is already clicked. @@ -129,8 +131,9 @@ public void onCreate(Bundle icicle) { } mImagePath = extras.getString(IMAGE_PATH); + mSaveImagePath = extras.getString(SAVE_IMAGE_PATH); - mSaveUri = getImageUri(mImagePath); + mSaveUri = getImageUri(mSaveImagePath != null ? mSaveImagePath : mImagePath); mBitmap = getBitmap(mImagePath); if (extras.containsKey(ASPECT_X) && extras.get(ASPECT_X) instanceof Integer) { @@ -434,7 +437,7 @@ private void saveOutput(Bitmap croppedImage) { Bundle extras = new Bundle(); Intent intent = new Intent(mSaveUri.toString()); intent.putExtras(extras); - intent.putExtra(IMAGE_PATH, mImagePath); + intent.putExtra(IMAGE_PATH, mSaveImagePath != null ? mSaveImagePath : mImagePath); intent.putExtra(ORIENTATION_IN_DEGREES, Util.getOrientationInDegree(this)); setResult(RESULT_OK, intent); } else {