diff --git a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt
index 3b25bc7e..771855fb 100644
--- a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt
+++ b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt
@@ -1,3 +1,5 @@
+@file:Suppress("DeprecatedCallableAddReplaceWith")
+
package com.canhub.cropper
import android.graphics.Bitmap
@@ -26,6 +28,7 @@ data class CropImageContractOptions(
*
* Default values: `True`
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setImageSource(includeGallery: Boolean, includeCamera: Boolean): CropImageContractOptions {
cropImageOptions.imageSourceIncludeGallery = includeGallery
cropImageOptions.imageSourceIncludeCamera = includeCamera
@@ -45,6 +48,7 @@ data class CropImageContractOptions(
* [setFixAspectRatio] } (with argument `false`) and
* [setInitialCropWindowPaddingRatio] (with argument `0f).
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCropShape(cropShape: CropShape): CropImageContractOptions {
cropImageOptions.cropShape = cropShape
return this
@@ -54,6 +58,7 @@ data class CropImageContractOptions(
* To set the shape of the cropper corner (RECTANGLE / OVAL)
* Default: RECTANGLE
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCropCornerShape(cornerShape: CropImageView.CropCornerShape): CropImageContractOptions {
cropImageOptions.cornerShape = cornerShape
return this
@@ -63,6 +68,7 @@ data class CropImageContractOptions(
* To set the fill color of the Oval crop corner
* [circleFillColorHexValue] Hex value of the color (Default is WHITE)
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCircleCornerFillColor(circleFillColorHexValue: Int): CropImageContractOptions {
cropImageOptions.circleCornerFillColorHexValue = circleFillColorHexValue
return this
@@ -72,6 +78,7 @@ data class CropImageContractOptions(
* To set the Oval crop corner radius
* Default is 10
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCropCornerRadius(cornerRadius: Float): CropImageContractOptions {
cropImageOptions.cropCornerRadius = cornerRadius
return this
@@ -83,6 +90,7 @@ data class CropImageContractOptions(
* bounding box edge (in pixels).
* *Default: 3dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setSnapRadius(snapRadius: Float): CropImageContractOptions {
cropImageOptions.snapRadius = snapRadius
return this
@@ -94,6 +102,7 @@ data class CropImageContractOptions(
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm
* *Default: 48dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setTouchRadius(touchRadius: Float): CropImageContractOptions {
cropImageOptions.touchRadius = touchRadius
return this
@@ -103,6 +112,7 @@ data class CropImageContractOptions(
* whether the guidelines should be on, off, or only showing when resizing.
* *Default: ON_TOUCH*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setGuidelines(guidelines: Guidelines): CropImageContractOptions {
cropImageOptions.guidelines = guidelines
return this
@@ -112,6 +122,7 @@ data class CropImageContractOptions(
* The initial scale type of the image in the crop image view
* *Default: FIT_CENTER*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setScaleType(scaleType: CropImageView.ScaleType): CropImageContractOptions {
cropImageOptions.scaleType = scaleType
return this
@@ -122,11 +133,13 @@ data class CropImageContractOptions(
* cropping image.
* *default: true, may disable for animation or frame transition.*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setShowCropOverlay(showCropOverlay: Boolean): CropImageContractOptions {
cropImageOptions.showCropOverlay = showCropOverlay
return this
}
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setShowCropLabel(showCropLabel: Boolean): CropImageContractOptions {
cropImageOptions.showCropLabel = showCropLabel
return this
@@ -136,6 +149,7 @@ data class CropImageContractOptions(
* if auto-zoom functionality is enabled.
* default: true.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setAutoZoomEnabled(autoZoomEnabled: Boolean): CropImageContractOptions {
cropImageOptions.autoZoomEnabled = autoZoomEnabled
return this
@@ -145,6 +159,7 @@ data class CropImageContractOptions(
* if multi touch functionality is enabled.
* default: true.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setMultiTouchEnabled(multiTouchEnabled: Boolean): CropImageContractOptions {
cropImageOptions.multiTouchEnabled = multiTouchEnabled
return this
@@ -154,6 +169,7 @@ data class CropImageContractOptions(
* if the crop window can be moved by dragging the center.
* default: true
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCenterMoveEnabled(centerMoveEnabled: Boolean): CropImageContractOptions {
cropImageOptions.centerMoveEnabled = centerMoveEnabled
return this
@@ -163,6 +179,7 @@ data class CropImageContractOptions(
* The max zoom allowed during cropping.
* *Default: 4*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setMaxZoom(maxZoom: Int): CropImageContractOptions {
cropImageOptions.maxZoom = maxZoom
return this
@@ -173,6 +190,7 @@ data class CropImageContractOptions(
* dimensions.
* *Default: 0.1*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setInitialCropWindowPaddingRatio(initialCropWindowPaddingRatio: Float): CropImageContractOptions {
cropImageOptions.initialCropWindowPaddingRatio = initialCropWindowPaddingRatio
return this
@@ -182,6 +200,7 @@ data class CropImageContractOptions(
* whether the width to height aspect ratio should be maintained or free to change.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setFixAspectRatio(fixAspectRatio: Boolean): CropImageContractOptions {
cropImageOptions.fixAspectRatio = fixAspectRatio
return this
@@ -195,6 +214,7 @@ data class CropImageContractOptions(
* [aspectRatioX] the width
* [aspectRatioY] the height
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setAspectRatio(aspectRatioX: Int, aspectRatioY: Int): CropImageContractOptions {
cropImageOptions.aspectRatioX = aspectRatioX
cropImageOptions.aspectRatioY = aspectRatioY
@@ -206,6 +226,7 @@ data class CropImageContractOptions(
* the thickness of the guidelines lines (in pixels).
* *Default: 3dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderLineThickness(borderLineThickness: Float): CropImageContractOptions {
cropImageOptions.borderLineThickness = borderLineThickness
return this
@@ -215,6 +236,7 @@ data class CropImageContractOptions(
* the color of the guidelines lines.
* *Default: Color.argb(170, 255, 255, 255)*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderLineColor(borderLineColor: Int): CropImageContractOptions {
cropImageOptions.borderLineColor = borderLineColor
return this
@@ -224,6 +246,7 @@ data class CropImageContractOptions(
* thickness of the corner line (in pixels).
* *Default: 2dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderCornerThickness(borderCornerThickness: Float): CropImageContractOptions {
cropImageOptions.borderCornerThickness = borderCornerThickness
return this
@@ -233,6 +256,7 @@ data class CropImageContractOptions(
* the offset of corner line from crop window border (in pixels).
* *Default: 5dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderCornerOffset(borderCornerOffset: Float): CropImageContractOptions {
cropImageOptions.borderCornerOffset = borderCornerOffset
return this
@@ -242,6 +266,7 @@ data class CropImageContractOptions(
* the length of the corner line away from the corner (in pixels).
* *Default: 14dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderCornerLength(borderCornerLength: Float): CropImageContractOptions {
cropImageOptions.borderCornerLength = borderCornerLength
return this
@@ -251,6 +276,7 @@ data class CropImageContractOptions(
* the color of the corner line.
* *Default: WHITE*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBorderCornerColor(borderCornerColor: Int): CropImageContractOptions {
cropImageOptions.borderCornerColor = borderCornerColor
return this
@@ -260,6 +286,7 @@ data class CropImageContractOptions(
* the thickness of the guidelines lines (in pixels).
* *Default: 1dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setGuidelinesThickness(guidelinesThickness: Float): CropImageContractOptions {
cropImageOptions.guidelinesThickness = guidelinesThickness
return this
@@ -269,6 +296,7 @@ data class CropImageContractOptions(
* the color of the guidelines lines.
* *Default: Color.argb(170, 255, 255, 255)*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setGuidelinesColor(guidelinesColor: Int): CropImageContractOptions {
cropImageOptions.guidelinesColor = guidelinesColor
return this
@@ -279,6 +307,7 @@ data class CropImageContractOptions(
* crop window.
* *Default: Color.argb(119, 0, 0, 0)*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setBackgroundColor(backgroundColor: Int): CropImageContractOptions {
cropImageOptions.backgroundColor = backgroundColor
return this
@@ -288,6 +317,7 @@ data class CropImageContractOptions(
* the min size the crop window is allowed to be (in pixels).
* *Default: 42dp, 42dp*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setMinCropWindowSize(
minCropWindowWidth: Int,
minCropWindowHeight: Int,
@@ -302,6 +332,7 @@ data class CropImageContractOptions(
* limits (in pixels).
* *Default: 40px, 40px*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setMinCropResultSize(
minCropResultWidth: Int,
minCropResultHeight: Int,
@@ -316,6 +347,7 @@ data class CropImageContractOptions(
* limits (in pixels).
* *Default: 99999, 99999*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setMaxCropResultSize(
maxCropResultWidth: Int,
maxCropResultHeight: Int,
@@ -329,6 +361,7 @@ data class CropImageContractOptions(
* the title of the [CropImageActivity].
* *Default: ""*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setActivityTitle(activityTitle: CharSequence): CropImageContractOptions {
cropImageOptions.activityTitle = activityTitle
return this
@@ -338,6 +371,7 @@ data class CropImageContractOptions(
* the color to use for action bar items icons.
* *Default: NONE*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setActivityMenuIconColor(activityMenuIconColor: Int): CropImageContractOptions {
cropImageOptions.activityMenuIconColor = activityMenuIconColor
return this
@@ -347,6 +381,7 @@ data class CropImageContractOptions(
* the color to use for action bar items texts.
* *Default: NONE*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setActivityMenuTextColor(activityMenuTextColor: Int): CropImageContractOptions {
cropImageOptions.activityMenuTextColor = activityMenuTextColor
return this
@@ -356,6 +391,7 @@ data class CropImageContractOptions(
* the Android Uri to save the cropped image to.
* *Default: NONE, will create a temp file*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setOutputUri(outputUri: Uri?): CropImageContractOptions {
cropImageOptions.customOutputUri = outputUri
return this
@@ -365,6 +401,7 @@ data class CropImageContractOptions(
* the compression format to use when writting the image.
* *Default: JPEG*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setOutputCompressFormat(outputCompressFormat: Bitmap.CompressFormat): CropImageContractOptions {
cropImageOptions.outputCompressFormat = outputCompressFormat
return this
@@ -374,28 +411,22 @@ data class CropImageContractOptions(
* the quality (if applicable) to use when writting the image (0 - 100).
* *Default: 90*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setOutputCompressQuality(outputCompressQuality: Int): CropImageContractOptions {
cropImageOptions.outputCompressQuality = outputCompressQuality
return this
}
- /**
- * the size to resize the cropped image to.
- * Uses [CropImageView.RequestSizeOptions.RESIZE_INSIDE] option.
- * *Default: 0, 0 - not set, will not resize*
- */
- fun setRequestedSize(reqWidth: Int, reqHeight: Int): CropImageContractOptions {
- return setRequestedSize(reqWidth, reqHeight, RequestSizeOptions.RESIZE_INSIDE)
- }
-
/**
* the size to resize the cropped image to.
* *Default: 0, 0 - not set, will not resize*
*/
+ @JvmOverloads
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setRequestedSize(
reqWidth: Int,
reqHeight: Int,
- reqSizeOptions: RequestSizeOptions,
+ reqSizeOptions: RequestSizeOptions = RequestSizeOptions.RESIZE_INSIDE,
): CropImageContractOptions {
cropImageOptions.outputRequestWidth = reqWidth
cropImageOptions.outputRequestHeight = reqHeight
@@ -409,6 +440,7 @@ data class CropImageContractOptions(
* data.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setNoOutputImage(noOutputImage: Boolean): CropImageContractOptions {
cropImageOptions.noOutputImage = noOutputImage
return this
@@ -418,6 +450,7 @@ data class CropImageContractOptions(
* the initial rectangle to set on the cropping image after loading.
* *Default: NONE - will initialize using initial crop window padding ratio*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setInitialCropWindowRectangle(initialCropWindowRectangle: Rect?): CropImageContractOptions {
cropImageOptions.initialCropWindowRectangle = initialCropWindowRectangle
return this
@@ -428,6 +461,7 @@ data class CropImageContractOptions(
*
* *Default: NONE - will read image exif data*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setInitialRotation(initialRotation: Int): CropImageContractOptions {
cropImageOptions.initialRotation = (initialRotation + DEGREES_360) % DEGREES_360
return this
@@ -437,6 +471,7 @@ data class CropImageContractOptions(
* if to allow rotation during cropping.
* *Default: true*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setAllowRotation(allowRotation: Boolean): CropImageContractOptions {
cropImageOptions.allowRotation = allowRotation
return this
@@ -446,6 +481,7 @@ data class CropImageContractOptions(
* if to allow flipping during cropping.
* *Default: true*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setAllowFlipping(allowFlipping: Boolean): CropImageContractOptions {
cropImageOptions.allowFlipping = allowFlipping
return this
@@ -456,6 +492,7 @@ data class CropImageContractOptions(
* Note: if rotation is disabled this option has no effect.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setAllowCounterRotation(allowCounterRotation: Boolean): CropImageContractOptions {
cropImageOptions.allowCounterRotation = allowCounterRotation
return this
@@ -465,6 +502,7 @@ data class CropImageContractOptions(
* The amount of degreees to rotate clockwise or counter-clockwise (0-360).
* *Default: 90*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setRotationDegrees(rotationDegrees: Int): CropImageContractOptions {
cropImageOptions.rotationDegrees = (rotationDegrees + DEGREES_360) % DEGREES_360
return this
@@ -474,6 +512,7 @@ data class CropImageContractOptions(
* whether the image should be flipped horizontally.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setFlipHorizontally(flipHorizontally: Boolean): CropImageContractOptions {
cropImageOptions.flipHorizontally = flipHorizontally
return this
@@ -483,6 +522,7 @@ data class CropImageContractOptions(
* whether the image should be flipped vertically.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setFlipVertically(flipVertically: Boolean): CropImageContractOptions {
cropImageOptions.flipVertically = flipVertically
return this
@@ -492,6 +532,7 @@ data class CropImageContractOptions(
* optional, set crop menu crop button title.
* *Default: null, will use resource string: crop_image_menu_crop*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCropMenuCropButtonTitle(title: CharSequence?): CropImageContractOptions {
cropImageOptions.cropMenuCropButtonTitle = title
return this
@@ -501,6 +542,7 @@ data class CropImageContractOptions(
* Image resource id to use for crop icon instead of text.
* *Default: 0*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setCropMenuCropButtonIcon(@DrawableRes drawableResource: Int): CropImageContractOptions {
cropImageOptions.cropMenuCropButtonIcon = drawableResource
return this
@@ -510,6 +552,7 @@ data class CropImageContractOptions(
* Set whether the cropping option should be allowed or skipped entirely.
* *Default: false*
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setSkipEditing(skipEditing: Boolean): CropImageContractOptions {
cropImageOptions.skipEditing = skipEditing
cropImageOptions.showCropOverlay = !skipEditing
@@ -524,6 +567,7 @@ data class CropImageContractOptions(
* Note: To show the camera app as an option in Intent chooser you will need to add
* the camera permission ("android.permission.CAMERA") to your manifest file.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setShowIntentChooser(showIntentChooser: Boolean) = cropImageOptions.apply {
this.showIntentChooser = showIntentChooser
}
@@ -531,6 +575,7 @@ data class CropImageContractOptions(
/**
* Sets a custom title for the intent chooser
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setIntentChooserTitle(intentChooserTitle: String) = cropImageOptions.apply {
this.intentChooserTitle = intentChooserTitle
}
@@ -547,6 +592,7 @@ data class CropImageContractOptions(
* By default, the library sorts the list putting a few common
* apps like Google Photos and Google Photos Go at the start of the list.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setIntentChooserPriorityList(priorityAppPackages: List) = cropImageOptions.apply {
this.intentChooserPriorityList = priorityAppPackages
}
@@ -554,6 +600,7 @@ data class CropImageContractOptions(
/**
* Sets the background color of the Crop Image Activity screen.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setActivityBackgroundColor(@ColorInt color: Int) = cropImageOptions.apply {
this.activityBackgroundColor = color
}
@@ -561,6 +608,7 @@ data class CropImageContractOptions(
/**
* Sets the toolbar color of the Crop Image Activity screen.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setToolbarColor(@ColorInt color: Int) = cropImageOptions.apply {
this.toolbarColor = color
}
@@ -568,6 +616,7 @@ data class CropImageContractOptions(
/**
* Sets the toolbar color of the Crop Image Activity screen.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setToolbarTitleColor(@ColorInt color: Int) = cropImageOptions.apply {
this.toolbarTitleColor = color
}
@@ -575,6 +624,7 @@ data class CropImageContractOptions(
/**
* Sets the toolbar back button color of the Crop Image Activity screen.
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setToolbarBackButtonColor(@ColorInt color: Int) = cropImageOptions.apply {
this.toolbarBackButtonColor = color
}
@@ -587,6 +637,7 @@ data class CropImageContractOptions(
* 3. Toolbar menu icon color
* 4. Toolbar menu text color
*/
+ @Deprecated("Please modify the associated properties directly on CropImageOptions using either primary constructor or the copy method")
fun setToolbarTintColor(@ColorInt color: Int) = cropImageOptions.apply {
this.activityMenuTextColor = color
this.activityMenuIconColor = color
@@ -595,6 +646,9 @@ data class CropImageContractOptions(
}
}
+@Deprecated(
+ message = "Please construct your own CropImageContractOptions using the constructor.",
+)
fun options(
uri: Uri? = null,
builder: CropImageContractOptions.() -> (Unit) = {},
diff --git a/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt b/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt
index 8ed9de3b..acd67bff 100644
--- a/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt
+++ b/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt
@@ -40,7 +40,7 @@ class CropImageContractTest {
}
// WHEN
try {
- fragment?.cropImageIntent(options { setMaxZoom(-10) })
+ fragment?.cropImageIntent(CropImageContractOptions(null, CropImageOptions().copy(maxZoom = -10)))
} catch (e: Exception) {
result = e
}
@@ -68,7 +68,7 @@ class CropImageContractTest {
onFragment { fragment = it }
}
// WHEN
- fragment?.cropImage(options())
+ fragment?.cropImage(CropImageContractOptions(null, CropImageOptions()))
// THEN
assertEquals(expected, fragment?.cropResult)
}
@@ -105,7 +105,7 @@ class CropImageContractTest {
onFragment { fragment = it }
}
// WHEN
- fragment?.cropImage(options())
+ fragment?.cropImage(CropImageContractOptions(null, CropImageOptions()))
// THEN
assertEquals(expected, fragment?.cropResult)
}
@@ -116,50 +116,59 @@ class CropImageContractTest {
var cropImageIntent: Intent? = null
val expectedClassName = CropImageActivity::class.java.name
val expectedSource = "file://testInput".toUri()
- val options = options(expectedSource) {
- setCropShape(CropImageView.CropShape.OVAL)
- setSnapRadius(1f)
- setTouchRadius(2f)
- setGuidelines(CropImageView.Guidelines.ON_TOUCH)
- setScaleType(CropImageView.ScaleType.CENTER)
- setShowCropOverlay(true)
- setAutoZoomEnabled(false)
- setMultiTouchEnabled(true)
- setCenterMoveEnabled(false)
- setMaxZoom(17)
- setInitialCropWindowPaddingRatio(0.2f)
- setFixAspectRatio(true)
- setAspectRatio(3, 4)
- setBorderLineThickness(3f)
- setBorderLineColor(Color.GREEN)
- setBorderCornerThickness(5f)
- setBorderCornerOffset(6f)
- setBorderCornerLength(7f)
- setBorderCornerColor(Color.MAGENTA)
- setGuidelinesThickness(8f)
- setGuidelinesColor(Color.RED)
- setBackgroundColor(Color.BLUE)
- setMinCropWindowSize(5, 5)
- setMinCropResultSize(10, 10)
- setMaxCropResultSize(5000, 5000)
- setActivityTitle("Test Activity Title")
- setActivityMenuIconColor(Color.BLACK)
- setOutputUri(expectedSource)
- setOutputCompressFormat(Bitmap.CompressFormat.JPEG)
- setOutputCompressQuality(85)
- setRequestedSize(25, 30, CropImageView.RequestSizeOptions.NONE)
- setNoOutputImage(false)
- setInitialCropWindowRectangle(Rect(4, 5, 6, 7))
- setInitialRotation(13)
- setAllowRotation(true)
- setAllowFlipping(false)
- setAllowCounterRotation(true)
- setRotationDegrees(4)
- setFlipHorizontally(true)
- setFlipVertically(false)
- setCropMenuCropButtonTitle("Test Button Title")
- setCropMenuCropButtonIcon(R.drawable.ic_rotate_left_24)
- }
+ val options = CropImageContractOptions(
+ expectedSource,
+ CropImageOptions(
+ cropShape = CropImageView.CropShape.OVAL,
+ snapRadius = 1f,
+ touchRadius = 2f,
+ guidelines = CropImageView.Guidelines.ON_TOUCH,
+ scaleType = CropImageView.ScaleType.CENTER,
+ showCropOverlay = true,
+ autoZoomEnabled = false,
+ multiTouchEnabled = true,
+ centerMoveEnabled = false,
+ maxZoom = 17,
+ initialCropWindowPaddingRatio = 0.2f,
+ fixAspectRatio = true,
+ aspectRatioX = 3,
+ aspectRatioY = 4,
+ borderLineThickness = 3f,
+ borderLineColor = Color.GREEN,
+ borderCornerThickness = 5f,
+ borderCornerOffset = 6f,
+ borderCornerLength = 7f,
+ borderCornerColor = Color.MAGENTA,
+ guidelinesThickness = 8f,
+ guidelinesColor = Color.RED,
+ backgroundColor = Color.BLUE,
+ minCropWindowWidth = 5,
+ minCropWindowHeight = 5,
+ minCropResultWidth = 10,
+ minCropResultHeight = 10,
+ maxCropResultWidth = 5000,
+ maxCropResultHeight = 5000,
+ activityTitle = "Test Activity Title",
+ activityMenuIconColor = Color.BLACK,
+ customOutputUri = null,
+ outputCompressFormat = Bitmap.CompressFormat.JPEG,
+ outputCompressQuality = 85,
+ outputRequestWidth = 25,
+ outputRequestHeight = 30,
+ outputRequestSizeOptions = CropImageView.RequestSizeOptions.NONE,
+ noOutputImage = false,
+ initialCropWindowRectangle = Rect(4, 5, 6, 7),
+ initialRotation = 13,
+ allowRotation = true,
+ allowFlipping = false,
+ allowCounterRotation = true,
+ rotationDegrees = 4,
+ flipHorizontally = true,
+ flipVertically = false,
+ cropMenuCropButtonTitle = "Test Button Title",
+ cropMenuCropButtonIcon = R.drawable.ic_rotate_left_24,
+ ),
+ )
val testRegistry = object : ActivityResultRegistry() {
override fun onLaunch(
@@ -213,7 +222,7 @@ class CropImageContractTest {
onFragment { fragment = it }
}
// WHEN
- fragment?.cropImage(options())
+ fragment?.cropImage(CropImageContractOptions(null, CropImageOptions()))
// THEN
assertEquals(false, fragment?.cropResult?.isSuccessful)
}