public final class CropImage
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CropImage.ActivityBuilder
Builder used for creating Image Crop Activity by user request.
|
static class |
CropImage.ActivityResult
Result data of Crop Image Activity.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE
The request code used to request permission to capture image from camera.
|
static int |
CROP_IMAGE_ACTIVITY_REQUEST_CODE
The request code used to start
CropImageActivity to be used on result to identify the
this specific request. |
static int |
CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE
The result code used to return error from
CropImageActivity. |
static java.lang.String |
CROP_IMAGE_EXTRA_BUNDLE
The key used to pass crop image bundle data to
CropImageActivity. |
static java.lang.String |
CROP_IMAGE_EXTRA_OPTIONS
The key used to pass crop image options to
CropImageActivity. |
static java.lang.String |
CROP_IMAGE_EXTRA_RESULT
The key used to pass crop image result data back from
CropImageActivity. |
static java.lang.String |
CROP_IMAGE_EXTRA_SOURCE
The key used to pass crop image source URI to
CropImageActivity. |
static int |
PICK_IMAGE_CHOOSER_REQUEST_CODE
The request code used to start pick image activity to be used on result to identify the this
specific request.
|
static int |
PICK_IMAGE_PERMISSIONS_REQUEST_CODE
The request code used to request permission to pick image from external storage.
|
| Modifier and Type | Method and Description |
|---|---|
static CropImage.ActivityBuilder |
activity()
Create
CropImage.ActivityBuilder instance to open image picker for cropping and then start CropImageActivity to crop the selected image.Result will be received in Activity.onActivityResult(int, int, Intent) and can be
retrieved using getActivityResult(Intent). |
static CropImage.ActivityBuilder |
activity(android.net.Uri uri)
Create
CropImage.ActivityBuilder instance to start CropImageActivity to crop the given
image.Result will be received in Activity.onActivityResult(int, int, Intent) and can be
retrieved using getActivityResult(Intent). |
static CropImage.ActivityResult |
getActivityResult(android.content.Intent data)
Get
CropImageActivity result data object for crop image activity started using activity(Uri). |
static android.content.Intent |
getCameraIntent(android.content.Context context,
android.net.Uri outputFileUri)
Get the main Camera intent for capturing image using device camera app.
|
static java.util.List<android.content.Intent> |
getCameraIntents(android.content.Context context,
android.content.pm.PackageManager packageManager)
Get all Camera intents for capturing image using device camera apps.
|
static android.net.Uri |
getCaptureImageOutputUri(android.content.Context context)
Get URI to image received from capture by camera.
|
static java.util.List<android.content.Intent> |
getGalleryIntents(android.content.pm.PackageManager packageManager,
java.lang.String action,
boolean includeDocuments)
Get all Gallery intents for getting image from one of the apps of the device that handle
images.
|
static android.content.Intent |
getPickImageChooserIntent(android.content.Context context)
Create a chooser intent to select the source to get image from.
The source can be camera's (ACTION_IMAGE_CAPTURE) or gallery's (ACTION_GET_CONTENT). All possible sources are added to the intent chooser. Use "pick_image_intent_chooser_title" string resource to override chooser title. |
static android.content.Intent |
getPickImageChooserIntent(android.content.Context context,
java.lang.CharSequence title,
boolean includeDocuments,
boolean includeCamera)
Create a chooser intent to select the source to get image from.
The source can be camera's (ACTION_IMAGE_CAPTURE) or gallery's (ACTION_GET_CONTENT). All possible sources are added to the intent chooser. |
static android.net.Uri |
getPickImageResultUri(android.content.Context context,
android.content.Intent data)
Get the URI of the selected image from
getPickImageChooserIntent(Context).Will return the correct URI for camera and gallery image. |
static boolean |
hasPermissionInManifest(android.content.Context context,
java.lang.String permissionName)
Check if the app requests a specific permission in the manifest.
|
static boolean |
isExplicitCameraPermissionRequired(android.content.Context context)
Check if explicetly requesting camera permission is required.
It is required in Android Marshmellow and above if "CAMERA" permission is requested in the manifest. See StackOverflow question. |
static boolean |
isReadExternalStoragePermissionsRequired(android.content.Context context,
android.net.Uri uri)
Check if the given picked image URI requires READ_EXTERNAL_STORAGE permissions.
Only relevant for API version 23 and above and not required for all URI's depends on the implementation of the app that was used for picking the image. |
static boolean |
isUriRequiresPermissions(android.content.Context context,
android.net.Uri uri)
Test if we can open the given Android URI to test if permission required error is thrown.
Only relevant for API version 23 and above. |
static void |
startPickImageActivity(android.app.Activity activity)
Start an activity to get image for cropping using chooser intent that will have all the
available applications for the device like camera (MyCamera), galery (Photos), store apps
(Dropbox), etc.
Use "pick_image_intent_chooser_title" string resource to override pick chooser title. |
static void |
startPickImageActivity(android.content.Context context,
Fragment fragment)
Same as
startPickImageActivity method but instead of
being called and returning to an Activity, this method can be called and return to a Fragment. |
static android.graphics.Bitmap |
toOvalBitmap(android.graphics.Bitmap bitmap)
Create a new bitmap that has all pixels beyond the oval shape transparent.
|
public static final java.lang.String CROP_IMAGE_EXTRA_SOURCE
CropImageActivity.public static final java.lang.String CROP_IMAGE_EXTRA_OPTIONS
CropImageActivity.public static final java.lang.String CROP_IMAGE_EXTRA_BUNDLE
CropImageActivity.public static final java.lang.String CROP_IMAGE_EXTRA_RESULT
CropImageActivity.public static final int PICK_IMAGE_CHOOSER_REQUEST_CODE
public static final int PICK_IMAGE_PERMISSIONS_REQUEST_CODE
public static final int CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE
public static final int CROP_IMAGE_ACTIVITY_REQUEST_CODE
CropImageActivity to be used on result to identify the
this specific request.public static final int CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE
CropImageActivity.public static android.graphics.Bitmap toOvalBitmap(android.graphics.Bitmap bitmap)
public static void startPickImageActivity(android.app.Activity activity)
activity - the activity to be used to start activity frompublic static void startPickImageActivity(android.content.Context context,
Fragment fragment)
startPickImageActivity method but instead of
being called and returning to an Activity, this method can be called and return to a Fragment.context - The Fragments context. Use getContext()fragment - The calling Fragment to start and return the image topublic static android.content.Intent getPickImageChooserIntent(android.content.Context context)
context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.public static android.content.Intent getPickImageChooserIntent(android.content.Context context,
java.lang.CharSequence title,
boolean includeDocuments,
boolean includeCamera)
context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.title - the title to use for the chooser UIincludeDocuments - if to include KitKat documents activity containing all sourcesincludeCamera - if to include camera intentspublic static android.content.Intent getCameraIntent(android.content.Context context,
android.net.Uri outputFileUri)
getCaptureImageOutputUri(Context), so then
you will be able to get the pictureUri using getPickImageResultUri(Context, Intent).
Otherwise, it is just you use the Uri passed to this method.context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.outputFileUri - the Uri where the picture will be placed.public static java.util.List<android.content.Intent> getCameraIntents(android.content.Context context,
android.content.pm.PackageManager packageManager)
public static java.util.List<android.content.Intent> getGalleryIntents(android.content.pm.PackageManager packageManager,
java.lang.String action,
boolean includeDocuments)
public static boolean isExplicitCameraPermissionRequired(android.content.Context context)
public static boolean hasPermissionInManifest(android.content.Context context,
java.lang.String permissionName)
permissionName - the permission to checkpublic static android.net.Uri getCaptureImageOutputUri(android.content.Context context)
context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.public static android.net.Uri getPickImageResultUri(android.content.Context context,
android.content.Intent data)
getPickImageChooserIntent(Context).context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.data - the returned data of the activity resultpublic static boolean isReadExternalStoragePermissionsRequired(android.content.Context context,
android.net.Uri uri)
context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.uri - the result URI of image pick.public static boolean isUriRequiresPermissions(android.content.Context context,
android.net.Uri uri)
context - used to access Android APIs, like content resolve, it is your
activity/fragment/widget.uri - the result URI of image pick.public static CropImage.ActivityBuilder activity()
CropImage.ActivityBuilder instance to open image picker for cropping and then start CropImageActivity to crop the selected image.Activity.onActivityResult(int, int, Intent) and can be
retrieved using getActivityResult(Intent).public static CropImage.ActivityBuilder activity(android.net.Uri uri)
CropImage.ActivityBuilder instance to start CropImageActivity to crop the given
image.Activity.onActivityResult(int, int, Intent) and can be
retrieved using getActivityResult(Intent).uri - the image Android uri source to crop or null to start a pickerpublic static CropImage.ActivityResult getActivityResult(android.content.Intent data)
CropImageActivity result data object for crop image activity started using activity(Uri).data - result data intent as received in Activity.onActivityResult(int, int,
Intent).