From 7eb319126c6752187c3cfe943073c916ecaf5b7c Mon Sep 17 00:00:00 2001 From: Niklas Baudy Date: Mon, 5 Aug 2024 12:00:14 +0200 Subject: [PATCH] API: Deprecate CropImageContract. (#637) --- .../main/kotlin/com/canhub/cropper/CropImageContract.kt | 9 ++++++++- .../com/canhub/cropper/CropImageContractOptions.kt | 6 ++++++ .../kotlin/com/canhub/cropper/ContractTestFragment.kt | 2 ++ .../kotlin/com/canhub/cropper/CropImageContractTest.kt | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContract.kt b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContract.kt index ecb16711..a1e3d35f 100644 --- a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContract.kt +++ b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContract.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package com.canhub.cropper import android.app.Activity @@ -11,8 +13,13 @@ import androidx.activity.result.contract.ActivityResultContract * The UI can be customized using [CropImageOptions]. * If you do not provide an [CropImageContractOptions.uri] in the input the user will be asked to pick an image before cropping. */ +@Deprecated( + """ + This ActivityResultContract is deprecated. + Please either roll your own ActivityResultContract with the desired behavior or copy paste this. +""", +) class CropImageContract : ActivityResultContract() { - @Suppress("DEPRECATION") override fun createIntent(context: Context, input: CropImageContractOptions) = Intent(context, CropImageActivity::class.java).apply { putExtra( CropImage.CROP_IMAGE_EXTRA_BUNDLE, diff --git a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt index 85d8a769..cc99c7fc 100644 --- a/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt +++ b/cropper/src/main/kotlin/com/canhub/cropper/CropImageContractOptions.kt @@ -2,6 +2,12 @@ package com.canhub.cropper import android.net.Uri +@Deprecated( + """ + This ActivityResultContract is deprecated. + Please either roll your own ActivityResultContract with the desired behavior or copy paste this. +""", +) data class CropImageContractOptions( val uri: Uri?, val cropImageOptions: CropImageOptions, diff --git a/cropper/src/test/kotlin/com/canhub/cropper/ContractTestFragment.kt b/cropper/src/test/kotlin/com/canhub/cropper/ContractTestFragment.kt index c65da614..b5c67dab 100644 --- a/cropper/src/test/kotlin/com/canhub/cropper/ContractTestFragment.kt +++ b/cropper/src/test/kotlin/com/canhub/cropper/ContractTestFragment.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package com.canhub.cropper import android.content.Intent diff --git a/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt b/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt index 615c62cf..d2a6eac1 100644 --- a/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt +++ b/cropper/src/test/kotlin/com/canhub/cropper/CropImageContractTest.kt @@ -17,6 +17,7 @@ import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith +@Suppress("DEPRECATION") @RunWith(AndroidJUnit4::class) class CropImageContractTest {