• Stars
    star
    406
  • Rank 106,421 (Top 3 %)
  • Language
    Java
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

Android library project for providing multiple image selection from the device.

PolyPicker

Android library project for selecting/capturing multiple images from the device.

Result

Caution!

Eclipse library project structure has been dropped. If you wish to use this library in your eclipse IDE, please checkout eclipse-develop. No further development will be done or merged into eclipse-develop branch.

Why?

  • Most of the apps we develop require fetching images from camera or gallery.
  • Android does not provide multi-selection of images out of the box until API 18.
  • Dealing with camera on variety of hardware and fragmentation in underlying software is difficult.
  • There are no libraries that help me multi-choose images from both camera and gallery with beautiful UX.

Features

  • Allows taking pictures from camera as well.
  • Multi-selection of images from gallery.
  • Ability to select/capture images upto a specified limit.
  • Preview thumbnails of selected images.

Download

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // and
    // your
    // other
    // dependencies...
}

// add external respository url in addition to having
// your preferred repository.
repositories {
    // for downloading polypicker dependency cwac-camera
    maven {
        url "https://repo.commonsware.com.s3.amazonaws.com"
    }

    // for downloading poly-picker now we are using jitpack.
    // Goodbye Maven Central
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // your dependencies
    compile 'com.github.jaydeepw:poly-picker:1.0.23'
}

Requires Android 4.0+.

Getting started

Add camera permissions and required features to your AndroidManifest.xml

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Request large heap memory using "largeHeap" attribute for your application. This will avoid application to crash on low memory devices. The side effect would be that your application may force other applications to be kicked out of memory. Nothing very severe.

<application
		android:icon="@drawable/ic_launcher"
		android:label="@string/app_name"
		android:largeHeap="true">
		.
		.
</application>

Declare the PolyPicker activity in your AndroidManifest.xml with some theme that is a descendent of AppCompat.

<activity
            android:name="nl.changer.polypicker.ImagePickerActivity" />

Start the PolyPicker activity and get the result back.

private void getImages() {
	    Intent intent = new Intent(mContext, ImagePickerActivity.class);
        Config config = new Config.Builder()
                .setTabBackgroundColor(R.color.white)    // set tab background color. Default white.
                .setTabSelectionIndicatorColor(R.color.blue)
                .setCameraButtonColor(R.color.green)
                .setSelectionLimit(2)    // set photo selection limit. Default unlimited selection.
                .build();
        ImagePickerActivity.setConfig(config);
        startActivityForResult(intent, INTENT_REQUEST_GET_IMAGES);
}

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

	if (resultCode == Activity.RESULT_OK) {
		if (requestCode == INTENT_REQUEST_GET_IMAGES) {
			Parcelable[] parcelableUris = intent.getParcelableArrayExtra(ImagePickerActivity.EXTRA_IMAGE_URIS);

            if (parcelableUris == null) {
                return;
            }

            // Java doesn't allow array casting, this is a little hack
            Uri[] uris = new Uri[parcelableUris.length];
            System.arraycopy(parcelableUris, 0, uris, 0, parcelableUris.length);

            if (uris != null) {
                for (Uri uri : uris) {
                    Log.i(TAG, " uri: " + uri);
                    mMedia.add(uri);
                }

                showMedia();
            }
		}
	}
}

Testing Snapshot build

Snapshot builds are development builds that need refining and bug fixes. Open source community can greatly help in achieveing this by testing such builds and logging issues and feedback that can make PolyPicker better, together. Add snapshot dependency to your app module's build.gradle file

repositories {
    // for downloading Polypicker dependency cwac-camera
    maven {
        url "https://repo.commonsware.com.s3.amazonaws.com"
    }

    // for downloading polypicker v1.0.13-SNAPSHOT
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.+'
    // and other dependencies

    // PolyPicker dependency.
    compile 'net.the4thdimension:poly-picker:1.0.13-SNAPSHOT'
}

Add camera permissions and required features to your AndroidManifest.xml

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Request large heap memory using "largeHeap" attribute for your application. This will avoid application to crash on low memory devices. The side effect would be that your application may force other applications to be kicked out of memory. Nothing very severe.

<application
		android:icon="@drawable/ic_launcher"
		android:label="@string/app_name"
		android:largeHeap="true">
		.
		.
</application>

Declare the PolyPicker activity in your AndroidManifest.xml

<activity
            android:name="nl.changer.polypicker.ImagePickerActivity" />

Start PolyPicker activity to request images.

// start polypicker activity to grab some images.
Intent intent = new Intent(mContext, ImagePickerActivity.class);
        Config config = new Config.Builder()
                .setTabBackgroundColor(R.color.white)    // set tab background color. Default white.
                .setTabSelectionIndicatorColor(R.color.blue)
                .setCameraButtonColor(R.color.green)
                .setSelectionLimit(2)    // set photo selection limit. Default unlimited selection.
                .build();
        ImagePickerActivity.setConfig(config);
        startActivityForResult(intent, INTENT_REQUEST_GET_IMAGES);


