Skip to content

Commit c5299c7

Browse files
committed
edited README
1 parent 218994d commit c5299c7

1 file changed

Lines changed: 30 additions & 171 deletions

File tree

README.md

Lines changed: 30 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
1-
<p align="left">
2-
<img src="https://cloud.githubusercontent.com/assets/4659608/12700433/4276edc0-c7f3-11e5-9f2c-de6bcbb9416d.png" width="600">
3-
</p>
4-
51
# Media Picker
6-
![](https://img.shields.io/badge/Platform-Android-brightgreen.svg)
7-
![](https://img.shields.io/hexpm/l/plug.svg)
8-
![](https://img.shields.io/badge/version-2.4.4-blue.svg)
9-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ea51407d60d04c938c263de206095abf)](https://www.codacy.com/app/me_101/MediaPicker?utm_source=github.com&utm_medium=referral&utm_content=alhazmy13/MediaPicker&utm_campaign=badger)
10-
112

12-
**[Please let me know if your application go to production via this link](https://docs.google.com/forms/d/e/1FAIpQLSe4Y5Fwn1mlEoD4RxjXQzTvL4mofhESuBlTkAPQhI7J_WqMDQ/viewform?c=0&w=1)**
133
------
14-
Media Picker is an Android Libary that lets you to select multiple images, video or voice for Android 4.1 (API 16) +.
15-
You can report any issue on issues page. **Note: If you speak Arabic, you can submit issues with Arabic language and I will check them. :)**
4+
Media Picker is an Android Libary that lets you to select multiple images, video for Android 4.4 (API 19) +.
165

176
# NOTE
187
----
19-
This build `2.x.x` will break backward compatibility and there are a lot of changes to improve the performance and fix a lot of Leak memory issues, So please read below document carefully.
208
## Installation
219
------
22-
**Maven**
23-
24-
```xml
25-
<dependency>
26-
<groupId>net.alhazmy13.MediaPicker</groupId>
27-
<artifactId>libary</artifactId>
28-
<version>2.4.4</version>
29-
</dependency>
30-
```
31-
3210

3311
**Gradle**
3412

@@ -43,190 +21,71 @@ dependencies {
4321
## Images
4422
After adding the library, you need to:
4523

46-
1. Create an object from `ImagePicker` or `VideoPicker`
47-
2. Override `onActivityResult` to receive the path of image or videos.
48-
49-
50-
51-
### Create an `ImagePicker`
52-
You will need to create a new instance of `ImagePicker`. Once the instance are configured, you can call `build()`.
24+
### Create an `MediaPicker`
25+
You will need to create a new instance of `MediaPicker`. Once the instance are configured, you can call `build()`.
5326

54-
```java
55-
new ImagePicker.Builder(MainActivity.this)
56-
.mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
57-
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
58-
.directory(ImagePicker.Directory.DEFAULT)
59-
.imageExtension(ImagePicker.Extension.PNG)
60-
.scale(600, 600)
61-
.allowMultipleImages(false)
62-
.enableDebuggingMode(true)
63-
.build();
64-
```
65-
### Override `onActivityResult `
66-
In order to receive the path of image, you will need to override `onActivityResult ` .
67-
68-
```java
69-
@Override
70-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
71-
super.onActivityResult(requestCode, resultCode, data);
72-
73-
if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
74-
List<String> mPaths = data.getStringArrayListExtra(ImagePicker.EXTRA_IMAGE_PATH);
75-
//Your Code
76-
}
77-
}
27+
```kotlin
28+
new MediaPicker.Builder(MainActivity.this)
29+
.mode(MediaPicker.Mode.CAMERA_AND_GALLERY)
30+
.directory(MediaPicker.Directory.DEFAULT)
31+
.imageExtension(MediaPicker.Extension.PNG)
32+
.videoExtension(MediaPicker.Extension.MP4)
33+
.allowMultipleImages(false)
34+
.enableDebuggingMode(true)
35+
.setCallback { files->
36+
//TODO
37+
}
38+
.build();
7839
```
7940

80-
### Additional Options
41+
### Additional Image Options
8142
* `mode` to select the mode, you can choose one of these `CAMERA`,`GALLERY` or `CAMERA_AND_GALLERY`
8243

83-
```java
84-
.mode(ImagePicker.Mode.CAMERA)
44+
```kotlin
45+
.mode(MediaPicker.Mode.CAMERA)
8546
```
8647

8748
* `imageExtension` You can change the imageExtension of image to `PNG` or `JPG`
8849

89-
```java
90-
.imageExtension(ImagePicker.Extension.PNG)
91-
```
92-
* `compressLevel` You can change the quality of image with three different levels `HARD`,`MEDIUM`, `SOFT` or `NONE`
93-
94-
```java
95-
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
50+
```kotlin
51+
.imageExtension(MediaPicker.Extension.PNG)
9652
```
9753

9854
* `directory` You can pass the storage path, or select `Directory.DEFAULT_DIR` to keep the default path.
9955

100-
```java
101-
.directory(ImagePicker.Directory.DEFAULT)
56+
```kotlin
57+
.directory(MediaPicker.Directory.DEFAULT)
10258

10359
//OR
10460

10561
.directory(Environment.getExternalStorageDirectory()+"/myFolder")
10662

10763
```
10864

109-
* `scale` You can scale the image to a a minimum width and height. This will only be used if compressLevel is set. To avoid OutOfMemory issues, ensure this is used.
110-
111-
```java
112-
.scale(500, 500)
113-
```
11465
* `allowMultipleImages` Extra used to select and return multiple images from gallery **CANNOT select single image from gallery if this feature was enabled**
11566

116-
```java
67+
```kotlin
11768
.allowMultipleImages(true)
11869
```
11970

120-
* `enableDebuggingMode` used to print Image Picker Log
121-
122-
```java
123-
.enableDebuggingMode(true)
124-
```
125-
12671
* `allowOnlineImages` an option to allow the user to select any image from online resource ex: Google Drive **(KNOWN ISSUE) if you enable this option then you cannot select multiple images**
12772

128-
```java
73+
```kotlin
12974
.allowOnlineImages(true)
13075
```
13176

132-
133-
### Create an `VideoPicker`
134-
You will need to create a new instance of `VideoPicker`. Once the instance are configured, you can call `build()`.
135-
136-
```java
137-
new VideoPicker.Builder(MainActivity.this)
138-
.mode(VideoPicker.Mode.CAMERA_AND_GALLERY)
139-
.directory(VideoPicker.Directory.DEFAULT)
140-
.imageExtension(VideoPicker.Extension.MP4)
141-
.enableDebuggingMode(true)
142-
.build();
143-
```
144-
### Override `onActivityResult `
145-
In order to receive the path of videos, you will need to override `onActivityResult ` .
146-
147-
```java
148-
@Override
149-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
150-
super.onActivityResult(requestCode, resultCode, data);
151-
152-
if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
153-
List<String> mPaths = data.getStringArrayListExtra(VideoPicker.EXTRA_VIDEO_PATH);
154-
//Your Code
155-
}
156-
}
157-
```
158-
159-
### Additional Options
77+
### Additional Video Options
16078
* `mode` to select the mode, you can choose one of these `CAMERA`,`GALLERY` or `CAMERA_AND_GALLERY`
16179

162-
```java
163-
.mode(VideoPicker.Mode.CAMERA)
80+
```kotlin
81+
.mode(MediaPicker.Mode.CAMERA)
16482
```
16583

16684
* `imageExtension` You can change the imageExtension of video to `MP4`
16785

168-
```java
169-
.imageExtension(VideoPicker.Extension.MP4)
86+
```kotlin
87+
.imageExtension(MediaPicker.Extension.MP4)
17088
```
17189

172-
* `directory` You can pass the storage path, or select `Directory.DEFAULT_DIR` to keep the default path.
173-
174-
```java
175-
.directory(VideoPicker.Directory.DEFAULT)
176-
177-
//OR
178-
179-
.directory(Environment.getExternalStorageDirectory()+"/myFolder")
180-
181-
```
182-
183-
* `enableDebuggingMode` used to print Video Picker Log
184-
185-
```java
186-
.enableDebuggingMode(true)
187-
```
188-
189-
### RxJava 2 for MediaPicker
190-
191-
It's an extenstion that allow you to return an observable from `ImagePickerBuilder` or `VideoPickerBuilder`, all you need is to add below dependency and then return the observable from `ImagePickerHelper` || `VideoPickerHelper` class.
192-
193-
194-
**Gradle**
195-
196-
```gradle
197-
dependencies {
198-
implementation 'io.reactivex.rxjava2:rxandroid:(Last_version)'
199-
implementation 'io.reactivex.rxjava2:rxjava:(Last_version)'
200-
implementation 'net.alhazmy13.MediaPicker:rxjava:(Last_version)'
201-
}
202-
```
203-
204-
```Java
205-
new ImagePickerHelper(
206-
new ImagePicker.Builder(Context)
207-
...)
208-
.getObservable()
209-
.subscribe(....);
210-
```
211-
212-
------
213-
214-
215-
## Theme the pickers
216-
217-
You can change the strings be overwriting below resources in your project.
218-
219-
```xml
220-
221-
<string name="media_picker_select_from">Select From:</string>
222-
<string name="media_picker_camera">Camera</string>
223-
<string name="media_picker_gallery">Gallery</string>
224-
<string name="media_picker_ok">Ok</string>
225-
<string name="media_picker_cancel">Cancel</string>
226-
<string name="media_picker_some_permission_is_denied">Some Permission is Denied</string>
227-
<string name="media_picker_you_need_to_grant_access_to">You need to grant access to</string>
228-
<string name="media_picker_read_Write_external_storage"><![CDATA[Read & Write External Storage]]></string>
229-
```
230-
231-
23290

91+
library based on [https://github.com/alhazmy13/MediaPicker](https://github.com/alhazmy13/MediaPicker)

0 commit comments

Comments
 (0)