@@ -6,7 +6,7 @@ This app can make the file picking process easy, which allows you to select Pict
66For using this library, you need to migrate your project to AndroidX(If your project is not migrated to AndroidX).
77
88
9- <img src =" app_demo_a .jpg" width =" 30% " height =" 30% " />
9+ <img src =" app_demo_b .jpg" width =" 30% " height =" 30% " />
1010
1111
1212# Getting Started
@@ -25,16 +25,16 @@ allprojects {
2525buildscript {
2626 repositories {
2727 maven { url "https://www.jitpack.io" }
28- }
28+ }
2929}
3030```
3131
3232Then, Add this in your root ` build.gradle ` file (app level gradle file):
3333
3434 add implementation 'implementation 'com.github.braver-tool:Android11FilePicker:0.1.1' to your build.gradle dependencies block.
35-
35+
3636 for example:
37-
37+
3838 ```
3939 dependencies {
4040 implementation 'com.github.braver-tool:Android11FilePicker:0.1.1'
@@ -56,8 +56,66 @@ It depends on your targetAPI:
5656- ` targetAPI <= 28 ` , you are fine ;)
5757- ` targetAPI >= 29 ` , please enable ` requestLegacyExternalStorage ` on your Manifest.xml file
5858
59+ ## How to use the included SD-card picker:
60+
61+ ### Include a provider element
62+
63+ Due to changes in Android 6.0 Marshmallow, bare File URIs can no
64+ longer be returned in a safe way. This change requires you to add an
65+ entry to your manifest.
66+
67+ ** NOTE: If you have an existing content provider in your app with the same authority you will have a conflict.**
68+
69+ ``` xml
70+ <provider
71+ android : name =" androidx.core.content.FileProvider"
72+ android : authorities =" ${applicationId}.provider"
73+ android : exported =" false"
74+ android : grantUriPermissions =" true" >
75+ <meta-data
76+ android : name =" android.support.FILE_PROVIDER_PATHS"
77+ android : resource =" @xml/provider_paths"
78+ tools : replace =" android:resource" />
79+ </provider >
80+ ```
81+
5982## Permissions Needed :
6083
6184* android.permission.READ_EXTERNAL_STORAGE
6285* android.permission.CAMERA
63- * android.permission.RECORD_AUDIO
86+ * android.permission.RECORD_AUDIO
87+
88+ ### Include the camera activity
89+
90+ ** NOTE: The theme set in the manifest is important.
91+
92+ ``` xml
93+ <activity
94+ android : name =" com.braver.tool.picker.CameraActivity"
95+ android : label =" @string/app_name"
96+ android : theme =" @style/Theme.FilePicker" >
97+ </activity >
98+ ```
99+
100+ ### Handling the ActivityResult
101+
102+ You can use the included utility method to parse the activity result:
103+
104+ ``` java
105+ activityResultLauncherForGallery = registerForActivityResult(new ActivityResultContracts .StartActivityForResult (), result - > {
106+ if (result. getResultCode() == RESULT_OK && result. getData() != null ) {
107+ Uri selectedMediaUri = result. getData(). getData();
108+ File imageFile = new BraveFilePicker (). setActivity(PickerActivity . this ). setIsCompressImage(false ). setIsTrimVide(false ). setFileType(BraveFileType . IMAGE ). setDestinationFilePath(AppUtils . getRandomImageFileName(PickerActivity . this )). setContentUri(selectedMediaUri). getSourceFile();
109+ // Do something with the result...
110+ }
111+ });
112+ ```
113+
114+ ## Want to customize further?
115+
116+ Sample project is here(https://github.com/braver-tool/Android11FilePicker )
117+
118+ ## Usage
119+
120+ * Photoview - ImageView for Android that supports zooming, by various touch gestures.
121+ https://github.com/Baseflow/PhotoView
0 commit comments