Easy to use and configurable library Use the camera to select an image from the gallery or capture the image.

  • You can easily choose a picture from the camera and gallery and upload it wherever you want. We created this library to make it easier to select or capture images.
  • Covered camera and gallery permissions also support storage with scope.
  • Returns the contentUri of the selected image.
  • Easy to use and supports all common devices.
  • Take picture with camera
  • Select an image from the gallery
  • Handle runtime permission for memory and camera
  • ImagePicker Bottomsheet
  • Retrieve the image result in Uri format
  • Crop image
  • Rotate picture
  • Zoom in, zoom out
  • Adjust the BottomSheet options for image selection as follows:
    • Adjust only the text of the buttons
    • Just adjust the text color of the buttons
    • Customize multiple values ​​of buttons, such as:
      • Text color, size, font family, padding with your own styles.xml
    • Customize the background shape and color of the ground sheet
Take picture with cameraSelect an image from the galleryAdjust bottom sheet
Crop imageRotate pictureZoom in, zoom out
  1. Gradle dependency
  • Add the JitPack repository to your project’s build.gradle file
 allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
  • Add a plugin to your app’s build.gradle file
 plugins { ... id 'kotlin-kapt' } 
  • Add the buildFeature to your app’s build.gradle file
 android { ... buildFeatures { dataBinding = true } }
  • Paste the dependency into your app’s build.gradle file
 dependencies { implementation 'com.github.SimformSolutionsPvtLtd:SSImagePicker:1.5' }
  1. Use ImagePicker Bottomsheet to select the option to select images from gallery or camera
 val fragment = ImagePickerBottomsheet() fragment.show(FragmentManager, String) 
  1. Call ImagePickerActivityClass in your onCreate () to deal with camera, gallery click and authorization result. Pass Context, Activity, Request Permit, Result Callback, and ActivityResultRegistry:
 var imagePicker = ImagePickerActivityClass(context,activity,onResult_Callback,activityResultRegistry)
  1. To enable all functions (cropping, rotating, zooming, zooming), call cropOptions (isAllCropFeaturesRequired: Boolean) and pass true. By default it is set to “False” and only offers a crop function.
 override fun onCreate(savedInstanceState: Bundle?) { ... imagePicker.cropOptions(true) }
  1. Allow camera and storage permissions to select an image and send your onRequestPermissionsResult to ImagePickerActivity
 override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { imagePicker.onRequestPermissionsResult(requestCode, permissions, grantResults) }
  1. To take pictures from the camera use takePhotoFromCamera ()
 imagePicker.takePhotoFromCamera()
  1. To select an image from the gallery: Select PhotoFromGallary ()
 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 receive the image result in Uri format in returnString () and adapt it for uploading
 override fun returnString(item: Uri?) { **Here You Will Get Your Image Result In Uri Format** }
  1. You can load the image into your image view with loadImage () func. (If you want to use circleCrop (), pass isCircle = true. By default, it’s false.)
 override fun returnString(item: Uri?) { imageViewEditProfile.loadImage(item, isCircle = true) {} }
  • To customize the bottom sheet, first override the following method in your activity.
 override fun doCustomisations(fragment: ImagePickerBottomsheet) { //Do customizations here... }
  • How to customize the text of buttons in the bottom sheet
 fragment.setButtonText("Select Camera","Select Gallery","Remove")
  • Only change the text color of buttons on the bottom sheet.
 fragment.setButtonColors(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
  • To adjust several 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: the parent element 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 both setTextAppearance and setButtonColors are used, the last function called overrides the other.

  • How to change the background of the bottom sheet (shape, color).
 fragment.setBottomSheetBackgroundStyle(R.drawable.drawable_bottom_sheet_dialog)

You need to create a drawable Shape file.

 <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>

Do you find this library useful? ❤️

Support it by joining Stargazers for this repository.

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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here