Android Gallery Image Picker : Custom responsive single or multi image picker

Android Code Lab
AndroidCodeLab
Published in
6 min readJun 22, 2020

Gallery have UI Components with Single and Multi files Selection Mode for android Developers to give there app a A Rich look With with custom picker functionality to cover up maximum media type like Audio, Files (Docs, Text etc) and Images.

What’s New? (0.0.1)

  • Stable Official Version for Developers and Live Apps.
  • Easy Calling Mechanism with Instant reply via onActivityResult.
  • Need less calls with many customs Tags in Intent Object to reach maximum developer satisfaction.
  • Compatible With Camera Library for More Efficent Working;

Why this library?

  • This library Competible with all screen sizes and device (Tab with 7' inches and 10'inches).
  • Library support both orientation that is portrait and landscape.
  • Its Calling feature is very simple and easy to use.
  • You don’t need to add Multiple libraries and UI components, it have such Components inside that make Quality.
  • Library is Customizable for Enable Features like Only Audio, Only Files, and Only Images view.

Quality Measures? for (0.0.1)

The following apps are using this library without facing any kind of Bugs.

Jamun-Gallery Preview Activity View Bottom Sheet View

Working Preview

Gradle Configuration

Add the dependency

Step 1. Add the jCenter repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
repositories {
mavenCentral()
}
}

Step 2. Add the dependency

dependencies {
compile 'tk.jamun.ui:gallery:0.0.1'
}

Maven Config

<dependency>
<groupId>tk.jamun.ui</groupId>
<artifactId>gallery</artifactId>
<version>0.0.1</version>
<type>aar</type>
</dependency>

How to Implement

Once the project has been added to gradle, You can use these lines of code to configure pickers….

Activity View

Step 1. Define Intent Object

Simple Object declaration :

**Single**
Intent intent = new Intent(this, ActivityGallery.class)
.putExtra(GALLERY_INTENT_COME_FOR, GALLERY_TYPE_IMAGE)// Means Gallery type either IMAGE, AUDIO, FILES and all
.putExtra(GALLERY_INTENT_MODE, GALLERY_MODE_SINGLE);// Means Gallery Mode GALLERY_MODE_SINGLE or MODE_MULIT
**Multi**
//or For All-In-One
Intent intent =new Intent(this, ActivityGallery.class)
.putExtra(GALLERY_INTENT_COME_FOR, GALLERY_TYPE_ALL)
.putExtra(GALLERY_INTENT_MODE, GALLERY_MODE_MULTI);// Means Gallery Mode GALLERY_MODE_SINGLE or MODE_MULIT

Step 2. Start Module By Calling

This method is very common to Android Developer, Very easy calling way to Start an activity help you same for calling this Picker :

startActivityForResult(intent, ACTION_REQUEST_GALLERY);

Step 3. Get Result from Picker

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case ACTION_REQUEST_GALLERY:
if (data.getIntExtra(GALLERY_INTENT_MODE, GALLERY_MODE_SINGLE) == GALLERY_MODE_SINGLE) {
ModelChild modelChild = data.getParcelableExtra(GALLERY_INTENT_FOR_MODEL);
if (modelChild != null)
try {
file = new File(modelChild.getFilePath());
startActivityForResult(new Intent(ActivityCameraGallery.this, ActivityCamera.class)
.putExtra(InterfaceUtils.INTENT_COME_FROM, LIBRARY_COME_FROM_GALLERY)
.putExtra(RESULT_IMAGE_PATH, file.getAbsolutePath()),
ACTION_REQUEST_CAMERA);
} catch (Exception ignored) {
}
} else {
ArrayList<ModelChild> childArrayList = data.getParcelableArrayListExtra(GALLERY_INTENT_FOR_MODEL);
for (ModelChild modelChild : childArrayList) {
file = new File(modelChild.getFilePath());
}
}
break;
}
}
}

Bottom Sheet View

Step 1. Define Intent Object

Object Declaration and Binding Response Listener:

**Single**
new PickerMulti().setThings(this, getSupportFragmentManager(), GALLERY_TYPE_IMAGE,
GALLERY_MODE_SINGLE).onClickListener(new InterfaceGallery.InterfaceSingleModeItemClickListener() {
@Override
public void getResponse(ModelChild modelChild) {
}
}).setColumnCount(4).showPicker();

