diff --git a/README.md b/README.md index f2ece9ba..8e5c49c3 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ class MainActivity { val result = CropImage.getActivityResult(data) if (resultCode == Activity.RESULT_OK) { val resultUri: Uri? = result?.uriContent - val resultFilePath: String? = result?.getFilePath(requireContext()) + val resultFilePath: String? = result?.getUriFilePath(requireContext()) } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { val error = result!!.error } diff --git a/cropper/src/main/java/com/canhub/cropper/BitmapLoadingWorkerJob.kt b/cropper/src/main/java/com/canhub/cropper/BitmapLoadingWorkerJob.kt index 90701941..3368d0de 100644 --- a/cropper/src/main/java/com/canhub/cropper/BitmapLoadingWorkerJob.kt +++ b/cropper/src/main/java/com/canhub/cropper/BitmapLoadingWorkerJob.kt @@ -78,7 +78,7 @@ class BitmapLoadingWorkerJob internal constructor( /** * The Android URI of the image to load. - * NOT a file path, for it use [getFilePath] + * NOT a file path, for it use [getUriFilePath] */ val uriContent: Uri @@ -95,7 +95,7 @@ class BitmapLoadingWorkerJob internal constructor( val error: Exception? /** The file path of the image to load */ - fun getFilePath(context: Context): String = getFilePathFromUri(context, uriContent) + fun getUriFilePath(context: Context): String = getFilePathFromUri(context, uriContent) internal constructor(uri: Uri, bitmap: Bitmap?, loadSampleSize: Int, degreesRotated: Int) { uriContent = uri diff --git a/cropper/src/main/java/com/canhub/cropper/CropImage.kt b/cropper/src/main/java/com/canhub/cropper/CropImage.kt index ed1e9a10..52a319d8 100644 --- a/cropper/src/main/java/com/canhub/cropper/CropImage.kt +++ b/cropper/src/main/java/com/canhub/cropper/CropImage.kt @@ -339,7 +339,7 @@ object CropImage { /** * Get URI to image received from capture by camera. * - * This is not the File Path, for it please use [getCaptureImageOutputFilePath] + * This is not the File Path, for it please use [getCaptureImageOutputUriFilePath] * * @param context used to access Android APIs, like content resolve, it is your * activity/fragment/widget. @@ -372,14 +372,14 @@ object CropImage { * @param context used to access Android APIs, like content resolve, it is your * activity/fragment/widget. */ - fun getCaptureImageOutputFilePath(context: Context): String = + fun getCaptureImageOutputUriFilePath(context: Context): String = getFilePathFromUri(context, getCaptureImageOutputUriContent(context)) /** * Get the URI of the selected image from [getPickImageChooserIntent]. * Will return the correct URI for camera and gallery image. * - * This is not the File Path, for it please use [getPickImageResultFilePath] + * This is not the File Path, for it please use [getPickImageResultUriFilePath] * * @param context used to access Android APIs, like content resolve, it is your * activity/fragment/widget. @@ -402,7 +402,7 @@ object CropImage { * activity/fragment/widget. * @param data the returned data of the activity result */ - fun getPickImageResultFilePath(context: Context, data: Intent?): String = + fun getPickImageResultUriFilePath(context: Context, data: Intent?): String = getFilePathFromUri(context, getPickImageResultUriContent(context, data)) /** diff --git a/cropper/src/main/java/com/canhub/cropper/CropImageView.kt b/cropper/src/main/java/com/canhub/cropper/CropImageView.kt index 15d6d69c..2bd2f58a 100644 --- a/cropper/src/main/java/com/canhub/cropper/CropImageView.kt +++ b/cropper/src/main/java/com/canhub/cropper/CropImageView.kt @@ -1659,7 +1659,7 @@ class CropImageView @JvmOverloads constructor(context: Context, attrs: Attribute * The Android uri of the saved cropped image result.

* Null if get cropped image was executed, no output requested or failure. * - * This is NOT the file path, please use [getFilePath] + * This is NOT the file path, please use [getUriFilePath] */ val uriContent: Uri?, /** The error that failed the loading/cropping (null if successful) */ @@ -1721,7 +1721,7 @@ class CropImageView @JvmOverloads constructor(context: Context, attrs: Attribute * The file path of the image to load * Null if get cropped image was executed, no output requested or failure. */ - fun getFilePath(context: Context): String? = + fun getUriFilePath(context: Context): String? = uriContent?.let { getFilePathFromUri(context, it) } } diff --git a/sample/src/main/java/com/canhub/cropper/sample/camera/presenter/SCameraPresenter.kt b/sample/src/main/java/com/canhub/cropper/sample/camera/presenter/SCameraPresenter.kt index e06e4a4c..a8867088 100644 --- a/sample/src/main/java/com/canhub/cropper/sample/camera/presenter/SCameraPresenter.kt +++ b/sample/src/main/java/com/canhub/cropper/sample/camera/presenter/SCameraPresenter.kt @@ -100,7 +100,7 @@ internal class SCameraPresenter : SCameraContract.Presenter { Log.v( "File Path", context - ?.let { CropImage.getActivityResult(data)?.getFilePath(it) } + ?.let { CropImage.getActivityResult(data)?.getUriFilePath(it) } .toString() ) @@ -110,16 +110,15 @@ internal class SCameraPresenter : SCameraContract.Presenter { } SCameraFragment.CUSTOM_REQUEST_CODE -> { context?.let { - Log.v("File Path", CropImage.getPickImageResultFilePath(it, data)) - - CropImage.getPickImageResultFilePath(it, data) + Log.v("File Path", CropImage.getPickImageResultUriFilePath(it, data)) + CropImage.getPickImageResultUriFilePath(it, data) val uri = CropImage.getPickImageResultUriContent(it, data) view?.handleCropImageResult(uri.toString().replace("file:", "")) } } CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE -> { context?.let { ctx -> - Log.v("File Path", CropImage.getPickImageResultFilePath(ctx, data)) + Log.v("File Path", CropImage.getPickImageResultUriFilePath(ctx, data)) val uri = CropImage.getPickImageResultUriContent(ctx, data) view?.handleCropImageResult(uri.toString()) diff --git a/sample/src/main/java/com/canhub/cropper/sample/crop_image_view/app/SCropImageViewFragment.kt b/sample/src/main/java/com/canhub/cropper/sample/crop_image_view/app/SCropImageViewFragment.kt index cc99f014..05327b55 100644 --- a/sample/src/main/java/com/canhub/cropper/sample/crop_image_view/app/SCropImageViewFragment.kt +++ b/sample/src/main/java/com/canhub/cropper/sample/crop_image_view/app/SCropImageViewFragment.kt @@ -177,7 +177,7 @@ internal class SCropImageViewFragment : handleCropResult(CropImage.getActivityResult(data)) CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE -> { val ctx = context - ctx?.let { Log.v("File Path", CropImage.getPickImageResultFilePath(it, data)) } + ctx?.let { Log.v("File Path", CropImage.getPickImageResultUriFilePath(it, data)) } val imageUri = ctx?.let { CropImage.getPickImageResultUriContent(it, data) } if (imageUri != null && @@ -230,7 +230,7 @@ internal class SCropImageViewFragment : if (binding.cropImageView.cropShape == CropImageView.CropShape.OVAL) result.bitmap?.let { CropImage.toOvalBitmap(it) } else result.bitmap - context?.let { Log.v("File Path", result.getFilePath(it).toString()) } + context?.let { Log.v("File Path", result.getUriFilePath(it).toString()) } SCropResultActivity.start(this, imageBitmap, result.uriContent, result.sampleSize) } else { Log.e("AIC", "Failed to crop image", result?.error) diff --git a/sample/src/main/java/com/canhub/cropper/sample/extend_activity/app/SExtendActivity.kt b/sample/src/main/java/com/canhub/cropper/sample/extend_activity/app/SExtendActivity.kt index ac1e0f2c..0284cb04 100644 --- a/sample/src/main/java/com/canhub/cropper/sample/extend_activity/app/SExtendActivity.kt +++ b/sample/src/main/java/com/canhub/cropper/sample/extend_activity/app/SExtendActivity.kt @@ -94,7 +94,7 @@ internal class SExtendActivity : CropImageActivity(), SExtendContract.View { sampleSize ) - Log.v("File Path", result.getFilePath(this).toString()) + Log.v("File Path", result.getUriFilePath(this).toString()) binding.cropImageView.setImageUriAsync(result.uriContent) }