From 33a0a42911d31a92595269640272d55013c4629c Mon Sep 17 00:00:00 2001 From: Canato Date: Fri, 5 Nov 2021 17:35:25 +0000 Subject: [PATCH] Prepare for release 3.3.6 (#259) * Code cleaning * Update changelog release --- CHANGELOG.md | 2 +- .../main/java/com/canhub/cropper/CropImage.kt | 22 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6acc9fc..2bbde8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. -## [unreleased 3.3.6] - 05/10/21 +## [3.3.6] - 05/11/21 ### Added - Added `PickImageContractOptions` to enable users specify image source [#226](https://github.com/CanHub/Android-Image-Cropper/issues/226) diff --git a/cropper/src/main/java/com/canhub/cropper/CropImage.kt b/cropper/src/main/java/com/canhub/cropper/CropImage.kt index ee498449..5f92d7b3 100644 --- a/cropper/src/main/java/com/canhub/cropper/CropImage.kt +++ b/cropper/src/main/java/com/canhub/cropper/CropImage.kt @@ -194,24 +194,20 @@ object CropImage { val includeGallery = options.includeGallery val allIntents: MutableList = ArrayList() val packageManager = context.packageManager + // collect all camera intents if Camera permission is available - if (!isExplicitCameraPermissionRequired(context) && includeCamera) { + if (!isExplicitCameraPermissionRequired(context) && includeCamera) allIntents.addAll(getCameraIntents(context, packageManager)) - } - if (includeGallery) { - allIntents.addAll( - getGalleryIntents( - packageManager, - Intent.ACTION_GET_CONTENT - ) - ) - } + + if (includeGallery) + allIntents.addAll(getGalleryIntents(packageManager, Intent.ACTION_GET_CONTENT)) + // Create a chooser from the main intent val chooserIntent = Intent.createChooser(allIntents.removeAt(allIntents.size - 1), title) + // Add all other intents - chooserIntent.putExtra( - Intent.EXTRA_INITIAL_INTENTS, allIntents.toTypedArray() - ) + chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, allIntents.toTypedArray()) + return chooserIntent }