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

Support circle crop as an aspect ratio option #747

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

Conversation

carstenz
Copy link

This allows you to add circle crop as one of the aspect ratio options.

When circle crop is selected/unselected, a protected function on UCropActivity/UCropFragment is called (setCircleCrop) - this allows a subclass to update the crop grid/frame/dimmed layer if so desired. This is also why I've changed some views to be protected rather than private, most importantly mOverlayView.

@dmitriy1morozov
Copy link
Contributor

@carstenz , thank you for the PR. Your idea seems to be promising. However, could you please provide some details about how do you see this API to be integrated and used? As I can see it doesn't work out of the box. Please add some details about this feature usage sample. Thank you.

@carstenz
Copy link
Author

@carstenz , thank you for the PR. Your idea seems to be promising. However, could you please provide some details about how do you see this API to be integrated and used? As I can see it doesn't work out of the box. Please add some details about this feature usage sample. Thank you.

Hi!
You're right - it doesn't work out of the box. In addition to this PR, what I do is subclass UcropActivity and override setCircleCrop(), like this:

protected void setCircleCrop(boolean circleCrop) {
        super.setCircleCrop(circleCrop);
        mOverlayView.setCircleDimmedLayer(circleCrop);
    }

That's it really. Perhaps calling mOverlayView.setCircleDimmedLayer(circleCrop) could be a part of KUCropActivity.setCircleCrop(), but I avoided doing that because:

  1. setCircleDimmedLayer() is existing functionality, and I wasn't sure of the ramifications of reusing it here.
  2. Calling setCircleDimmedLayer() by default would make this less flexible. I was thinking it could be up to users of the library to provide other ways of representing the circle (instead of using the existing circleDimmedLayer). But I see the point that not showing any circle by default makes this feature harder to use.

When it comes to the output (EXTRA_OUTPUT_CIRCLE_CROP), it's really up to the user of the feature how to use that flag. In my company, we store this flag as part of image metadata, and apply a circle mask to images that has it.

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.

2 participants