Giter VIP home page Giter VIP logo

imagepicker's Introduction

📸Image Picker Library for Android

Download Releases API Build Status Language Android Arsenal ktlint PRWelcome Open Source Love License Twitter

Built with ❤︎ by Dhaval Patel and contributors

Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera. It also allows to Crop and Compresses the Image based on Aspect Ratio, Resolution and Image Size.

Almost 90% of the app that I have developed has an Image upload feature. Along with the image selection, Sometimes I needed a crop feature for profile image for that I've used uCrop. Most of the time I need to compress the image as the image captured from the camera is more than 5-10 MBs and sometimes we have a requirement to upload images with specific resolution/size, in that case, image compress is the way to go option. To simplify the image pick/capture option I have created ImagePicker library. I hope it will be useful to all.

🐱‍🏍Features:

  • Pick Gallery Image
  • Pick Image from Google Drive
  • Capture Camera Image
  • Crop Image (Crop image based on provided aspect ratio or let user choose one)
  • Compress Image (Compress image based on provided resolution and size)
  • Retrieve Image Result as Uri object (Retrieve as File object feature is removed in v2.0 to support scope storage)
  • Handle runtime permission for camera
  • Does not require storage permission to pick gallery image or capture new image.

🎬Preview

Profile Image Picker Gallery Only Camera Only

💻Usage

  1. Gradle dependency:

    allprojects {
       repositories {
           	maven { url "https://jitpack.io" }
       }
    }
    implementation 'com.github.dhaval2404:imagepicker:2.1'

    If you are yet to Migrate on AndroidX, Use support build artifact:

    implementation 'com.github.dhaval2404:imagepicker-support:1.7.1'
  2. The ImagePicker configuration is created using the builder pattern.

    Kotlin

    ImagePicker.with(this)
            .crop()	    			//Crop image(Optional), Check Customization for more option
            .compress(1024)			//Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)	//Final image resolution will be less than 1080 x 1080(Optional)
            .start()

    Java

    ImagePicker.with(this)
            .crop()	    			//Crop image(Optional), Check Customization for more option
            .compress(1024)			//Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)	//Final image resolution will be less than 1080 x 1080(Optional)
            .start()
  3. Handling results

    Override onActivityResult method and handle ImagePicker result.

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
         if (resultCode == Activity.RESULT_OK) {
             //Image Uri will not be null for RESULT_OK
             val uri: Uri = data?.data!!
    
             // Use Uri object instead of File to avoid storage permissions
             imgProfile.setImageURI(fileUri)
         } else if (resultCode == ImagePicker.RESULT_ERROR) {
             Toast.makeText(this, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
         } else {
             Toast.makeText(this, "Task Cancelled", Toast.LENGTH_SHORT).show()
         }
    }

    Inline method (with registerForActivityResult, Only Works with FragmentActivity and AppCompatActivity)

    i. Add required dependency for registerForActivityResult API

    implementation "androidx.activity:activity-ktx:1.2.3"
    implementation "androidx.fragment:fragment-ktx:1.3.3"

    ii. Declare this method inside fragment or activity class

    private val startForProfileImageResult =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
            val resultCode = result.resultCode
            val data = result.data
    
            if (resultCode == Activity.RESULT_OK) {
                //Image Uri will not be null for RESULT_OK
                val fileUri = data?.data!!
    
                mProfileUri = fileUri
                imgProfile.setImageURI(fileUri)
            } else if (resultCode == ImagePicker.RESULT_ERROR) {
                Toast.makeText(this, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
            } else {
                Toast.makeText(this, "Task Cancelled", Toast.LENGTH_SHORT).show()
            }
        }

    iii. Create ImagePicker instance and launch intent

    ImagePicker.with(this)
            .compress(1024)         //Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)  //Final image resolution will be less than 1080 x 1080(Optional)
            .createIntent { intent ->
                startForProfileImageResult.launch(intent)
            }

