Skip to content

kristiyanP/TedBottomPicker

 
 

Repository files navigation

TedBottomPicker Download

In Google's Material Design, Google introduce Bottom sheets.(Components – Bottom sheets)
Bottom sheets slide up from the bottom of the screen to reveal more content.

If you want pick image from gallery or take picture, this library can help easily.
TedBottomPicker provide 3 options:

  1. Take a picture by camera(using MediaStore.ACTION_IMAGE_CAPTURE intent)
  2. Get image from gallery(using Intent.ACTION_PICK intent)
  3. Get image from recent image(using MediaStore.Images.Media.EXTERNAL_CONTENT_URI cursor)

TedBottomPicker is simple image picker using bottom sheet.



Demo

Screenshot
Screenshot

  1. Show Bottom Sheet.
  2. Pick Image

Single/Multi Select

Screenshot
Screenshot
Screenshot



Setup

Gradle

dependencies {
    compile 'petrov.kristiyan:tedbottompicker:1.4'
}

If you think this library is useful, please press star button at upside.


How to use

1. Check Permission

You have to grant WRITE_EXTERNAL_STORAGE permission from user.
If your targetSDK version is 23+, you have to check permission and request permission to user.
Because after Marshmallow(6.0), you have to not only decalare permisions in AndroidManifest.xml but also request permissions at runtime.
There are so many permission check library in Android-Arsenal

2. Start TedBottomPicker

TedBottomPicker class extend BottomSheetDialogFragment.
TedBottomPicker.Builder make new TedBottomPicker().
After then, you can show TedBottomPicker

     TedBottomPicker tedBottomPicker = new TedBottomPicker.Builder(MainActivity.this)
                                .setOnImageSelectedListener(new TedBottomPicker.OnImageSelectedListener() {
                                    @Override
                                    public void onImageSelected(Uri uri) {
                                        // here is selected uri
                                    }
                                })
                                .create();

     tedBottomPicker.show(getSupportFragmentManager());

If you want select multi image, you can use OnMultiImageSelectedListener

 TedBottomPicker bottomSheetDialogFragment = new TedBottomPicker.Builder(MainActivity.this)
                               .setOnMultiImageSelectedListener(new TedBottomPicker.OnMultiImageSelectedListener() {
                                   @Override
                                   public void onImagesSelected(ArrayList<Uri> uriList) {
                                       // here is selected uri list
                                   }
                               })
                                .setPeekHeight(1600)
                                .showTitle(false)
                                .setCompleteButtonText("Done")
                                .setEmptySelectionText("No Select")
                                .create();

                        bottomSheetDialogFragment.show(getSupportFragmentManager());

Don't forget!!
You have to declare setOnImageSelectedListener() or OnMultiImageSelectedListener() in Builder.
This listener will pass selected Uri/UriList.


##Customization

Function

Common

  • setPreviewMaxCount(Int) (default: 25)
  • setPeekHeight(Int)
  • setPeekHeightResId(R.dimen.xxx)
  • showCameraTile(Boolean) (default: true)
  • setCameraTile(R.drawable.xxx or Drawable)
  • setCameraTileBackgroundResId(R.color.xxx)
  • setGalleryTile(R.drawable.xxx or Drawable)
  • showGalleryTile(Boolean) (default: true)
  • setGalleryTileBackgroundResId(R.color.xxx)
  • setSpacing(Int)
  • setSpacingResId(R.dimen.xxx)
  • setOnErrorListener(OnErrorListener)
  • setTitle(String or R.string.xxx) (default: 'Select Image','사진 선택')
  • showTitle(Boolean) (default: true)
  • setTitleBackgroundResId(R.color.xxx)
  • setImageProvider(ImageProvider) : If you want load grid image yourself, you can use your ImageProvider

Single Select

  • setSelectedUri(Uri)

Multi Select

  • setDeSelectIcon(R.drawable.xxx or Drawable)
  • setSelectedForeground(R.drawable.xxx or Drawable)
  • setSelectMaxCount(Int)
  • setSelectMinCount(Int)
  • setCompleteButtonText(String or R.string.xxx) (default: 'Done','완료')
  • setEmptySelectionText(String or R.string.xxx) (default: 'No Image','이미지가 선택되지 않았습니다')
  • setSelectMaxCountErrorText(String or R.string.xxx)
  • setSelectMinCountErrorText(String or R.string.xxx)
  • setSelectedUriList(ArrayList<Uri>)



Thanks

About

TedBottomPicker is simple image picker using bottom sheet

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%