Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): allowEdit not working when sourceType is PHOTOLIBRARY #426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hazems
Copy link
Member

@hazems hazems commented Feb 25, 2019

Platforms affected

Android

Motivation and Context

allowEdit is not respected when source type is set to PHOTOLIBRARY. Looking into the code of the Camera plugin, I found that this case was never handled and allowEdit never launches cropping tool at all for Android versions >= Marshmallow.

This issue is reported in
#393

Description

In order to solve this issue, I made sure that performCrop is called when allowEdit is set to true for PHOTOALBUM and introduced an extra new parameter to performCrop method in order to determine the source type to properly set request codes for Camera and Photo Album cropping cases.

Testing

I did manual testing to test all various test cases that I have and all pass fine. I also run paramedic unit tests and they runs perfectly in my emulator.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@mconti80
Copy link

mconti80 commented May 1, 2019

Is there any chance this will be included in the next build of the plugin?
Can I include this fix in my angular project?

@hazems
Copy link
Member Author

hazems commented May 5, 2019

Is there any chance this will be included in the next build of the plugin?
Can I include this fix in my angular project?

Please thumb it up so so it can be merged. thanks

Copy link
Member

@timbru31 timbru31 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your PR 👍 , I've added some comments

src/android/CameraLauncher.java Outdated Show resolved Hide resolved
//Crop Codes
private static final int CROP_OPERATION = 100;
private static final int CROP_CAMERA = CROP_OPERATION;
private static final int CROP_PHOTO_ALBUM = CROP_OPERATION + 900;
Copy link
Member

Choose a reason for hiding this comment

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

any particular reason for 900? Can we use something better than a random magic number?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason is to give a clear distinction between CROP_CAMERA operation code and CROP_PHOTO_ALBUM operation code.

Copy link

@ishanAhuja ishanAhuja May 16, 2019

Choose a reason for hiding this comment

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

Hey @hazems, why 900 specifically? Is there a reason for it?

@janpio janpio changed the title AAR-233: (android) allowEdit not working when sourceType is PHOTOLIBRARY (android) allowEdit not working when sourceType is PHOTOLIBRARY May 6, 2019
@ishanAhuja
Copy link

Hope this can be reviewed and merged soon, @timbru31! We too are relying on a fix for this issue for our app. Thanks! 😊

@YaroslavG
Copy link

hello @hazems,
My app is closed now when I choose load from gallery

@hazems
Copy link
Member Author

hazems commented Jun 9, 2019

hello @hazems,
My app is closed now when I choose load from gallery

This PR is not merged yet? which version of plugin are you using? What is your OS/device information? Do you have a sample that replicates the issue?

If yes, feel free to open a new issue, and we will look into it.

Thanks

@janpio janpio changed the title (android) allowEdit not working when sourceType is PHOTOLIBRARY fix(android): allowEdit not working when sourceType is PHOTOLIBRARY Jul 1, 2019
@wxingheng
Copy link

@hazems I took the initiative to merge ARR-233, locally, but no effect. (android) allowEdit not working when sourceType is PHOTOLIBRARY error still exists. Can I help you?
Android 7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants