• This repository has been archived on 30/May/2021
  • Stars
    star
    268
  • Rank 153,144 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Media Picker is an Android Libary that lets you to select multiple images or video

Media Picker

Codacy Badge

Please let me know if your application go to production via this link

Media Picker is an Android Libary that lets you to select multiple images, video or voice for Android 4.1 (API 16) +. 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. :)

NOTE


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.

Installation


Maven

<dependency>
<groupId>net.alhazmy13.MediaPicker</groupId>
<artifactId>libary</artifactId>
<version>2.4.4</version>
</dependency>

Gradle

dependencies {
	implementation 'net.alhazmy13.MediaPicker:libary:2.4.4'
}

Usage


Images

After adding the library, you need to:

  1. Create an object from ImagePicker or VideoPicker
  2. Override onActivityResult to receive the path of image or videos.

Create an ImagePicker

You will need to create a new instance of ImagePicker. Once the instance are configured, you can call build().

        new ImagePicker.Builder(MainActivity.this)
                        .mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
                        .compressLevel(ImagePicker.ComperesLevel.MEDIUM)
                        .directory(ImagePicker.Directory.DEFAULT)
                        .extension(ImagePicker.Extension.PNG)
                        .scale(600, 600)
                        .allowMultipleImages(false)
                        .enableDebuggingMode(true)
                        .build();

Override onActivityResult

In order to receive the path of image, you will need to override onActivityResult .

   @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
            List<String> mPaths = data.getStringArrayListExtra(ImagePicker.EXTRA_IMAGE_PATH);
            //Your Code
        }
    }

Additional Options

  • mode to select the mode, you can choose one of these CAMERA,GALLERY or CAMERA_AND_GALLERY
.mode(ImagePicker.Mode.CAMERA)
  • extension You can change the extension of image to PNG or JPG
.extension(ImagePicker.Extension.PNG)
  • compressLevel You can change the quality of image with three different levels HARD,MEDIUM, SOFT or NONE
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
  • directory You can pass the storage path, or select Directory.DEFAULT_DIR to keep the default path.
.directory(ImagePicker.Directory.DEFAULT)

//OR

.directory(Environment.getExternalStorageDirectory()+"/myFolder")
  • 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.
.scale(500, 500)
  • allowMultipleImages Extra used to select and return multiple images from gallery CANNOT select single image from gallery if this feature was enabled
	.allowMultipleImages(true)
  • enableDebuggingMode used to print Image Picker Log
	.enableDebuggingMode(true)
  • 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
	.allowOnlineImages(true)

Create an VideoPicker

You will need to create a new instance of VideoPicker. Once the instance are configured, you can call build().

        new VideoPicker.Builder(MainActivity.this)
                        .mode(VideoPicker.Mode.CAMERA_AND_GALLERY)
                        .directory(VideoPicker.Directory.DEFAULT)
                        .extension(VideoPicker.Extension.MP4)
                        .enableDebuggingMode(true)
                        .build();

Override onActivityResult

In order to receive the path of videos, you will need to override onActivityResult .

   @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
            List<String> mPaths =  data.getStringArrayListExtra(VideoPicker.EXTRA_VIDEO_PATH);
            //Your Code
        }
    }

Additional Options

  • mode to select the mode, you can choose one of these CAMERA,GALLERY or CAMERA_AND_GALLERY
.mode(VideoPicker.Mode.CAMERA)
  • extension You can change the extension of video to MP4
.extension(VideoPicker.Extension.MP4)
  • directory You can pass the storage path, or select Directory.DEFAULT_DIR to keep the default path.
.directory(VideoPicker.Directory.DEFAULT)

//OR

.directory(Environment.getExternalStorageDirectory()+"/myFolder")
  • enableDebuggingMode used to print Video Picker Log
	.enableDebuggingMode(true)

RxJava 2 for MediaPicker

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.

Gradle

dependencies {
  implementation 'io.reactivex.rxjava2:rxandroid:(Last_version)'
  implementation 'io.reactivex.rxjava2:rxjava:(Last_version)'
	implementation 'net.alhazmy13.MediaPicker:rxjava:(Last_version)'
}
  new ImagePickerHelper(
        new ImagePicker.Builder(Context)
                ...)
                .getObservable()
                .subscribe(....);

