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

Feature/421 add color customisations for crop image activity #422

Conversation

Devenom1
Copy link
Contributor

@Devenom1 Devenom1 commented Aug 15, 2022

Add the issue linked to this PR
close #421

New Feature

Description:

Added options to customize toolbar color and activity background color of CropImageActivity

Check list for the Code Reviewer:

  • CHANGELOG
  • README
  • Wiki
  • Version Number

@Canato I'm a bit rusty with the code. let me know if I need to do anything

@Devenom1 Devenom1 requested a review from a team as a code owner August 15, 2022 19:19
Copy link
Member

@Canato Canato left a comment

Choose a reason for hiding this comment

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

Great work! just some small details ^^

Comment on lines 346 to 352
/** Crop Image background color **/
@JvmField
var activityBackgroundColor: Int = -1

/** Toolbar color **/
@JvmField
var toolbarColor: Int = -1
Copy link
Member

Choose a reason for hiding this comment

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

We can add a default value, so we can avoid the logic to check -1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is if we add a default value it's going to ignore the color taken from styles. Like Primary Color will always be ignored. For toolbar at least. Would that be ok?

Copy link
Member

Choose a reason for hiding this comment

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

Totally valid point.

Can we get these values here? as default? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked this.

We can set default Color WHITE to activity background.

But for toolbar I'm not sure how to fetch the primaryColor from the app themes file.

I found 2 solutions here.
Solution 1
Solution 2

Unfortunately they both require context which is not available in CropImageOptions.

I also tried Resources.getSystem().getColor() method. It has 2 parameters. The first one takes only an id of a color we have defined. So we cannot fetch the colorPrimary attribute using this.

We could also manually set the toolbar color to the primary color stated in the themes file which is currently purpleDark but if in the future this attribute is updated in the themes file it might not be updated for the toolbar

Copy link
Member

Choose a reason for hiding this comment

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

I will let you decide what makes more sense here. Any solution is good for me

just think about what is easy for our users and for maintenance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it ok to keep a default value of -1 only for toolbar here? I can't think of any other option that can fetch the primaryColor from the theme file.

So if they don't set the toolbar color it will use the default primary color set in the theme file.

Copy link
Member

Choose a reason for hiding this comment

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

yes

@Canato
Copy link
Member

Canato commented Aug 17, 2022

One more, we need to add the features here https://github.com/CanHub/Android-Image-Cropper/blob/main/.documentation/features.md

@Devenom1
Copy link
Contributor Author

One more, we need to add the features here https://github.com/CanHub/Android-Image-Cropper/blob/main/.documentation/features.md

Alright I'll update that too

@Canato Canato merged commit f521736 into CanHub:main Aug 19, 2022
@Janneman84
Copy link
Contributor

I noticed the background suddenly being white. I had to set it to transparent to get the original theme color back. Why not setting it to transparent by default?

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

Successfully merging this pull request may close these issues.

[Feat] - Add custom color customisations for CropImageActivity toolbar and background
3 participants