🎨Customization

  • Pick image using Gallery

    ImagePicker.with(this)
    	.galleryOnly()	//User can only select image from Gallery
    	.start()	//Default Request Code is ImagePicker.REQUEST_CODE
  • Capture image using Camera

    ImagePicker.with(this)
    	.cameraOnly()	//User can only capture image using Camera
    	.start()
  • Crop image

    ImagePicker.with(this)
    	.crop()	    //Crop image and let user choose aspect ratio.
    	.start()
  • Crop image with fixed Aspect Ratio

    ImagePicker.with(this)
    	.crop(16f, 9f)	//Crop image with 16:9 aspect ratio
    	.start()
  • Crop square image(e.g for profile)

    ImagePicker.with(this)
        .cropSquare()	//Crop square image, its same as crop(1f, 1f)
        .start()
  • Compress image size(e.g image should be maximum 1 MB)

    ImagePicker.with(this)
    	.compress(1024)	//Final image size will be less than 1 MB
    	.start()
  • Set Resize image resolution

    ImagePicker.with(this)
    	.maxResultSize(620, 620)	//Final image resolution will be less than 620 x 620
    	.start()
  • Intercept ImageProvider, Can be used for analytics

    ImagePicker.with(this)
        .setImageProviderInterceptor { imageProvider -> //Intercept ImageProvider
            Log.d("ImagePicker", "Selected ImageProvider: "+imageProvider.name)
        }
        .start()
  • Intercept Dialog dismiss event

    ImagePicker.with(this)
    	.setDismissListener {
    		// Handle dismiss event
    		Log.d("ImagePicker", "onDismiss");
    	}
    	.start()
  • Specify Directory to store captured, cropped or compressed images. Do not use external public storage directory (i.e. Environment.getExternalStorageDirectory())

    ImagePicker.with(this)
       /// Provide directory path to save images, Added example saveDir method. You can choose directory as per your need.
    
       //  Path: /storage/sdcard0/Android/data/package/files
       .saveDir(getExternalFilesDir(null)!!)
       //  Path: /storage/sdcard0/Android/data/package/files/DCIM
       .saveDir(getExternalFilesDir(Environment.DIRECTORY_DCIM)!!)
       //  Path: /storage/sdcard0/Android/data/package/files/Download
       .saveDir(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)!!)
       //  Path: /storage/sdcard0/Android/data/package/files/Pictures
       .saveDir(getExternalFilesDir(Environment.DIRECTORY_PICTURES)!!)
       //  Path: /storage/sdcard0/Android/data/package/files/Pictures/ImagePicker
       .saveDir(File(getExternalFilesDir(Environment.DIRECTORY_PICTURES)!!, "ImagePicker"))
       //  Path: /storage/sdcard0/Android/data/package/files/ImagePicker
       .saveDir(getExternalFilesDir("ImagePicker")!!)
       //  Path: /storage/sdcard0/Android/data/package/cache/ImagePicker
       .saveDir(File(getExternalCacheDir(), "ImagePicker"))
       //  Path: /data/data/package/cache/ImagePicker
       .saveDir(File(getCacheDir(), "ImagePicker"))
       //  Path: /data/data/package/files/ImagePicker
       .saveDir(File(getFilesDir(), "ImagePicker"))
    
      // Below saveDir path will not work, So do not use it
      //  Path: /storage/sdcard0/DCIM
      //  .saveDir(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM))
      //  Path: /storage/sdcard0/Pictures
      //  .saveDir(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES))
      //  Path: /storage/sdcard0/ImagePicker
      //  .saveDir(File(Environment.getExternalStorageDirectory(), "ImagePicker"))
    
        .start()
  • Limit MIME types while choosing a gallery image

    ImagePicker.with(this)
        .galleryMimeTypes(  //Exclude gif images
            mimeTypes = arrayOf(
              "image/png",
              "image/jpg",
              "image/jpeg"
            )
          )
        .start()
  • You can also specify the request code with ImagePicker

    ImagePicker.with(this)
    	.maxResultSize(620, 620)
    	.start(101)	//Here 101 is request code, you may use this in onActivityResult
  • Add Following parameters in your colors.xml file, If you want to customize uCrop Activity.

    <resources>
        <!-- Here you can add color of your choice  -->
        <color name="ucrop_color_toolbar">@color/teal_500</color>
        <color name="ucrop_color_statusbar">@color/teal_700</color>
        <color name="ucrop_color_widget_active">@color/teal_500</color>
    </resources>