Theme the pickers

You can change the strings be overwriting below resources in your project.

    <string name="media_picker_select_from">Select From:</string>
    <string name="media_picker_camera">Camera</string>
    <string name="media_picker_gallery">Gallery</string>
    <string name="media_picker_ok">Ok</string>
    <string name="media_picker_cancel">Cancel</string>
    <string name="media_picker_some_permission_is_denied">Some Permission is Denied</string>
    <string name="media_picker_you_need_to_grant_access_to">You need to grant access to</string>
    <string name="media_picker_read_Write_external_storage"><![CDATA[Read & Write External Storage]]></string>

More Repositories

1

Synology-NAS-monitoring

influxDB, Grafana, snmp and telegraf
Shell
197
star
2

HijriDatePicker

Material (Gregorian - Hijri) Date & Time Picker
Java
142
star
3

ImageFilters

Image Filter is an Android Libary that lets you to Filtering any image
Makefile
91
star
4

Saudi-ID-Validator

Saudi-ID-Validator (Swift, Kotlin, Java, Go, JS, Python, TypeScript, PHP, Scala, ruby, c#, vb, SQL, C++, SQL and Dart)
Swift
81
star
5

MediaRecorderDialog

Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.
Java
72
star
6

Gota

Simplifying Android Permissions
Java
70
star
7

aws-serverless-skeleton

A Serverless skeleton project using Python
Python
41
star
8

AndroidWordCloud

Android Word Cloud
Java
39
star
9

Catcho

No Force close messages anymore!
Java
35
star
10

MediaGallery

Android image slideshow with circular scrolling and custom view.
Java
30
star
11

PrayerTimesSwift

Prayer Times provides a set of handy functions to calculate prayer times for any location around the world
Swift
29
star
12

PrayerTimes

Prayer Times provides a set of handy functions to calculate prayer times for any location around the world, based on a variety of calculation methods currently used in Muslim communities.
Java
24
star
13

pwa-angular4

A progressive webapp with Angular 4 (PLEASE NOTE: angular 5 support PWA )
TypeScript
13
star
14

CacheWithNetworkDemo-Android

Dagger+Retrofit+Realm+Gson+Clean Architecture+MVP
Java
12
star
15

Contact-Form-7-Submission-limit

Contact form 7 submission limit
PHP
11
star
16

Angular4-word-cloud

Word cloud directive for Angular4
JavaScript
10
star
17

IBAN-Validator

Iban Validator (Swift, Kotlin, Java)
Swift
10
star
18

Simple-SQLite-Project-with-Android

Java
4
star
19

microservices-example

Python
4
star
20

discourse-cognito-auth

Ruby
3
star
21

alhazmy13

3
star
22

ResistorsOpenCV

A python project using OpenCV to identify and calculate resistors' values from a webcam feed.
Python
3
star
23

RadioButtonSwift3

Custom radio button for swift 3
Swift
3
star
24

MacScripts

A list of shell commands and tools specific to OS X.
Shell
3
star
25

ActivityCleanArchitecture_Template

Template for Android Studio to create an empty activity with Clean Architecture approach
FreeMarker
3
star
26

arcdps-squad-notes-plugin

A Plugin for arcdps, that tracks squad members and add notes next to each member.
C++
2
star
27

CleanSwift_Template

Clean Swift Xcode Template
Makefile
2
star
28

ghost-casper-rtl

CSS
2
star
29

Spara

Save/Restore Activity's member
Java
2
star
30

plex-tvtime-webhook

Sync Plex with TvTime using Plex WebHook.
TypeScript
2
star
31

RestAPI-using-Slim-Framework

PHP
1
star
32

UglyKotlinProject

Kotlin
1
star
33

DemoWatchOS

Demo project for communication between a watchOS and iOS app using WCSession
Swift
1
star
34

javamail-android

Automatically exported from code.google.com/p/javamail-android
Java
1
star
35

streamdeck-sensibo

Control your Sensibo air conditioners from stream deck
JavaScript
1
star