(android) Add 'hideBottomControls' & 'enableRotationGesture' -options

This commit is contained in:
Olli Jaakkola 2017-04-03 23:24:05 +03:00
parent 6725db0147
commit 3d12a4510d
2 changed files with 16 additions and 0 deletions

View File

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

View File

@ -31,6 +31,7 @@ import com.facebook.react.bridge.WritableNativeMap;
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;
@ -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;
@ -112,6 +115,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
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;
}
@ -554,6 +559,15 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
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")))