💥Compatibility

  • Library - Android Kitkat 4.4+ (API 19)
  • Sample - Android Kitkat 4.4+ (API 19)

✔️Changelog

Version: 2.1

  • Added uzbekistan translation (Special Thanks to Khudoyshukur Juraev)
  • Removed requestLegacyExternalStorage flag
  • Removed unused string resources

Version: 2.0

  • Added arabic translation #157 (Special Thanks to zhangzhu95)
  • Added norwegian translation #163 (Special Thanks to TorkelV)
  • Added german translation #192 (Special Thanks to MDXDave)
  • Added method to return Intent for manual launching ImagePicker #182 (Special Thanks to tobiasKaminsky)
  • Added support for android 11 #199
  • Fixed android scope storage issue #29
  • Removed storage permissions #29
  • Fixed calculateInSampleSize leads to overly degraded quality #152 (Special Thanks to FlorianDenis)
  • Fixed camera app not found issue #162
  • Fixed Playstore requestLegacyExternalStorage flag issue #199

Version: 1.8

  • Added dialog dismiss listener (Special Thanks to kibotu)
  • Added text localization (Special Thanks to yamin8000 and Jose Bravo)
  • Fixed crash issue on missing camera app #69
  • Fixed issue selecting images from download folder #86
  • Fixed exif information lost issue #121
  • Fixed crash issue on large image crop #122
  • Fixed saving image in cache issue #127

Version: 1.7

  • Added option to limit MIME types while choosing a gallery image (Special Thanks to Marchuck)
  • Introduced ImageProviderInterceptor, Can be used for analytics (Special Thanks to Marchuck)
  • Fixed .crop() opening gallery or camera twice #32
  • Fixed FileProvider of the library clashes with the FileProvider of the app #51 (Special Thanks to OyaCanli)
  • Added option to set Storage Directory #52
  • Fixed NullPointerException in FileUriUtils.getPathFromRemoteUri() #61 (Special Thanks to himphen)
  • Fixed UCropActivity Crash Android 4.4 (KiKat) #82
  • Fixed PNG image saved as JPG after crop issue #94
  • Fixed PNG image saved as JPG after compress issue #105
  • Added Polish text translation #115 (Special Thanks to MarcelKijanka)
  • Failed to find configured root exception #116

Version: 1.6

  • Improved UI/UX of sample app
  • Removed Bitmap Deprecated Property #33 (Special Thanks to nauhalf)
  • Camera opens twice when "Don't keep activities" option is ON #41 (Special Thanks to benji101)
  • Fixed uCrop Crash Issue #42

Version: 1.5

  • Fixed app crash issue, due to Camera Permission in manifest #34
  • Added Option for Dynamic Crop Ratio. Let User choose aspect ratio #36 (Special Thanks to Dor-Sloim)

Version: 1.4

Version: 1.3

  • Sample app made compatible with Android Kitkat 4.4+ (API 19)
  • Fixed Uri to File Conversion issue #8 (Special Thanks to squeeish)

Version: 1.2

  • Added Support for Inline Activity Result(Special Thanks to soareseneves)
  • Fixed issue #6

Version: 1.1

  • Optimized Compression Logic
  • Replace white screen with transparent one.

Version: 1.0

  • Initial Build

📃 Libraries Used

Let us know!

We'll be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the library.

License

Copyright 2019-2021, Dhaval Patel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

imagepicker's People

Contributors

armandditto avatar benjaminlefevre avatar dhaval2404 avatar douglas-srs avatar linx64 avatar lotuxpunk avatar marchuck avatar mateusandreatta avatar mdxdave avatar onuryurtturk avatar soareseneves avatar terence-codigo avatar tobiaskaminsky avatar torkelv avatar yamin8000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagepicker's Issues

ActivityNotFoundException: android.intent.action.OPEN_DOCUMENT

ActivityNotFoundException: android.intent.action.OPEN_DOCUMENT

