Skip to content

hitesh24by365/image-chooser-library

 
 

Repository files navigation

Version 1.2.2

  1. Bug fix: For some files, when you get FileNotFoundException, fixed a null pointer exception.
  2. Feature: Send back the filepath, to the caller while using camera for video/image. This should be used when you want to support orientation changes.

Version 1.2.1

  1. Bug Fix for versions <3.0 Pull Request:Juan Andrés

Version 1.2

  1. Added choosing video from gallery (supports both locally stored videos and your picasa videos).
  2. Added taking a video using camera.
  3. Gives back the actual video path, and two thumbnails.

Sample App using the library v1.2

Link to Sample app with v1.2

Link to image-chooser-library v1.2

Version 1.1

  1. Added optional output folder configuration.
  2. Added folder cache limit and auto delete old files.
  3. Added an optional flag to control thumbnail generation.

Link to image-chooser-library v1.1

Version 1.0

  1. Supports adding images by using the device's camera.
  2. Supports adding pictures from the Camera folder of your gallery.
  3. Supports adding pictures from your synced Picasa folders on your phone.
  4. Supports 3 types of image output sizes (Original, Thumbnail and Thumbnail smaller).

Pre-Requisites:

  1. Your app should have internet permission.
  2. WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions are required.

Integration with your apps (2 options)

  1. Clone this repository and add this as a dependency to your Android project. This is a library project.
  2. Download the jar file, and add it to your Android project's build path

Usage:

For choosing an image from gallery

imageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE);
imageChooserManager.setImageChooserListener(this);
imageChooserManager.choose();

For capturing a picture using your camera

imageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_CAPTURE_PICTURE);
imageChooserManager.setImageChooserListener(this);
imageChooserManager.choose();

On Activity result, do this:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if (resultCode == RESULT_OK && 
		(requestCode == ChooserType.REQUEST_PICK_PICTURE ||
				requestCode == ChooserType.REQUEST_CAPTURE_PICTURE)) {
		imageChooserManager.submit(requestCode, data);
	}
}

Implement the ImageChooserListener interface

Override these methods:

@Override
public void onImageChosen(final ChosenImage image) {
	runOnUiThread(new Runnable() {

		@Override
		public void run() {
			if (image != null) {
				// Use the image
				// image.getFilePathOriginal();
				// image.getFileThumbnail();
				// image.getFileThumbnailSmall();
			}
		}
	});
}
@Override
public void onError(final String reason) {
	runOnUiThread(new Runnable() {

		@Override
		public void run() {
			// Show error message
		}
	});
}

For capturing a video using your camera

videoChooserManager = new VideoChooserManager(this, ChooserType.REQUEST_CAPTURE_VIDEO);
videoChooserManager.setVideoChooserListener(this);
videoChooserManager.choose();

For selecting a video from your gallery

videoChooserManager = new VideoChooserManager(this, ChooserType.REQUEST_PICK_VIDEO);
videoChooserManager.setVideoChooserListener(this);
videoChooserManager.choose();

On Activity result, do this:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if (resultCode == RESULT_OK && 
		(requestCode == ChooserType.REQUEST_PICK_VIDEO ||
				requestCode == ChooserType.REQUEST_CAPTURE_VIDEO)) {
		videoChooserManager.submit(requestCode, data);
	}
}

Implement the VideoChooserListener interface

Override these methods:

@Override
public void onVideoChosen(final ChosenVideo video) {
	runOnUiThread(new Runnable() {

		@Override
		public void run() {
			if (video != null) {
				// Use the video
				// video.getFilePathOriginal();
				// video.getFileThumbnail();
				// video.getFileThumbnailSmall();
			}
		}
	});
}
@Override
public void onError(final String reason) {
	runOnUiThread(new Runnable() {

		@Override
		public void run() {
			// Show error message
		}
	});
}

License


Copyright 2013 Kumar Bibek

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An Easy Image/Video Chooser Library for your Android Apps

Resources

Stars

Watchers

Forks

Packages

No packages published