PickImage


Source link: https://github.com/jrvansuita/PickImage

PickImage

This is an Android project. It shows a DialogFragment with Camera or Gallery options. The user can choose from which provider wants to pick an image.




Dialog screenshots

Default icons.

Colored icons.

Custom dialog.

System dialog.

Setup

Step #1. Add the JitPack repository to your build file:

allprojects {

  repositories {
  ...  maven {
 url "https://jitpack.io" 
}

  
}
 
}

Step #2. Add the dependency ( See latest release).

dependencies {

  compile 'com.github.jrvansuita:PickImage:+' 
}

Implementation

Step #1. Overriding the library file provider authority to avoid installation conflicts.

The use of this library can cause INSTALL_FAILED_CONFLICTING_PROVIDER if you skip this step. Update your AndroidManifest.xml with this exact provider declaration below.

<manifest ...>
  <application ...>

<provider

 android:name="android.support.v4.content.FileProvider"

 android:authorities="${
applicationId
}
.com.vansuita.pickimage.provider"

 android:exported="false"

 android:grantUriPermissions="true"

 tools:replace="android:authorities">

 <meta-data

  android:name="android.support.FILE_PROVIDER_PATHS"

  android:resource="@xml/picker_provider_paths" />

</provider>
  </application>  </manifest> 

Step #2 - Showing the dialog.

PickImageDialog.build(new PickSetup()).show(this);

Step #3 - Applying the listeners.

Method #3.1 - Make your AppCompatActivity implements IPickResult.
@Override public void onPickResult(PickResult r) {

  if (r.getError() == null) {

//If you want the Uri.

//Mandatory to refresh image from Uri.

//getImageView().setImageURI(null);


 //Setting the real returned image.

//getImageView().setImageURI(r.getUri());


 //If you want the Bitmap.

getImageView().setImageBitmap(r.getBitmap());

 //Image path

//r.getPath();

  
}
 else {

//Handle possible errors

//TODO: do what you have to do with r.getError();


Toast.makeText(this, r.getError().getMessage(), Toast.LENGTH_LONG).show();

  
}
 
}
Method #3.2 - Set the listener using the public method (Good for Fragments).
PickImageDialog.build(new PickSetup())

 .setOnPickResult(new IPickResult() {

 @Override

 public void onPickResult(PickResult r) {

 //TODO: do what you have to...

 
}

 
}
).show(getSupportFragmentManager());

Step #4 - Customize you Dialog using PickSetup.

PickSetup setup = new PickSetup()

 .setTitle(yourText)

 .setTitleColor(yourColor)

 .setBackgroundColor(yourColor)

 .setProgressText(yourText)

 .setProgressTextColor(yourColor)

 .setCancelText(yourText)

 .setCancelTextColor(yourColor)

 .setButtonTextColor(yourColor)

 .setDimAmount(yourFloat)

 .setFlip(true)

 .setMaxSize(500)

 .setPickTypes(EPickType.GALLERY, EPickType.CAMERA)

 .setCameraButtonText(yourText)

 .setGalleryButtonText(yourText)

 .setIconGravity(Gravity.LEFT)

 .setButtonOrientation(LinearLayoutCompat.VERTICAL)

 .setSystemDialog(false)

 .setGalleryIcon(yourIcon)

 .setCameraIcon(yourIcon);
 /*... and more to come. */

Additionals

Own click implementations.

If you want to write your own button click event, just use IPickClick listener like in the example below. You may want to take a look at the sample app.

PickImageDialog.build(setup)

.setOnClick(new IPickClick() {

 @Override

 public void onGalleryClick() {

  Toast.makeText(SampleActivity.this, "Gallery Click!", Toast.LENGTH_LONG).show();

 
}

  @Override

 public void onCameraClick() {

  Toast.makeText(SampleActivity.this, "Camera Click!", Toast.LENGTH_LONG).show();

 
}

 
}
).show(this);

For dismissing the dialog.

PickImageDialog dialog = PickImageDialog.build(...);
 dialog.dismiss();

Force a specific width and height.

new PickSetup().setWidth(600).setHeight(800);

Sample app code.

You can take a look at the sample app located on this project.

Resources

A lightweight Android library for customizable alerts.

RxJava2 based caching mechanism. Simple to use yet very powerful.

Key features:

  • Customizable
  • Fast
  • Reliable

An easy to use wrapper of the native Android Snackbar which stays visible across multiple activities. It provides different themes to start with, and allows you to easily manage common scenarios like success, warning, error, info.

An easy file / folder picker dialog fragment which is easily to implement. Nothing special is required, you just need to add few lines of code!

This library add the ability to listen for drawable click events for TextView, EditText and AutoCompleteTextView normally added in XML with android:drawableStart etc... or in code with setCompoundDrawables(...) and similar.

With this library you can flat a layout used to side any widget with an ImageView or ImageButton added to listen for click on the icon, to one unique custom view.

SwipeableRV is a library that provides a fast and convenient way to implement the 'swipe to dismiss' feature in Recycler View, as seen in apps such as Messenger.

SwipeableRV wraps around ItemTouchHelper from the Android Support Library. Therefore, developers do not need to do any extra work on ItemTouchHelper.Callback themselves. Instead they can just focus on creating a recycler view, adapter, and view holder as normal, plus some minimal work on specifying some details such as supported swipe directions, deletion message or icon.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes