SSImagePicker


Source link: https://github.com/SimformSolutionsPvtLtd/SSImagePicker

Is a Library for pick an image from gallery

SSImagePicker

Android-Studio API Language

Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera.

  • You can easily select image from camera and gallery and upload it wherever you want. We have created this library to simplify pick or capture image feature.
  • Handled permissions for camera and gallery, also supports scoped storage.
  • Returns contentUri of selected image.
  • Easy to use and supports all major devices.

Features :

  • Capture Image Using Camera
  • Pick Image From Gallery
  • Handle Runtime Permission For Storage And Camera
  • ImagePicker Bottomsheet
  • Retrieve Image Result In Uri Format
  • Crop Image
  • Rotate Image
  • Image Zoom In, Zoom Out
  • Customize Image Picker BottomSheet Options Like :
    • Customize only text of buttons
    • Customize only text color of buttons
    • Customize multiple values of buttons like:
      • Text color, size, font family, padding using your own styles.xml
    • Customize bottomsheet s background shape and color

Preview

Capture Image Using Camera Pick Image From Gallery Customize Bottomsheet
Crop Image Rotate Image Image Zoom in, Zoom out

How it works:

  1. Gradle Dependency
  • Add the JitPack repository to your project s build.gradle file
 allprojects {

repositories {

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

}

  
}
  • Add plugin in your app s build.gradle file
 plugins {

...

id  kotlin-kapt 
  
}
 
  • Add buildFeature in your app s build.gradle file
 android {

...

buildFeatures {

 dataBinding = true

}

  
}
  • Add the dependency in your app s build.gradle file
 dependencies {

implementation  com.github.SimformSolutionsPvtLtd:SSImagePicker:1.6 
  
}
  1. Implement ImagePickerBottomsheet.ItemClickListener, ImagePickerActivityClass.OnResult interface in your activity or fragment

  2. Use ImagePicker Bottomsheet To Choose Option For Pick Image From Gallery Or Camera

 val fragment = ImagePickerBottomsheet()
  fragment.show(FragmentManager, String) 
  1. Call ImagePickerActivityClass in your onCreate() To Handle Camera, Gallery Click And Permission Result. Pass Context, Request Permission Result Callback And activityResultRegistry, Activity or Fragment. :
 //From activity
  var imagePicker = ImagePickerActivityClass(context,onResult_Callback,activityResultRegistry,activity = this)

//From fragment
  var imagePicker = ImagePickerActivityClass(context,onResult_Callback,activityResultRegistry,fragment = this)
  1. To Enable All Features(crop,rotate,zoomIn,zoomOut) call cropOptions(isAllCropFeaturesRequired: Boolean) And Pass true. By Default It s Set To False And Provides Only Crop Feature.
 override fun onCreate(savedInstanceState: Bundle?) {

...

imagePicker.cropOptions(true)
  
}
  1. Allow Camera And Storage Permission To Pick Image And Send Your onRequestPermissionsResult To ImagePickerActivity
 override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {

super.onRequestPermissionsResult(requestCode, permissions, grantResults) (required)
  
}
  1. To Capture Image From Camera Use takePhotoFromCamera()
 imagePicker.takePhotoFromCamera()
  1. To Pick Image From Gallery Use choosePhotoFromGallary()
 imagePicker.choosePhotoFromGallary()
  1. Send Your onActivityResult to ImagePickerActivity
 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

super.onActivityResult(requestCode, resultCode, data)  (required)

imagePicker.onActivityResult(requestCode, resultCode, data)
  
}
  1. You Will Get Image Result In Uri Format In returnString() And Customize It To Upload
 override fun returnString(item: Uri?) {

**Here You Will Get Your Image Result In Uri Format**
  
}
  1. You can load image in your imageview using loadImage() func. (If you want to apply circleCrop() then pass isCircle = true, by default it s false)
 override fun returnString(item: Uri?) {

imageViewEditProfile.loadImage(item, isCircle = true) {

}

  
}

To customize bottomsheet:

  • To customize bottomsheet, first override below method in your activity.
 override fun doCustomisations(fragment: ImagePickerBottomsheet) {

//Do customizations here...
  
}
  • To customize text of buttons in Bottomsheet.
 fragment.setButtonText("Select Camera","Select Gallery","Remove")
  • To only change text color of buttons in Bottomsheet.
 fragment.setButtonColors(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
  • To customize multiple values of buttons (Text color, size, font family, padding), you need to create a style in your style.xml.
 fragment.setTextAppearance(R.style.fontForNotificationLandingPage)

In styles.xml (Note: parent must be "Widget.AppCompat.TextView")

 <style name="fontForNotificationLandingPage" parent="Widget.AppCompat.TextView">

<item name="android:fontFamily">@font/poppins_medium</item>

<item name="android:textColor">@color/white</item>

<item name="android:textSize">@dimen/_18ssp</item>
  </style>

Note: if setTextAppearance and setButtonColors both are used than whichever function is last called will override other one.

  • To change bottomsheet s background (shape, color).
 fragment.setBottomSheetBackgroundStyle(R.drawable.drawable_bottom_sheet_dialog)

You need to make one drawable file of type shape.

 <shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle">

<corners

 android:topLeftRadius="@dimen/_25sdp"

 android:topRightRadius="@dimen/_25sdp" />

<padding android:top="@dimen/_5sdp" />

<solid android:color="@color/colorPrimary" />
  </shape>

Other Library used:

Find this library useful? ❤️

Support it by joining stargazers for this repository.

How to Contribute

Whether you re helping us fix bugs, improve the docs, or a feature request, we d love to have you!

Check out our Contributing Guide for ideas on contributing.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

License

Copyright 2020 Simform Solutions
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

A shimmer effect in RecyclerView.

Telegram and whatsapp like download progress indicator.

Ultimate RecyclerView.

This framework is designed to solve the traditional MVP class and interface too much, and Presenter and View communicate too complicated through the interface, reuse Presenter too much cost.

Marvelous sliding square loader view inspired this.

The lib provides an easy way to store your settings in SharedPreferences.

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