[Android] Add option to set the cropper toolbar title (#521)

* Add option to set the cropper toolbar title

I needed to change the toolbar title but didn't know any other way so I thought about adding this functionality. Currently, as my knowledge is limited to java, this is currently only available for Android.

Example usage:

```
ImagePicker.openCropper({
    path: 'image.png',
    width: 800,
    height: 800,
    cropperToolbarTitle: 'Please, crop your photo',
})
```
If no title is provided, the default one from the library will be used.

* Update docs
This commit is contained in:
Ricardo Fuhrmann 2017-11-25 23:11:13 -02:00 committed by Ivan Pusic
parent 822fbd7974
commit b34b43654f
2 changed files with 6 additions and 0 deletions

View File

@ -98,6 +98,7 @@ ImagePicker.clean().then(() => {
| cropperActiveWidgetColor (android only) | string (default `"#424242"`) | When cropping image, determines ActiveWidget color. |
| cropperStatusBarColor (android only) | string (default `#424242`) | When cropping image, determines the color of StatusBar. |
| cropperToolbarColor (android only) | string (default `#424242`) | When cropping image, determines the color of Toolbar. |
| cropperToolbarTitle (android only) | string (default `Edit Photo`) | When cropping image, determines the title of Toolbar. |
| cropperCircleOverlay | bool (default false) | Enable or disable circular cropping mask. |
| minFiles (ios only) | number (default 1) | Min number of files to select when using `multiple` option |
| maxFiles (ios only) | number (default 5) | Max number of files to select when using `multiple` option |

View File

@ -81,6 +81,7 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
private String cropperActiveWidgetColor = DEFAULT_TINT;
private String cropperStatusBarColor = DEFAULT_TINT;
private String cropperToolbarColor = DEFAULT_TINT;
private String cropperToolbarTitle = null;
//Light Blue 500
private final String DEFAULT_WIDGET_COLOR = "#03A9F4";
@ -120,6 +121,7 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
cropperActiveWidgetColor = options.hasKey("cropperActiveWidgetColor") ? options.getString("cropperActiveWidgetColor") : cropperActiveWidgetColor;
cropperStatusBarColor = options.hasKey("cropperStatusBarColor") ? options.getString("cropperStatusBarColor") : cropperStatusBarColor;
cropperToolbarColor = options.hasKey("cropperToolbarColor") ? options.getString("cropperToolbarColor") : cropperToolbarColor;
cropperToolbarTitle = options.hasKey("cropperToolbarTitle") ? options.getString("cropperToolbarTitle") : null;
cropperCircleOverlay = options.hasKey("cropperCircleOverlay") ? options.getBoolean("cropperCircleOverlay") : cropperCircleOverlay;
showCropGuidelines = options.hasKey("showCropGuidelines") ? options.getBoolean("showCropGuidelines") : showCropGuidelines;
hideBottomControls = options.hasKey("hideBottomControls") ? options.getBoolean("hideBottomControls") : hideBottomControls;
@ -578,6 +580,9 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
options.setCircleDimmedLayer(cropperCircleOverlay);
options.setShowCropGrid(showCropGuidelines);
options.setHideBottomControls(hideBottomControls);
if (cropperToolbarTitle != null) {
options.setToolbarTitle(cropperToolbarTitle);
}
if (enableRotationGesture) {
// UCropActivity.ALL = enable both rotation & scaling
options.setAllowedGestures(