Skip to content

Commit

Permalink
Propagate all extra data set on start crop activity intent back in cr…
Browse files Browse the repository at this point in the history
…op result intent #352
  • Loading branch information
ArthurHub committed Oct 7, 2017
1 parent 0e923fc commit 5fb46a6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ For more information, see the [GitHub Wiki](https://github.com/ArthurHub/Android
- Try solve manifest merger issue by adding `transitive` flag #405 (thx @j-garin)
- Use thread pool executors for async image loading and cropping operations to prevent app hang if default executor is busy (thx @ruifcardoso)
- Fix image rotation breaking min/max crop result restrictions #401
- Propagate all extra data set on start crop activity intent back in crop result intent #352

*2.5.0*
- Update to sdk v26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public final class CropImage {
/** The key used to pass crop image options to {@link CropImageActivity}. */
public static final String CROP_IMAGE_EXTRA_OPTIONS = "CROP_IMAGE_EXTRA_OPTIONS";

/** The key used to pass crop image bundle data to {@link CropImageActivity}. */
public static final String CROP_IMAGE_EXTRA_BUNDLE = "CROP_IMAGE_EXTRA_BUNDLE";

/** The key used to pass crop image result data back from {@link CropImageActivity}. */
public static final String CROP_IMAGE_EXTRA_RESULT = "CROP_IMAGE_EXTRA_RESULT";

Expand Down Expand Up @@ -469,7 +472,7 @@ public Intent getIntent(@NonNull Context context, @Nullable Class<?> cls) {
Bundle bundle = new Bundle();
bundle.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
bundle.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
intent.putExtra(CropImageOptions.BUNDLE_KEY, bundle);
intent.putExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE, bundle);
return intent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onCreate(Bundle savedInstanceState) {

mCropImageView = findViewById(R.id.cropImageView);

Bundle bundle = getIntent().getBundleExtra(CropImageOptions.BUNDLE_KEY);
Bundle bundle = getIntent().getBundleExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE);
mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
mOptions = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);

Expand Down Expand Up @@ -325,6 +325,7 @@ protected Intent getResultIntent(Uri uri, Exception error, int sampleSize) {
mCropImageView.getWholeImageRect(),
sampleSize);
Intent intent = new Intent();
intent.putExtras(getIntent());
intent.putExtra(CropImage.CROP_IMAGE_EXTRA_RESULT, result);
return intent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*/
public class CropImageOptions implements Parcelable {

static final String BUNDLE_KEY = "bundle";

public static final Creator<CropImageOptions> CREATOR =
new Creator<CropImageOptions>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public CropImageView(Context context, AttributeSet attrs) {
CropImageOptions options = null;
Intent intent = context instanceof Activity ? ((Activity) context).getIntent() : null;
if (intent != null) {
Bundle bundle = intent.getBundleExtra(CropImageOptions.BUNDLE_KEY);
Bundle bundle = intent.getBundleExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE);
if (bundle != null) {
options = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
}
Expand Down

1 comment on commit 5fb46a6

@engSmart1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iam using this to display the image for cropping , so why ask me twice for this image , first when it get complete action , second select source for this image ?!!!!!!!!!!!!
Intent gallReq = new Intent(Intent.ACTION_GET_CONTENT);
gallReq.setType("image/*");
startActivityForResult(gallReq, GALL_REQ);

Please sign in to comment.