Merge pull request #289 from ollija/master

(android) Add 'hideBottomControls' & 'enableRotationGesture' -options
This commit is contained in:
Ivan Pusic 2017-04-03 23:49:12 +02:00 committed by GitHub
commit 34d80f2327
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' | | 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 | | 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 | | 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 #### Response Object
| Property | Type | Description | | 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.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener; import com.facebook.react.modules.core.PermissionListener;
import com.yalantis.ucrop.UCrop; import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.UCropActivity;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -68,6 +69,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
private boolean cropping = false; private boolean cropping = false;
private boolean cropperCircleOverlay = false; private boolean cropperCircleOverlay = false;
private boolean showCropGuidelines = true; private boolean showCropGuidelines = true;
private boolean hideBottomControls = false;
private boolean enableRotationGesture = false;
private ReadableMap options; private ReadableMap options;
@ -112,6 +115,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
cropperTintColor = options.hasKey("cropperTintColor") ? options.getString("cropperTintColor") : cropperTintColor; cropperTintColor = options.hasKey("cropperTintColor") ? options.getString("cropperTintColor") : cropperTintColor;
cropperCircleOverlay = options.hasKey("cropperCircleOverlay") ? options.getBoolean("cropperCircleOverlay") : cropperCircleOverlay; cropperCircleOverlay = options.hasKey("cropperCircleOverlay") ? options.getBoolean("cropperCircleOverlay") : cropperCircleOverlay;
showCropGuidelines = options.hasKey("showCropGuidelines") ? options.getBoolean("showCropGuidelines") : showCropGuidelines; 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; this.options = options;
} }
@ -554,6 +559,15 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
options.setCompressionQuality(100); options.setCompressionQuality(100);
options.setCircleDimmedLayer(cropperCircleOverlay); options.setCircleDimmedLayer(cropperCircleOverlay);
options.setShowCropGrid(showCropGuidelines); 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); configureCropperColors(options);
UCrop.of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg"))) UCrop.of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg")))