Skip to content

Commit

Permalink
API: Make CropOverlayView internal.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech committed Oct 20, 2022
1 parent ccc4fc4 commit 3b3fa77
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
32 changes: 10 additions & 22 deletions cropper/src/main/kotlin/com/canhub/cropper/CropImageAnimation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,26 @@ internal class CropImageAnimation(

override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
val animRect = RectF().apply {
left = (
startCropWindowRect.left +
(endCropWindowRect.left - startCropWindowRect.left) * interpolatedTime
)
top = (
startCropWindowRect.top +
(endCropWindowRect.top - startCropWindowRect.top) * interpolatedTime
)
right = (
startCropWindowRect.right +
(endCropWindowRect.right - startCropWindowRect.right) * interpolatedTime
)
bottom = (
startCropWindowRect.bottom +
(endCropWindowRect.bottom - startCropWindowRect.bottom) * interpolatedTime
)
left = (startCropWindowRect.left + (endCropWindowRect.left - startCropWindowRect.left) * interpolatedTime)
top = (startCropWindowRect.top + (endCropWindowRect.top - startCropWindowRect.top) * interpolatedTime)
right = (startCropWindowRect.right + (endCropWindowRect.right - startCropWindowRect.right) * interpolatedTime)
bottom = (startCropWindowRect.bottom + (endCropWindowRect.bottom - startCropWindowRect.bottom) * interpolatedTime)
}

val animPoints = FloatArray(8)
for (i in animPoints.indices) {
animPoints[i] =
(startBoundPoints[i] + (endBoundPoints[i] - startBoundPoints[i]) * interpolatedTime)
animPoints[i] = (startBoundPoints[i] + (endBoundPoints[i] - startBoundPoints[i]) * interpolatedTime)
}

cropOverlayView.apply {
cropWindowRect = animRect
setBounds(animPoints, imageView.width, imageView.height)
invalidate()
}

val animMatrix = FloatArray(9)
for (i in animMatrix.indices) {
animMatrix[i] =
(startImageMatrix[i] + (endImageMatrix[i] - startImageMatrix[i]) * interpolatedTime)
animMatrix[i] = (startImageMatrix[i] + (endImageMatrix[i] - startImageMatrix[i]) * interpolatedTime)
}

imageView.apply {
Expand All @@ -86,10 +74,10 @@ internal class CropImageAnimation(
}
}

override fun onAnimationStart(animation: Animation) {}
override fun onAnimationStart(animation: Animation) = Unit
override fun onAnimationEnd(animation: Animation) {
imageView.clearAnimation()
}

override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationRepeat(animation: Animation) = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ class CropImageIntentChooser(
private val activity: ComponentActivity,
private val callback: ResultCallback,
) {

interface ResultCallback {

fun onSuccess(uri: Uri?)

fun onCancelled()
}

companion object {

const val GOOGLE_PHOTOS = "com.google.android.apps.photos"
const val GOOGLE_PHOTOS_GO = "com.google.android.apps.photosgo"
const val SAMSUNG_GALLERY = "com.sec.android.gallery3d"
Expand Down
11 changes: 6 additions & 5 deletions cropper/src/main/kotlin/com/canhub/cropper/CropOverlayView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import kotlin.math.min
import kotlin.math.sin

/** A custom View representing the crop window and the shaded background outside the crop window. */
class CropOverlayView
@JvmOverloads constructor(context: Context?, attrs: AttributeSet? = null) : View(context, attrs) {

companion object {

internal class CropOverlayView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : View(context, attrs) {
internal companion object {
/**
* Creates the paint object for drawing text label over crop overlay */
internal fun getTextPaint(options: CropImageOptions): Paint =
Expand Down Expand Up @@ -74,6 +74,7 @@ class CropOverlayView
return borderPaint
}
}

private var mCropCornerRadius: Float = 0f
private var mCircleCornerFillColor: Int? = null
private var mOptions: CropImageOptions? = null
Expand Down

0 comments on commit 3b3fa77

Please sign in to comment.