QuickImagePick


Source link: https://github.com/aviadmini/quickimagepick

QuickImagePick

Easy to use and highly customizable image picker for Android with helpful extras to deal with outputs. Minimum API 9+, gets better with newer API versions

API 9+ (Gingerbread) functionality:

  • Pick image from gallery (using existing apps)
  • Use content manager apps (usually file managers) to pick image
  • Take picture with device camera (using existing apps)
  • Mix and match: allow user to choose from any combination of above
  • Save Uri content to a File
  • Set allowed MIME type of files that can be picked
  • Single call to get MIME type and file extension of picked image (from returned Uri)
  • Supports activities and fragments (both plain and support ones)

API 11+ (Honeycomb):

  • Allow only local content to be picked

API 18+ (Jelly Bean MR2):

  • Allow picking multiple images via documents pick source (where supported)

API 19+ (KitKat):

  • Additionally use Documents app (API 19+) to pick image from gallery, cloud storage etc.
  • Allow multiple MIME types of files that can be picked

Why this library?

  • Simple yet powerful API with chained calls
  • Activity, Fragment and support Fragment targets for returning picked result
  • More functionality (numerous useful operations with Uri, multiple pick options, etc)
  • It works with content data type rather than filesystem (solving FileUriExposedException issue on API 24+ target)

Dependency

repositories {

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

dependencies {

  compile ('com.github.aviadmini:quickimagepick:${
qip.release.version
}
'){

// Uncomment next line if you have dependency conflict with AppCompat v7

// exclude group: 'com.android.support', module: 'appcompat-v7' 
  
}
 
}

Latest release: (Use without 'v')

Usage

For detailed explanation refer to Documentation and sample app

Fire pick request

@PickTriggerResult final int triggerResult; triggerResult = QiPick.in(Activity or Fragment)

  .fromMultipleSources("All sources", PickSource.CAMERA, PickSource.DOCUMENTS);

Here triggerResult defines whether pick request was fired successfully. If not, it can be treated as error code.

Consume result

In onActivityResult of Activity or Fragment:

private final PickCallback mCallback = new PickCallback() {

@Override
  public void onImagePicked(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final Uri pImageUri) {

// Do something with Uri, for example load image into an ImageView

Glide.with(getApplicationContext())

  .load(pImageUri)

  .fitCenter()

  .into(mImageView);

  
}

@Override
  public void onMultipleImagesPicked(final int pRequestType, @NonNull final List<Uri> pImageUris) {

// meh whatever, just show first picked ;D

this.onImagePicked(PickSource.DOCUMENTS, pRequestType, pImageUris.get(0));

  
}

@Override
  public void onError(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final String pErrorString) {

Log.e(TAG, "Err: " + pErrorString);

  
}

@Override
  public void onCancel(@NonNull final PickSource pPickSource, final int pRequestType) {

Log.d(TAG, "Cancel: " + pPickSource.name());

  
}
  
}
;  @Override protected void onActivityResult(final int pRequestCode, final int pResultCode, final Intent pData) {
 super.onActivityResult(pRequestCode, pResultCode, pData);

  super.onActivityResult(pRequestCode, pResultCode, pData);

 QiPick.handleActivityResult(getApplicationContext(), pRequestCode, pResultCode, pData, this.mCallback);

  
}

Dessert

There's a bunch of useful methods to work with Uri in UriUtils

Vector

There's a few extension ideas that might make the library even more useful.

  • v3.0 create PickResult that will encapsulate both PickRequest details and pick results
  • ability to explicitly add specific file picker components as pick sources
  • tell me more ;)

If your app uses this library send me market links ;)

License

Copyright 2017 Bohdan Semeniuk  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. 

Resources

Imitation of Ali credit sesame "ring view".

GSON analog for serialization/deserialization of Java objects into HTML code and back.

Change color of words (or substrings) into a TextView.

FingerLock is a library designed to make fingerprint authentication an easy task for Android developers.

AllowMe simple library to handle Android M permissions easily.

A material design music player for Android using google's ExoPlayer library, based off Pasta for Spotify.

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