Fatal Exception: java.lang.RuntimeException
:Unable to start activity ComponentInfo{com.github.dhaval2404.imagepicker.ImagePickerActivity}
:android.content.ActivityNotFoundException
:No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] typ=image/* }

I face this issue only in android 8 (oreo)

Feature Request: Bottom picker with Camera View and image list in grid view

Thank you for your great library with nice Kotlin. To make it the best, i would like to propose a feature request.

When set provider(ImageProvider.BOTH), there is config to display a bottom sheet fragment which is a grid view include camera view and images. You can see TedBottomPicker to get the idea, but that lib is not good enough.

Get Image form gallery not work in andorid Q

https://developer.android.com/training/data-storage/files/external-scoped

Warning: Apps will be required to use scoped storage in next year's major platform release for all apps, independent of target SDK level. Therefore, you should ensure that your app works with scoped storage well in advance. To do so, make sure that the behavior is enabled for devices that run Android 10 (API level 29) and higher.

I add this to manifest and everything work perfect.
`<manifest ... >

<application android:requestLegacyExternalStorage="true" ... >
...

`

Could not find com.github.yalantis:ucrop:2.2.2 again

Could not find com.github.yalantis:ucrop:2.2.2.
Searched in the following locations:

my gradle
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }

}

i am url - https://jcenter.bintray.com/com/github/yalantis/ucrop/2.2.2/ucrop-2.2.2.jar
{
"errors" : [ {
"status" : 404,
"message" : "Could not find resource"
} ]
}

please update

FileProvider of the library clashes with the FileProvider of the app

Hi! Thanks for this library, I have been using it for a while without any issues.

However recently, when I added a FileProvider to my app, it clashed with the FileProvider of the library. It failed to merge the manifest, telling that there is already a FileProvider for the same authority.

I found this thread on StackOverflow helpful:
https://stackoverflow.com/questions/43175014/possible-to-use-multiple-authorities-with-fileprovider

As discussed there, adding suffixes to the authority name didn't help. Instead, creating a custom FileProvider class (an empty implementation, just a wrapper) solved the issue.

My problem is solved, but I think it would be better if the library itself uses this solution. Instead of adapting all client apps for the library, it would be more efficient to only adjust the library.

The solution is simple:
-Create a class that extends from FileProvider (an empty class, no code needed)
-In the manifest of the library, give this class as the name of the provider instead of FileProvider

If you wish, I can make a PR as well.

Best regards,

Oya Canli

Localization

Hello. How i can localization your lib? I need change "Edit Photo" to my language
Screenshot_20190607-172329

ImagePicker crash while capturing Camera Image and Camera Permission is Defined in Manifest

Today, I discover a very strange crash issue. When Camera Permission is declared in Manifest and android.media.action.IMAGE_CAPTURE intent is called then the app must request CAMERA runtime permission. Otherwise, app will be crashed.

And if we remove permission from manifest then an error will no longer be reproduced.

Found below StackOverflow link which has this kind of similar issue:
https://stackoverflow.com/questions/43042725/revoked-permission-android-permission-camera/43070198

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=4282, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.github.dhaval2404.imagepicker.sample/com.github.dhaval2404.imagepicker.ImagePickerActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:content://com.github.dhaval2404.imagepicker.sample.provider/external_files/DCIM/Camera/IMG_20190930_230312575.jpg} (has extras) } from ProcessRecord{bfa62b 30120:com.github.dhaval2404.imagepicker.sample/u0a134} (pid=30120, uid=10134) with revoked permission android.permission.CAMERA
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4845)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:content://com.github.dhaval2404.imagepicker.sample.provider/external_files/DCIM/Camera/IMG_20190930_230312575.jpg} (has extras) } from ProcessRecord{bfa62b 30120:com.github.dhaval2404.imagepicker.sample/u0a134} (pid=30120, uid=10134) with revoked permission android.permission.CAMERA
        at android.os.Parcel.createException(Parcel.java:2071)
        at android.os.Parcel.readException(Parcel.java:2039)
        at android.os.Parcel.readException(Parcel.java:1987)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3851)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1705)
        at android.app.Activity.startActivityForResult(Activity.java:5192)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
        at android.app.Activity.startActivityForResult(Activity.java:5150)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
        at com.github.dhaval2404.imagepicker.provider.CameraProvider.startCameraIntent(CameraProvider.kt:82)
        at com.github.dhaval2404.imagepicker.provider.CameraProvider.onRequestPermissionsResult(CameraProvider.kt:96)
        at com.github.dhaval2404.imagepicker.ImagePickerActivity.onRequestPermissionsResult(ImagePickerActivity.kt:87)
        at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8264)
        at android.app.Activity.dispatchActivityResult(Activity.java:8114)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
     Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:760)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:583)
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1288)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:514)

Multiple FileProvider causing manifest merge failed issue

Hi,

My project is in java and I never added any kotlin library or file. Also my project is not on android X.
When I use this implementation 'com.github.dhaval2404:imagepicker-support:1.5' in gradle I am getting the following error

java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
	at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:558)
	at com.android.build.gradle.tasks.ProcessApplicationManifest.doFullTaskAction(ProcessApplicationManifest.java:208)
	at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
	at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
	at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
	at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
	at java.util.Optional.map(Optional.java:215)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
	at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
	at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
	at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
	at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
	at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
	at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
	at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
	at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
	at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
	at java.util.Optional.map(Optional.java:215)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
	at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
	at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
	at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
	at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)

`

How to save img path/name

Hi, the title is pretty self explanatory :

I got a local database and I want to get the the full path (name of the pic included) in a String to save it.

Failed to pick Gallery Image

Library is awesome. But when i tried to pick an image from Downloads folder then it gives me the above error(Title) and the path was content://downloads/public_downloads/1511 Using this path am setting this to imageview like this Imageview.setImageURI

Translate text

Is there any way to translate edit photo title text and alert choose?

Logo design

Hi, I'm a logo designer, I design free logos for open source project and I can make a logo for your project. So, what do you think?

Version Bump

Hey there,

I think you forgot to bump the version after your last commit, I can't get the new features using version 1.1

Camera opens twice when "Don't keep activities" option is ON

Doing some tests while having the developer option "Don't keep activities" turned on (that simulates what could happen when low on memory). After taking a picture, the camera is started again. Taking a second picture, it now behave like it should. Please note that I'm using the cameraOnly() option.

I think the problem is that ImagePickerActivity, in its onCreate method, is not considering the savedInstanceState Bundle (which is not null if the activity has been destroyed and is being re-created). What I'm not sure is why it's working the second time, and not going on a loop.

Anyone else has this problem or can reproduce it?

Receiving "Failed To Create Camera Image File"

`
2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.util.FileUtil.getImageFile(FileUtil.kt:46)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.util.FileUtil.getImageFile$default(FileUtil.kt:30)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.provider.CameraProvider.startCameraIntent(CameraProvider.kt:86)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.provider.CameraProvider.checkPermission(CameraProvider.kt:72)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.provider.CameraProvider.startIntent(CameraProvider.kt:61)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.ImagePickerActivity.loadBundle(ImagePickerActivity.kt:68)

2019-12-01 14:00:05.865 16921-16921/com.irondigitalmedia.keep W/System.err: at com.github.dhaval2404.imagepicker.ImagePickerActivity.onCreate(ImagePickerActivity.kt:47)`

Your code says this shouldn't ever happen.

else -> {
Log.e(TAG, "Image provider can not be null")
// Something went Wrong! This case should never happen
setError(getString(R.string.error_task_cancelled))
}

line 72. I'm not sure what's going on. Would you need anything else to help figure out what's going on? The permission is given i checked the app permissions it settings.

This works great on a physical device (note 9), but doesn't work on a virtual device.

Performing pause of activity that is not resumed

I'm using this library for tablet app. I'm opening the camera by your method and clicking on back button it throwing the exception. and unable to go back.
`Performing pause of activity that is not resumed: {com.xxx/com.github.dhaval2404.imagepicker.ImagePickerActivity}
java.lang.RuntimeException: Performing pause of activity that is not resumed: {com.xxx/com.github.dhaval2404.imagepicker.ImagePickerActivity}

Unable to start activity ComponentInfo{com.github.dhaval2404.imagepicker.ImagePickerActivity

I received this error using this library:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.dhaval2404.imagepicker.ImagePickerActivity}: kotlin.TypeCastException: null cannot be cast to non-null type com.github.dhaval2404.imagepicker.constant.ImageProvider
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5420)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by kotlin.TypeCastException: null cannot be cast to non-null type com.github.dhaval2404.imagepicker.constant.ImageProvider
at com.github.dhaval2404.imagepicker.ImagePickerActivity.loadBundle(ImagePickerActivity.kt:49)
at com.github.dhaval2404.imagepicker.ImagePickerActivity.onCreate(ImagePickerActivity.kt:38)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5420)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

How can I resolve this issue?
Thanks

When I'm choosing camera, I'm getting crash below Android 8.0.0 Samsung S7

com.github.dhaval2404.imagepicker.ImagePickerActivity}: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:613)
at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
at com.github.dhaval2404.imagepicker.util.IntentUtils.getCameraIntent(IntentUtils.kt:75)
at com.github.dhaval2404.imagepicker.provider.CameraProvider.startCameraIntent(CameraProvider.kt:119)
at com.github.dhaval2404.imagepicker.provider.CameraProvider.checkPermission(CameraProvider.kt:100)
at com.github.dhaval2404.imagepicker.provider.CameraProvider.startIntent(CameraProvider.kt:89)
at com.github.dhaval2404.imagepicker.ImagePickerActivity.loadBundle(ImagePickerActivity.kt:104)
at com.github.dhaval2404.imagepicker.ImagePickerActivity.onCreate(ImagePickerActivity.kt:56)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

Ucrop crash

 ImagePicker.with(this@FromProyekActivity)
        .galleryOnly()    //User can only select image from Gallery
        .cropSquare()
        .compress(1024)
        .start { resultCode, data ->
            if (resultCode == Activity.RESULT_OK) {
                val fileUri = data?.data
                if (fileUri != null) {
                    mViewmodel.renderUpload(fileUri)
                }

                //You can get File object from intent
                val file: File? = ImagePicker.getFile(data)

                //You can also get File Path from intent
                val filePath: String? = ImagePicker.getFilePath(data)
            } else if (resultCode == ImagePicker.RESULT_ERROR) {
                Toast.makeText(
                    this@FromProyekActivity,
                    ImagePicker.getError(data),
                    Toast.LENGTH_SHORT
                ).show()
            } else {
                Toast.makeText(
                    this@FromProyekActivity,
                    "Task Cancelled",
                    Toast.LENGTH_SHORT
                )
                    .show()
            }

        }
Error Code : 
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.zerojump.a18app, PID: 14965
    java.lang.NoSuchMethodError: No virtual method start(Landroid/app/Activity;I)V in class Lcom/yalantis/ucrop/UCrop; or its super classes (declaration of 'com.yalantis.ucrop.UCrop' appears in /data/app/com.zerojump.a18app-to7xY13CNXQhLWgsLJMHvg==/base.apk!classes3.dex)
        at com.github.dhaval2404.imagepicker.provider.CropProvider.cropImage(CropProvider.kt:91)
        at com.github.dhaval2404.imagepicker.provider.CropProvider.startIntent(CropProvider.kt:61)
        at com.github.dhaval2404.imagepicker.ImagePickerActivity.setImage(ImagePickerActivity.kt:116)
        at com.github.dhaval2404.imagepicker.provider.GalleryProvider.handleResult(GalleryProvider.kt:104)
        at com.github.dhaval2404.imagepicker.provider.GalleryProvider.onActivityResult(GalleryProvider.kt:89)
        at com.github.dhaval2404.imagepicker.ImagePickerActivity.onActivityResult(ImagePickerActivity.kt:97)
        at android.app.Activity.dispatchActivityResult(Activity.java:7741)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4724)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4773)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2034)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:226)
        at android.app.ActivityThread.main(ActivityThread.java:7179)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

Add option to set Storage Directory

In the current version, All images are stored in the camera folder(Environment.DIRECTORY_DCIM).

Need to add an option to allow developers to set a storage directory path along with crop and compress options.

Not working in fragment

Hello Dhaval,

Hope you are doing well, I found that using your library and example it does not work in the fragment, it did not receive in fragment onActivityResult method.

Camera permission is redundant and decreases supported devices count

Hi,
Thanks a lot for this component, it saved me a lot of work!
I'm using v1.3 and when I try to publish my new bundle, Google Play Store tells me that some devices will not be compatible with the new version, it occurs because of this library.

In the readme file you've mentioned:

<!--
If Not using Camera feature, Add following line in app manifest.
This will remove permission while manifest merge
-->
<uses-permission android:name="android.permission.CAMERA" tools:node="remove"/> 

But, there's no actual need for this permission, unless of course you're presenting an embedded camera preview. If I'm not mistaking there's no embedded camera preview here, for now.

So:

  1. Can we remove it?
  2. We can add an option to your API that will ignore camera permissions, because when I'm using tools:node="remove" in the manifest this library simply ignores my request due to "missing permissions", which is wrong (that's the actual issue here).
  3. However, if you like, you can use activity.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY) to prevent camera usage when it is not available.

LMK what you think, I'll be glad to help :)

Memory Leak

When use providerBoth, leakcanary warn memory leak in ImageBuider picker....

Android 10 permission issue

Hi there!

Thanks for making this great library! I ran into some issues when using the library for Android 10. It's related to the file permission and the changes that have been made to it. The latest version uses scoped permissions for data storage: https://developer.android.com/training/data-storage/files/external-scoped

I'm not 100% sure if I need to update something on the caller side or if the library needs some changes. I was able to temporarily getting the library working by adding android:requestLegacyExternalStorage="true" to my manifest.

[Feature Request] Allow multiple image selection from gallery

Hello @Dhaval2404
Everything good to me, but how can i select 3 photos from gallery? It seems no method for setting this right?

ImagePicker.with(this)
	    .galleryOnly()     //User can only select image from Gallery
            .limit(3)               //need method like this
	    .start()		      //Default Request Code is ImagePicker.REQUEST_CODE

Thanks.

Implement Inline Activity Result

Hello,

First of all thanks for this great library!

I was wondering if you could please make the ImagePicker class open so I can override it, I want to add some way to open activity and get response with lambda which is way more convenient for me.

Failed to create Camera image file !

Hello i am getting Failed to create Camera image file in Error. !
device : PIXEL 3A API 29 Android Q
targetSdkVersion:29

Suggestion:

  1. You can not get public directory at API 29 LEVEL.. it is deprecated..

private fun getCameraDirectory(): File {
val dir = context.getExternalFilesDir(null)!!.absolutePath
return File(dir, "Camera")
}

  1. Change the targetSdkVersion to 28 from build.gradle file.

Images clicked in portrait mode are rotated.

When I take a picture from the camera in portrait mode the picture gets rotated. When the picture is taken by the camera in landscape mode the picture doesn't get rotated and looks the way it was clicked.

Silent Failure to Pick - ClassNotFound vs ClassCast and AppCompatActivity

In ImagePicker.kt startActivity, around line 299, there is the following code:

if (e is ClassNotFoundException) {

However, running Kotlin 1.3.61 and Java 1.8 the excption caught here is not a ClassNotFoundException it's a ClassCastException.

Because there is no other test for any other exception type in this handler, this method fails silently. To the developer, it appears that the picker fails without running the inline result handler.

Also, in the READ.ME it says:

If you are yet to Migrate on AndroidX, Use support build artifact: imagepicker-support:1.5

I am using several AndroidX components, however I had not yet migrated my Activity to AppCompatActivity. (I'm actually writing a Tasker plugin and the Tasker sample library doesn't use that super class). Even after changing to use imagepicker-support:1.5, it appears the library still does a cast to AppCompatActivity.

I'm a bit unclear what support:1.5 is supposed to change if the library still depends on AppCompatActivity. If AppCompatActivity is in fact a requirement, please consider updating the READ.ME to make this requirement clear.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.