Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-EasyImage-green.svg?style=true)](https://android-arsenal.com/details/1/2725) [![](https://jitpack.io/v/jkwiecien/EasyImage.svg)](https://jitpack.io/#jkwiecien/EasyImage)
[![](https://jitpack.io/v/abhinav12k/EasyPicker.svg)](https://jitpack.io/#abhinav12k/EasyPicker)

# What is it?
EasyImage allows you to easily capture images and videos from the gallery, camera or documents without creating lots of boilerplate.
EasyPicker is an extended version of easy image library which allows you to easily capture images and videos from the gallery, camera or get files from documents based on specified file formats without creating lots of boilerplate.

# Setup

Expand All @@ -22,26 +23,27 @@ Also you'll need to ask for this permission in the runtime in the moment of your

If your app targets M and above and declares as using the CAMERA permission which is not granted, then attempting to use this action will result in a SecurityException.

For this reason, if your app uses `CAMERA` permission, you should check it along **with** `WRITE_EXTERNAL_STORAGE` before calling `EasyImage.openCamera()`
For this reason, if your app uses `CAMERA` permission, you should check it along **with** `WRITE_EXTERNAL_STORAGE` before calling `EasyPicker.openCamera()`

## Gradle dependency
Get the latest version from jitpack

[![](https://jitpack.io/v/jkwiecien/EasyImage.svg)](https://jitpack.io/#jkwiecien/EasyImage)
[![](https://jitpack.io/v/abhinav12k/EasyPicker.svg)](https://jitpack.io/#abhinav12k/EasyPicker)

# Usage
## Essentials

Create your EasyImageInstance like this:
Create your EasyPickerInstance like this:
```java
EasyImage easyImage = new EasyImage.Builder(context)
EasyPicker easypicker = new EasyPicker.Builder(context)

// Chooser only
// Will appear as a system chooser title, DEFAULT empty string
//.setChooserTitle("Pick media")
// Will tell chooser that it should show documents or gallery apps
//.setChooserType(ChooserType.CAMERA_AND_DOCUMENTS) you can use this or the one below
// Will tell chooser that it should show documents or gallery or all three of them
//.setChooserType(ChooserType.CAMERA_AND_DOCUMENTS)
//.setChooserType(ChooserType.CAMERA_AND_GALLERY)
//.setChooserType(ChooserType.CAMERA_AND_GALLERY_AND_DOCUMENTS)
// saving EasyImage state (as for now: last camera file link)
.setMemento(memento)

Expand All @@ -52,43 +54,46 @@ EasyImage easyImage = new EasyImage.Builder(context)

// Allow multiple picking
.allowMultiple(true)

// You can also specify the file formats you need to show in documents
//.addSupportedFileFormats(new String[]{"pdf","image"})
.build();
```

### Taking image straight from camera
- `easyImage.openCameraForImage(Activity activity,);`
- `easyImage.openCameraForImage(Fragment fragment);`
- `easyPicker.openCameraForImage(Activity activity,);`
- `easyPicker.openCameraForImage(Fragment fragment);`

### Capturing video
- `easyImage.openCameraForVideo(Activity activity);`
- `easyImage.openCameraForVideo(Fragment fragment);`
- `easyPicker.openCameraForVideo(Activity activity);`
- `easyPicker.openCameraForVideo(Fragment fragment);`

### Taking image from gallery or the gallery picker if there is more than 1 gallery app
- `easyImage.openGallery(Activity activity);`
- `easyImage.openGallery(Fragment fragment);`
- `easyPicker.openGallery(Activity activity);`
- `easyPicker.openGallery(Fragment fragment);`

### Taking image from documents
- `easyImage.openDocuments(Activity activity);`
- `easyImage.openDocuments(Fragment fragment);`
- `easyPicker.openDocuments(Activity activity);`
- `easyPicker.openDocuments(Fragment fragment);`

### Displaying system picker to chose from camera, documents, or gallery if no documents apps are available
- `easyImage.openChooser(Activity activity);`
- `easyImage.openChooser(Fragment fragment);`
- `easyPicker.openChooser(Activity activity);`
- `easyPicker.openChooser(Fragment fragment);`

### Getting the photo file

```java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

easyImage.handleActivityResult(requestCode, resultCode, data, this, new DefaultCallback() {
easyPicker.handleActivityResult(requestCode, resultCode, data, this, new DefaultCallback() {
@Override
public void onMediaFilesPicked(MediaFile[] imageFiles, MediaSource source) {
onPhotosReturned(imageFiles);
public void onMediaFilesPicked(MediaFile[] mediaFiles, MediaSource source) {
onPhotosReturned(mediaFiles);
}

@Override
public void onImagePickerError(@NonNull Throwable error, @NonNull MediaSource source) {
public void onPickerError(@NonNull Throwable error, @NonNull MediaSource source) {
//Some error handling
error.printStackTrace();
}
Expand All @@ -101,10 +106,6 @@ EasyImage easyImage = new EasyImage.Builder(context)
}
```

# Known issues
Library was pretty much rewritten from scratch in kotlin on 29.03.2019. Initial version 3.0.0 might be unstable. In case of problems fallback to version 2.1.1
Also version 3.0.0 is not backward compatible and will require some changes of those who used previous versions. These are not big tho. Updated readme explains it all.

# License

Copyright 2015 Jacek Kwiecień.
Expand Down
26 changes: 22 additions & 4 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
<manifest package="pl.aprilapps.easyphotopicker"
<manifest package="pl.aprilapps.easypicker"
xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
</intent>
<intent>
<action android:name="android.intent.action.PICK" />
</intent>
<intent>
<action android:name="android.media.action.VIDEO_CAPTURE" />
</intent>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
</intent>
</queries>

<application>
<provider
android:name=".EasyImageFileProvider"
android:authorities="${applicationId}.easyphotopicker.fileprovider"
android:name="pl.aprilapps.easypicker.EasyFileProvider"
android:authorities="${applicationId}.easypicker.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/easyimage_filepaths" />
android:resource="@xml/easypicker_filepaths" />
</provider>
</application>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

106 changes: 0 additions & 106 deletions library/src/main/java/pl/aprilapps/easyphotopicker/Intents.kt

This file was deleted.

5 changes: 5 additions & 0 deletions library/src/main/java/pl/aprilapps/easypicker/ChooserType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pl.aprilapps.easypicker

enum class ChooserType {
CAMERA_AND_GALLERY, CAMERA_AND_DOCUMENTS, CAMERA_AND_GALLERY_AND_DOCUMENTS
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.aprilapps.easyphotopicker
package pl.aprilapps.easypicker

/**
* Created by Jacek Kwiecień on 03.11.2015.
Expand All @@ -9,12 +9,12 @@ package pl.aprilapps.easyphotopicker
* Unlikely to be a duplicate of clients request code but not ideal.
*/

internal const val EASYIMAGE_LOG_TAG = "EasyImage"
internal const val EASYPICKER_LOG_TAG = "EasyPicker"

internal object RequestCodes {
const val PICK_PICTURE_FROM_DOCUMENTS = 34961
const val PICK_FILE_FROM_DOCUMENTS = 34961
const val PICK_PICTURE_FROM_GALLERY = 34962
const val PICK_PICTURE_FROM_CHOOSER = 34963
const val PICK_FILE_FROM_CHOOSER = 34963
const val TAKE_PICTURE = 34964
const val CAPTURE_VIDEO = 34965
}
12 changes: 12 additions & 0 deletions library/src/main/java/pl/aprilapps/easypicker/DefaultCallback.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pl.aprilapps.easypicker

/**
* Stas Parshin
* 05 November 2015
*/
abstract class DefaultCallback : EasyPicker.Callbacks {

override fun onPickerError(error: Throwable, source: MediaSource) {}

override fun onCanceled(source: MediaSource) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pl.aprilapps.easypicker;

import androidx.core.content.FileProvider;

public class EasyFileProvider extends FileProvider {

}
Loading