Pr/cropper text label support#382
Conversation
- Added a helper text on top of crop overlay which moves along with it - Exposed xml attrs and setter to update the copy text styles
| * Text size for text label over crop overlay UI | ||
| * default: 20sp | ||
| */ | ||
| private var mCropLabelTextSize = 20f |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
| /** Text to show over text label over crop overlay */ | ||
| private var cropLabelText: String = "" | ||
| /** Text color to apply over text label over crop overlay */ | ||
| private var cropLabelTextSize: Float = 20f |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
| showIntentChooser = false | ||
| intentChooserTitle = null | ||
| intentChooserPriorityList = listOf() | ||
| cropperLabelTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20f, dm) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
Canato
left a comment
There was a problem hiding this comment.
Amazing work!
Only comments are related to stuff you could not know before anyway, some old Java way of doing we are trying to improve.
Please update the CHANGELOG
| /** | ||
| * Creates the paint object for drawing text label over crop overlay | ||
| */ | ||
| private fun getTextPaint(options: CropImageOptions): Paint { | ||
| return Paint().apply { | ||
| strokeWidth = 1f | ||
| textSize = options.cropperLabelTextSize | ||
| style = Paint.Style.FILL | ||
| textAlign = Paint.Align.CENTER | ||
| this.color = options.cropperLabelTextColor | ||
| } | ||
| } |
There was a problem hiding this comment.
Please change to:
/** Creates the paint object for drawing text label over crop overlay */
private fun getTextPaint(options: CropImageOptions): Paint = , removing return
| /** The Paint used to darken the surrounding areas outside the crop area. */ | ||
| private var mBackgroundPaint: Paint? = null | ||
|
|
||
| private var mTextLabelPaint: Paint? = null |
There was a problem hiding this comment.
this m is the old java way. And we didn't remove every where, please use textLabelPaint
- Old java style coding updated as per feedback
| if (isCropLabelEnabled) { | ||
| val rect = mCropWindowHandler.getRect() | ||
| var xCoordinate = (rect.left + rect.right) / 2 | ||
| var yCoordinate = rect.top - 50 |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
Added missing activity declaration over Manifest.xml
| <activity android:name="com.canhub.cropper.CropImageActivity" /> | ||
| <activity | ||
| android:name="com.canhub.cropper.sample.extend_activity.app.SExtendActivity" | ||
| android:name="com.canhub.cropper.sample.SampleCustomActivity" |
There was a problem hiding this comment.
@Canato It was an existing crash, so fixed it along with other changes
The changes are related to #381
Adding sample working video after the change
Cropper_sticky_label.mp4