-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Convert CropImageOptions to data class with proper default parameters. #396
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 29 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 29 potential problems in the proposed changes. Check the Files changed tab for more details.
|
||
/** | ||
* The radius of the touchable area around the handle. (in pixels)<br></br> | ||
* We are basing this value off of the recommended 48dp Rhythm.<br></br> | ||
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm | ||
*/ | ||
@JvmField | ||
var touchRadius: Float | ||
val touchRadius: Float = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, Resources.getSystem().displayMetrics), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never be used as it might be different from the current window.
Alternatively I'd just rename this to touchRadiusDp
, set 24 as the default value and do the conversion at a later stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, but would suggest another PR to do the changes, so we keep it self contained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I just inlined the previous defaults. I'd change that in a follow up. Also there's the #387
|
||
/** | ||
* The radius of the touchable area around the handle. (in pixels)<br></br> | ||
* We are basing this value off of the recommended 48dp Rhythm.<br></br> | ||
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm | ||
*/ | ||
@JvmField | ||
var touchRadius: Float | ||
val touchRadius: Float = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, Resources.getSystem().displayMetrics), | ||
|
||
/** whether the guidelines should be on, off, or only showing when resizing. */ | ||
@JvmField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the benefit of JvmField here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need this to work on Java, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you're with Java you'd need to call getGuideliness
here without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For java it's also a best practice to use a getter in order to be able to change the implementation without needing to change the api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you. I can remove all JvmFields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great PR, thanks for the work. Will help everyone who uses and maintain the library.
Keep the good work 🚀
cropper/src/main/java/com/canhub/cropper/CropImageContractOptions.kt
Outdated
Show resolved
Hide resolved
|
||
/** | ||
* The radius of the touchable area around the handle. (in pixels)<br></br> | ||
* We are basing this value off of the recommended 48dp Rhythm.<br></br> | ||
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm | ||
*/ | ||
@JvmField | ||
var touchRadius: Float | ||
val touchRadius: Float = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, Resources.getSystem().displayMetrics), | ||
|
||
/** whether the guidelines should be on, off, or only showing when resizing. */ | ||
@JvmField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need this to work on Java, right?
|
||
/** | ||
* The radius of the touchable area around the handle. (in pixels)<br></br> | ||
* We are basing this value off of the recommended 48dp Rhythm.<br></br> | ||
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm | ||
*/ | ||
@JvmField | ||
var touchRadius: Float | ||
val touchRadius: Float = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, Resources.getSystem().displayMetrics), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, but would suggest another PR to do the changes, so we keep it self contained
@vanniktech please fix the CI issues so I can test ^^. Maybe the contributing guide can help with ktlint |
Mobile data is terrible where I am currently. I only have ktlint 0.46.0 & 0.46.1 locally and we can't seem to update this project #398, will run ktlint later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 65 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 67 potential problems in the proposed changes. Check the Files changed tab for more details.
@Canato updated the PR with ktlint fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! need some rebase with the latest merged PRs
@@ -18,7 +18,6 @@ internal class MainActivity : AppCompatActivity() { | |||
binding.sampleCropImageView.setOnClickListener { SampleUsingImageView.newInstance().show() } | |||
binding.sampleCustomActivity.setOnClickListener { SampleCustomActivity.start(this) } | |||
binding.sampleCropImage.setOnClickListener { SampleCrop.newInstance().show() } | |||
binding.sampleCropImageJava.setOnClickListener { SampleCropJava.newInstance().show() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much benefit of providing it. We should not be the one teaching people how to use Kotlin from Java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be the one teaching people how to use Kotlin from Java\
Why should we not show how to use the library in Java?
There are many requests to use the library in Java code, we have documentation only for this and is by far the most amount of issues I get in the repo.
I need a way to manually test if is working, in the case someone spot a bug in the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and is by far the most amount of issues I get in the repo.
Seems like we have different motivations. I'll eventually get around of it and update it. In the meantime, I'll build a version myself.
I need a way to manually test if is working, in the case someone spot a bug in the library.
And this can't be done using Kotlin only? What's a bug that is only targeting Java?
I'm just in favor of reducing maintenance cost here. We don't need similar things twice. Kotlin and Java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kotlin is the industry standard.
Javs usage is very simple and you get autocompletion. Also it's pretty well documented how interop is working in general.
https://kotlinlang.org/docs/java-interop.html
I believe it should not be a task of a library to document how kotlin-java interop works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [Feat] - does a java version exist ? #338
- [BUG] - No method find when java migrating to Can Hub #317
- [BUG] - Cannot find getActivityResult() while migrating from ArthurHub to CanHub #316
- [BUG] - "4.0.0"->App crash when clicking on "SAMPLE CALLING CROP IMAGE JAVA->TAKE CAMERA PICTURE BEFORE CALLING LIBRARY WITH URI" #301
- [Feat] - how to use in java #290
- [hacktoberfest] - Add Java samples #227
- [Feat] - use in java #224
- Any one please share a java version....! #210
- Hello please java code provide #192
- Implementation using java, with alternative for deprecated onActivityResult() #169
- https://github.com/CanHub/Android-Image-Cropper/discussions/359
- https://github.com/CanHub/Android-Image-Cropper/discussions/236
- https://github.com/CanHub/Android-Image-Cropper/discussions/286
- https://github.com/CanHub/Android-Image-Cropper/discussions/170
These are some of the cases.
Most of the time I'm maintaining the library by myself.
In other great times, good developers like you two (@PaulWoitaschek and @vanniktech) appear to provide valid help.
But so far no one took the step further of becoming responsible for the library too.
I believe it should not be a task of a library to document how kotlin-java interop works.
I strongly believe we can support the community with examples of library usage. And if we can use Kotlin and Java why not have both?
Sadly not all developers who use this library are good developers or even know how to use Kotlin.
There are some developers blocked on the versions before the v4, because they don't know how to use ActivityContracts
or they don't have the skills to update Gradle and Java.
My goal with this library is to help the Android community, having it in Java helps a lot.
I already changed everything to Kotlin, fix issues and update to the latest Gradle, OS and Java.
I believe we can take time and help new developers on the path to becoming better Android developers instead of excluding them from using the library because they don't know Kotlin yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, if the community that uses this library wanna go in this direction, I will not oppose it. But we need someone to take ownership of the Java questions.
customCropImage.launch( | ||
options { | ||
setImageSource( | ||
includeGallery = includeGallery, | ||
includeCamera = includeCamera, | ||
CropImageContractOptions( | ||
uri = null, | ||
CropImageOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the README, documentation, wiki etc.
setAllowRotation(true) | ||
setNoOutputImage(false) | ||
setFixAspectRatio(false) | ||
// Odd Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the new odd settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, people can look at the type itself to figure out all options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please return the odd settings? I use this for testing when people make changes to the library.
Or if you really want to remove we can add CI tests that check is this values are been setup.
<Button | ||
style="@style/Sample.Button" | ||
android:id="@+id/sampleCropImageJava" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/sample_calling_cropimage_java"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 67 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 67 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 67 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 67 potential problems in the proposed changes. Check the Files changed tab for more details.
Let's keep this mess organised! This issue has been automatically marked as stale because it has not had recent activity. =( It will be closed if no further activity occurs. Thank you for your contributions. |
What do you think of this?
CropImageContractOptions
would get much simpler tooWanted to get your opinion first, before continuing