**Multi**
//or For All-In-One
new PickerMulti().setThings(this, getSupportFragmentManager(), GALLERY_TYPE_ALL,
GALLERY_MODE_MULTI).onSubmitClickListener(new InterfaceGallery.InterfaceMultiModeItemClickListener() {
@Override
public void getResponse(ArrayList<ModelChild> selectedArrayList) {
}
}).showPicker();

Gallery Customization

Intent Object provide you custom functionality to work Module according to your requirement :

Set Title of the Gallery

**Activity View**
intent.putExtra(INTENT_SCANNER_ACTIVITY_NAME, "Title of the Scanner Activity");
or **Bottom Sheet View**
new PickerMulti().setTitle();

Set Column Count of the Gallery

**Activity View**
intent.putExtra(GALLERY_INTENT_COLUMN_COUNT, COUNT);
or **Bottom Sheet View**
new PickerMulti().setColumnCount();

Dependency

  • Goole Vision v15.0.2
  • SDK Version 15 to 27

Credits

Desgin & Developed by : Jatin Sahgal
(Linkedin & Website & Blog & GitHub)

More Library under Jamun

  • Pickers
    Pickers Library provide you a set of Pickers like Country, Language, Share and Intent Chooser.
  • Share
    provide you Intent Chooser with great UI/UX. It automatically retrieve the sort list of all the apps which can share the file. This functionality saves much of your task. You can also share dialog Picker for sending Large files. For this you just need to call a single function with file as Argument.
  • Country-Pickers
    allow you to access Country picking functionality with great UI/UX design, and there are numerous of function which help you to modify picker as per your requirements. Library has been provided with four custom UI initiate mode you can decide how the view of picker can be initiate. You can also decide weather picker inherit Single or Multi Selection property. Library consists of updated collection of country name, code and there flags. We are using APIs base structure to avoid increase in the size of apk due to flag Images. This module Maintain the database so that you don’t need to call APIs again and again rather than you can choose when to refresh the Database and fetch new real time data.
  • Language-Pickers
    provides you read-made Language picker which is easy to use and comes with great UI/UX, and there are numerous of function which help you to modify picker as per your requirements. Library has been provided with four custom UI initiate mode you can decide how the view of picker can be initiate. You can also decide weather picker inherit Single or Multi Selection property.
  • Scanner
    is a collection of Beautiful Activity which help others to make there own Custom QR/Barcode Scanner.
  • Calendar
    is a collection of Beautiful Activities which help others to make there Fully Custom Calendar View with Single and Multi Date Picker Functionality
  • UI
    library is a set of UI Views, Custom Component and Collection of Helper Classes which help Developer for making quality Product. Such as Camera, Gallery, Number of Pickers, Calendar, Date Pickers, Dialogs and many more Helper UI and Backend Component.
  • Camera
    library provide you Custom Complete Camera view with full features like Flash, Rotation, Gallery Picker, Focus, Tap to capture, Confirmation window and last but not least cropping feature. It also provide you file path in return so that developer can feel a friendly handy way to Deal After.
  • Gallery
    have some Beautiful UI Components and Multi files Mode for android Developers to give there app a A Rich look With single and Multi picker Functionality.
  • CircularImageView
    Library provide you a custom set of Android Elements that have custom views and properties like CircularImageView Element which provide you both XML and Java Code functions for Circular view with vector compatibility.
  • CircularNetworkImageView
    Library provide you a custom set of Android Elements that have custom views and properties like CircularNetworkImageView Element which provide you both XML and Java Code functions for Circular Volley Network view with vector compatibility.
  • SinglePageBrowser
    Library provide you two type Single Pager In-APP Browser Functionality with Event Handling and Functions to Customize Views. It also provide you Copy to clipboard, Open in Browser and share link feature in-Built.
  • MultiPageBrowser
    Library provide you two type Multi Pager In-APP Browser Functionality with Event Handling and Functions to Customize Views. It also provide you Copy to clipboard, Open in Browser and share link feature in-Built.
  • Volley
    A set of Custom Classes with UI components for network programming, integration and transaction handling in a better and standard way. This will help developers for making quality use of volley library..

License

Copyright (c) 2018 Jatin SahgalLicensed 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.0Unless 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.

--

--

Android Code Lab
AndroidCodeLab

Android Code Lab is a world for Android Nerds which provide Android libraries, codelabs, tutorials, Custom code classes and many more to make you 0 to infinity.