Skip to content

Commit

Permalink
(android) Add 'hideBottomControls' & 'enableRotationGesture' -options
Browse files Browse the repository at this point in the history
  • Loading branch information
Olli Jaakkola committed Apr 3, 2017
1 parent 6725db0 commit 3d12a45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ ImagePicker.clean().then(() => {
| mediaType | string (default any) | Accepted mediaType for image selection, can be one of: 'photo', 'video', or 'any' |
| showsSelectedCount (ios only) | bool (default true) | Whether to show the number of selected assets |
| showCropGuidelines (android only) | bool (default true) | Whether to show the 3x3 grid on top of the image during cropping |
| hideBottomControls (android only) | bool (default false) | Whether to display bottom controls |
| enableRotationGesture (android only) | bool (default false) | Whether to enable rotating the image by hand gesture |
#### Response Object

| Property | Type | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.UCropActivity;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -68,6 +69,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
private boolean cropping = false;
private boolean cropperCircleOverlay = false;
private boolean showCropGuidelines = true;
private boolean hideBottomControls = false;
private boolean enableRotationGesture = false;
private ReadableMap options;


Expand Down Expand Up @@ -112,6 +115,8 @@ private void setConfiguration(final ReadableMap options) {
cropperTintColor = options.hasKey("cropperTintColor") ? options.getString("cropperTintColor") : cropperTintColor;
cropperCircleOverlay = options.hasKey("cropperCircleOverlay") ? options.getBoolean("cropperCircleOverlay") : cropperCircleOverlay;
showCropGuidelines = options.hasKey("showCropGuidelines") ? options.getBoolean("showCropGuidelines") : showCropGuidelines;
hideBottomControls = options.hasKey("hideBottomControls") ? options.getBoolean("hideBottomControls") : hideBottomControls;
enableRotationGesture = options.hasKey("enableRotationGesture") ? options.getBoolean("enableRotationGesture") : enableRotationGesture;
this.options = options;
}

Expand Down Expand Up @@ -554,6 +559,15 @@ private void startCropping(Activity activity, Uri uri) {
options.setCompressionQuality(100);
options.setCircleDimmedLayer(cropperCircleOverlay);
options.setShowCropGrid(showCropGuidelines);
options.setHideBottomControls(hideBottomControls);
if (enableRotationGesture) {
// UCropActivity.ALL = enable both rotation & scaling
options.setAllowedGestures(
UCropActivity.ALL, // When 'scale'-tab active
UCropActivity.ALL, // When 'rotate'-tab active
UCropActivity.ALL // When 'aspect ratio'-tab active
);
}
configureCropperColors(options);

UCrop.of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg")))
Expand Down

0 comments on commit 3d12a45

Please sign in to comment.