// parse images returned by polypicker
@Override
protected void onActivityResult(int requestCode, int resuleCode, Intent intent) {
	super.onActivityResult(requestCode, resuleCode, intent);

	if (resuleCode == Activity.RESULT_OK) {
		if (requestCode == INTENT_REQUEST_GET_IMAGES) {
			Parcelable[] parcelableUris = intent.getParcelableArrayExtra(ImagePickerActivity.EXTRA_IMAGE_URIS);

            if (parcelableUris == null) {
                return;
            }

            // Java doesn't allow array casting, this is a little hack
            Uri[] uris = new Uri[parcelableUris.length];
            System.arraycopy(parcelableUris, 0, uris, 0, parcelableUris.length);

            if (uris != null) {
                for (Uri uri : uris) {
                    Log.i(TAG, " uri: " + uri);
                    mMedia.add(uri);
                }

                showMedia();
            }
		}
	}
}

Contributing

Please fork this repository and contribute back using pull requests.

Please follow Android code style guide

You can contribute to polypicker in following ways

  • Test on multiple devices you have
  • Write unit tests
  • Write UI tests
  • Help with string translations
  • Fix open issues in the library

Developed by

Credits

  • This project is inspired by and modified from an existing project mentioned below. android-multiple-image-picker

  • Dealing with camera on variety of hardware and fragmentation in underlying software is difficult. CommonsGuy's library Cwac Camera helped handle it better in this project

Donations!

  • Using Bitcoins: If this project has helped you understand issues, be productive by using this library in your app or just being nice with me, you can always donate me Bitcoins at this address 3QJEmgqXsT1CFLtURYWxzmww59DdKYVwNk

  • Using Paypal: Pay Jay

Alternative projects

Release Notes

1.0.23

v1.0.22

  • Add Danish translations

v1.0.17

  • Add Japanese and Portuguese(Brazil) translations

v1.0.14

  • Add autofocus feature when taking picture using camera.
  • Material theme for camera fragment
  • Configurable UI controls to match the theme of the host application using the library.

v1.0.11

  • Fix leaking progress dialog window when the device orientation changes

v1.0.10

  • Persist captured images even on device orientation changes

v1.0.9

  • Replace camera view with CommonsGuy camera view which is tested well and handles camera functionality better on variety of hardware.

More Repositories

1

audio-wife

A simple themable & integrable audio player library for Android.
Java
238
star
2

android-utils

Library for utility classes that can make me and others more productive.
Java
216
star
3

simplest-sync-adapter

The bare minimum code that one will have to write to build a working sync adapter for an android app.
Java
10
star
4

jquerymobile-dynamic-listview

Creating a listview dynamically using javascript.
7
star
5

questionnaire

Android library to create & navigate within different types of questions which can be used in an android application. It can be used for "Take-Test" kind of feature, if any, in your application.
Java
6
star
6

google-docs-as-database

Using google docs as a read-only database for HTML5 based applications.
5
star
7

jaydeepw.github.com

My site
JavaScript
3
star
8

adb-restarter

Restart ADB as root from command line
Python
3
star
9

avantika-university

Sample code and demo implemented during session at Avantika Universtiy.
Java
3
star
10

coordinate-drawings

Kotlin
2
star
11

cardslib-eclipse

Eclipse port of cardslib for Android
Java
2
star
12

tech-talks

Presentations and demos of the tech talks that I delivered at various places.
JavaScript
1
star
13

photoview-eclipse

Eclipse port of PhotoView image zooming library for Android
Java
1
star
14

google-maps-selector

Java
1
star
15

flutterbook

A facebook skeleton application using Flutter.
Dart
1
star
16

socket-io-demo

A minimalist and simple project to learn and try out socket.io
JavaScript
1
star
17

ffmpeg-android

Working demo of FFMpeg on Android using JNI.
C
1
star
18

content-provider

Java
1
star
19

experiments

Some experiments that I am usually engaged in. This will NOT be useful to anybody.
Java
1
star
20

android-mvvm-gjk

A simple application using MVVM arch. pattern for Android
1
star
21

backend-snetworks

A simple web service using NodeJS that exposes a GET API
JavaScript
1
star
22

express-learning

A repo created when I started learning ExpressJS.
JavaScript
1
star
23

android-mvvm-slk

A demo search application in Kotlin and MVVM architecture
Kotlin
1
star
24

boiler-plates

contains boiler plate code for HTML, Media Queries, Simple Android App, JQueryMobile and many to be added with time.
1
star
25

timesheet-maker

Python script/app that reformats office check in and check out times in WhatsApp to excel sheet friendly format
Python
1
star
26

flutter-experiements

Dart
1
star
27

android-crop

Java
1
star
28

google-analytics-notifier

Receive audio, visual notifications from Google Analytics whenever user count goes beyond certain threshold on your site/blog.
JavaScript
1
star
29

sync-adapters

learning sync adapters in android
1
star
30

android-test

Java
1
star
31

video-frames

Java
1
star
32

bb10-opensource

My Open Source code for BB10 that I think can be reused by somebody sometime. :)
C++
1
star
33

offlinr

JavaScript
1
star
34

android-multiple-image-picker-eclipse

Eclipse port of https://github.com/giljulio/android-multiple-image-picker
Java
1
star
35

1942-tanks

A simple HTML5 game build by me in 2011 to learn programming in JavaScript. It uses HTML5 Canvas. Its not very advanced. Just putting out here so anyone can clone and extend it.
JavaScript
1
star
36

temploid

A template app for Android. An Android template application to quickly get started with a new Android application project.
Java
1
star