Skip to content

Commit

Permalink
merge latest code (#11)
Browse files Browse the repository at this point in the history
* Add chooseText and cancelText properties: rebased (ivpusic#699)

* Add cancel and choose buttons text properties

* Change props names to ‘cancelText’,’chooseText’

* Add cancel and choose buttons text props

* Fix properties names IOS

* Add cropper prefix and update readme

* Add cloud support (Android) (ivpusic#650)

* Add cloud support - workd in progress

* Fix extension issue

* Remove log, unused import

* Fix regression (MIME_TYPE for action_get_document)

* (android) Upgrade ucrop to 2.2.2. Upgrade react-native for example project. Cleanup picker module

* version bump

* (android) Result collector improvements

* version bump

* Update README.md

* Update README.md

* Update README.md

* Reduce size of default compressed files, update README (ivpusic#736)

* [fix/android] Android API version under 19 crash fix (ivpusic#741)

* Convert unknown file types to JPEG (ivpusic#735)

* Added android equivalent code to iOS code. (ivpusic#749)

* Revert "Added android equivalent code to iOS code. (ivpusic#749)" (ivpusic#750)

This reverts commit 97ce8ba.

* Added android equivalent code for skipping image compression. (ivpusic#753)

* Added android equivalent code to iOS code.

* Fix invalid variable.

* Added option to configure avoidEmptySpaceAroundImage (ivpusic#765)

* Added option to configure avoidEmptySpaceAround image

* Added missing interface option

* Fixes uncasted bool value

* Add new logo/icon (ivpusic#768)

* Upload new logo

* Add new logo to README

* Add new to mipmap hdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Upload new logo svg

* Update README with new logo

* delete

* Upload New logo svg

* Update README

* Update README.md

* Use project-wide properties and new dependency (ivpusic#771)

* Support for gradle 3.+

* Add cropperToolbarTitle into TypeScript typings (ivpusic#777)

* Fix a bug when the file name contains slashes. (ivpusic#775)

It can happen when selecting an image downloaded from Weibo app.

* Change screen orientation so android will detect and change to match screen fixes issue ivpusic#733 (ivpusic#766)

* Adds forceJpg flag to convert live photos (ivpusic#791)

* Adds property to filter live photos

* Force JPG image conversion

* Renames forceJPG -> forceJpg

* [DEVOPS] version bump

* Revert to compile (ivpusic#796)

* [DEVOPS] Version bump

* add license scan

* Set options.networkAccessAllowed = YES in getVideoAsset to prevent freezing when attempting to get videos stored in the cloud (ivpusic#772)

* Fix typo on example (ivpusic#809)

* Fall back to writing to file if _data column does not exist (ivpusic#817)

* Fall back to writting to file if _data column does not exist

* Fix spelling

* Update README.md

* Update README.md (ivpusic#826)

Add optional configuration details about default ios text button for the camera and the gallery

* Diegolmello master (ivpusic#834)

* [FIX] Poor image quality after cropping

* Update README.md (ivpusic#826)

Add optional configuration details about default ios text button for the camera and the gallery

* [IMPROVEMENT] fix android cropping height condition. update podfile lock

* version bump

* Update README.md (ivpusic#851)

* Update PickerModule.java (ivpusic#862)

Fix for default values being kept when calling cropPicker from multiple locations.

Now default values if not passed will be reverted to default.

* version bump

* Add front camera support for android (ivpusic#876)

* Add front camera support for android

* Update readme

* Update readme

* Update README.md

* Added missing flags to support front camera on some android phones (ivpusic#891)

* Remove problematic step from manual post-install steps (ivpusic#821)

* (ios) fix images are not resized after cropping. Fixes ivpusic#843

* (ios) add example project xcshareddata

* (feature) video recording (ivpusic#917)

* Android: Add video recording support

- Caveats:
  - Wont work if cropping is enabled
- Video recording will be used if mediaType is set to 'video'
  - Mediatype any is not supported since there is no standard intent for capture image or video

* IOS: Add video recording support

- Caveats:
  - Cropping does not work

Video recording will be enabled if mediaType is set to `video` or `any`. Note: With any the native ui
allows the user to choose whether to take a photo or record a video. This differs from android where
mediaType any will just allow taking photos.

* IOS: Set camera video quality to high

* Update README.md (ivpusic#851)

* Update PickerModule.java (ivpusic#862)

Fix for default values being kept when calling cropPicker from multiple locations.

Now default values if not passed will be reverted to default.

* version bump

* Add front camera support for android (ivpusic#876)

* Add front camera support for android

* Update readme

* Update readme

* Update README.md

* Added missing flags to support front camera on some android phones (ivpusic#891)

* Remove problematic step from manual post-install steps (ivpusic#821)

* (ios) fix images are not resized after cropping. Fixes ivpusic#843

* (ios) add example project xcshareddata

* (ios) fixes for camera recording. updated example project with camera recording. updated readme with camera recording

* unify ios and android camera response. Fixes ivpusic#872

* version bump

* Update README.md

* Simplify `includeBase64` (ivpusic#918)

If `image.data` is already base64 encoded string, why do we need this wrapper?
The proposed change worked for me on ios and android.

* Make example config valid json (ivpusic#927)

* (android) cropping and resizing improvements

* (android) simplify options parsing

* android libs and package.json version bump

* Remove images from npm bundle (ivpusic#960)

* upgrade example project to react-native 0.59

* fix ios camera with cropping not reject on cancel cropping (ivpusic#954)

* fix ios camera with cropping not reject on cancel cropping

* cancel properly from opencropper

* replace compile with implementation in build.gradle

* version bump

* Add some types for Image interface (ivpusic#973)

* (android) add showCropFrame option (ivpusic#972)

* Fix Android image rotation issue when compressing gallery and camera images (ivpusic#379) (ivpusic#986)

When using the image compression options, the returned resized image orientation differed from the original image. This caused selected images to often be rotated.

Original issue thread:
ivpusic#379

* version bump

* example project support for android 9

* fixed bug with iOS cancel button (ivpusic#1000)

* version bump

* autoclose inputstream when base64 image file (ivpusic#1040)

* Fix when Pictures directory is not existing on device (ivpusic#1027)

* Update pod dependency to support rn 0.60 (ivpusic#1019)

* Update pod dependency to support rn 0.60

* Update RNImageCropPicker.podspec

* update android support library to androidx (ivpusic#1048)

* Update PickerModule.java

* Update RealPathUtil.java

* Update AndroidManifest.xml

* finishing support for react-native 0.60

* add installation notes for react-native 0.60

* Clarify README.md (ivpusic#1065)

React Native 0.60 higher requires you to manually install the pods after auto linking

* Clarify README.md (ivpusic#1058) (ivpusic#1074)

Not all Android devices handle useFrontCamera

* Adds a sortOrder flag to sort by creation date on iOS (ivpusic#1090)

* Adds a sortOrder flag to sort by creation date on iOS

* Removes extraneous sortOrder access

* check permission before startCropping. Fix of ivpusic#957 (ivpusic#1095)

* version bump

* Revert "Adds a sortOrder flag to sort by creation date on iOS (ivpusic#1090)"

This reverts commit 33fd526.

* version bump

* fixed `jitpack.io` url in readme.md (ivpusic#1115)

* Added iOS 13 DarkMode for picker (ivpusic#1129)

* Update README.md

* version bump

* HOM-3770 fix merge issues

* HOM-3770 restore video compression utility
  • Loading branch information
Ady Levy authored Nov 19, 2019
1 parent e052faf commit 887e682
Show file tree
Hide file tree
Showing 38 changed files with 4,477 additions and 3,595 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
example
node_modules
build
images
97 changes: 86 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# react-native-image-crop-picker
iOS/Android image picker with support for camera, configurable compression, multiple images and cropping

[![Backers on Open Collective](https://opencollective.com/react-native-image-crop-picker/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/react-native-image-crop-picker/sponsors/badge.svg)](#sponsors)

<img src="svg.svg" width="50%" height="50%" />

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping

## Result

<p align="left">
Expand All @@ -11,6 +14,10 @@ iOS/Android image picker with support for camera, configurable compression, mult
<img width=200 title="iOS Multiple Pick" src="https://github.com/ivpusic/react-native-image-crop-picker/blob/master/images/ios_multiple_pick.png">
</p>

## Important note

If you are using react-native >= 0.60 use react-native-image-crop-picker version >= 0.25.0. Otherwise use version < 0.25.0.

## Usage

Import library
Expand Down Expand Up @@ -55,13 +62,25 @@ ImagePicker.openPicker({
**Android: The prop 'cropping' has been known to cause videos not to be display in the gallery on Android. Please do not set cropping to true when selecting videos.**


### Select from camera
### Select from camera

#### Image

```javascript
ImagePicker.openCamera({
width: 300,
height: 400,
cropping: true
cropping: true,
}).then(image => {
console.log(image);
});
```

#### Video

```javascript
ImagePicker.openCamera({
mediaType: 'video',
}).then(image => {
console.log(image);
});
Expand Down Expand Up @@ -100,8 +119,9 @@ ImagePicker.clean().then(() => {
| height | number | Height of result image when used with `cropping` option |
| multiple | bool (default false) | Enable or disable multiple image selection |
| writeTempFile (ios only) | bool (default true) | When set to false, does not write temporary files for the selected images. This is useful to improve performance when you are retrieving file contents with the `includeBase64` option and don't need to read files from disk. |
| includeBase64 | bool (default false) | Enable or disable returning base64 data with image |
| includeBase64 | bool (default false) | When set to true, the image file content will be available as a base64-encoded string in the `data` property. Hint: To use this string as an image source, use it like: ``<Image source={{uri: `data:${image.mime};base64,${image.data}`}} />`` |
| includeExif | bool (default false) | Include image exif data in the response |
| avoidEmptySpaceAroundImage | bool (default true) | When set to true, the image will always fill the mask space. |
| 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. |
Expand All @@ -113,17 +133,21 @@ ImagePicker.clean().then(() => {
| maxFiles (ios only) | number (default 5) | Max number of files to select when using `multiple` option |
| waitAnimationEnd (ios only) | bool (default true) | Promise will resolve/reject once ViewController `completion` block is called |
| smartAlbums (ios only) | array ([supported values](https://github.com/ivpusic/react-native-image-crop-picker/blob/master/README.md#smart-album-types-ios)) (default ['UserLibrary', 'PhotoStream', 'Panoramas', 'Videos', 'Bursts']) | List of smart albums to choose from |
| useFrontCamera (ios only) | bool (default false) | Whether to default to the front/'selfie' camera when opened |
| useFrontCamera | bool (default false) | Whether to default to the front/'selfie' camera when opened. Please note that not all Android devices handle this parameter, see [issue #1058](https://github.com/ivpusic/react-native-image-crop-picker/issues/1058)|
| compressVideoPreset (ios only) | string (default MediumQuality) | Choose which preset will be used for video compression |
| compressImageMaxWidth | number (default none) | Compress image with maximum width |
| compressImageMaxHeight | number (default none) | Compress image with maximum height |
| compressImageQuality | number (default 1) | Compress image with quality (from 0 to 1, where 1 is best quality) |
| compressImageQuality | number (default 1 (Android)/0.8 (iOS)) | Compress image with quality (from 0 to 1, where 1 is best quality). On iOS, values larger than 0.8 don't produce a noticable quality increase in most images, while a value of 0.8 will reduce the file size by about half or less compared to a value of 1. |
| loadingLabelText (ios only) | string (default "Processing assets...") | Text displayed while photo is loading in picker |
| 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 |
| forceJpg (ios only) | bool (default false) | Whether to convert photos to JPG. This will also convert any Live Photo into its JPG representation |
| showCropGuidelines (android only) | bool (default true) | Whether to show the 3x3 grid on top of the image during cropping |
| showCropFrame (android only) | bool (default true) | Whether to show crop frame 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 |
| cropperChooseText (ios only)  |           string (default choose)        | Choose button text |
| cropperCancelText (ios only) | string (default Cancel) | Cancel button text |

#### Smart Album Types (ios)

Expand Down Expand Up @@ -161,6 +185,17 @@ npm i react-native-image-crop-picker --save

### iOS

NOTE: If you are using react-native >= 0.60 autolinking, all you have to do is:

- Install the library via NPM or Yarm
- Run the following:
```
cd ios
pod install
```

Then the library will be successfully linked.

#### - If you use Cocoapods which is highly recommended:

```bash
Expand Down Expand Up @@ -219,8 +254,18 @@ After this use `ios/<project_name>.xcworkspace`. **Do not use** `ios/<project_na
react-native link react-native-image-crop-picker
```
#### Dark Mode
To enable support for dark mode, please add local 'QBImagePickerController' pod to your Podfile.
```
pod 'QBImagePickerController', :path => '../node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePickerController.podspec'
```
### Android
NOTE: If you are using react-native >= 0.60 autolinking, you can skip this step.
```bash
react-native link react-native-image-crop-picker
```
Expand All @@ -237,14 +282,21 @@ In Xcode open Info.plist and add string key `NSPhotoLibraryUsageDescription` wit
##### Only if you are not using Cocoapods
- Drag and drop the ios/ImageCropPickerSDK folder to your xcode project. (Make sure Copy items if needed IS ticked)
- Click on project General tab
- Under `Deployment Info` set `Deployment Target` to `8.0`
- Under `Embedded Binaries` click `+` and add `RSKImageCropper.framework` and `QBImagePicker.framework`
#### Step Optional - To localizate the camera / gallery text buttons
- Open your Xcode project
- Go to your project settings by opening the project name on the Navigation (left side)
- Select your project in the project list
- Should be into the Info tab and add in Localizations the language your app was missing throughout the +
- Rebuild and you should now have your app camera and gallery with the classic ios text in the language you added.
### Android
- Make sure you are using Gradle `2.2.x` (android/build.gradle)
- Make sure you are using Gradle >= `2.2.x` (android/build.gradle)
```gradle
buildscript {
Expand All @@ -266,8 +318,11 @@ allprojects {
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
// jitpack repo is necessary to fetch ucrop dependency
maven { url "https://jitpack.io" }
// ADD THIS
maven { url 'https://maven.google.com' }
// ADD THIS
maven { url "https://www.jitpack.io" }
}
}
```
Expand All @@ -287,9 +342,30 @@ android {
}
```
- Use Android SDK >= 26 (android/app/build.gradle)
```gradle
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
...
defaultConfig {
...
targetSdkVersion 27
...
}
...
}
```
- [Optional] If you want to use camera picker in your project, add following to `app\src\main\AndroidManifest.xml`
- `<uses-permission android:name="android.permission.CAMERA"/>`
- [Optional] If you want to use front camera, also add following to `app\src\main\AndroidManifest.xml`
- `<uses-feature android:name="android.hardware.camera" android:required="false" />`
- `<uses-feature android:name="android.hardware.camera.front" android:required="false" />`
## Production build
### iOS
Expand All @@ -312,7 +388,6 @@ Details for second approach:
## TO DO
- [ ] [Android] Standardize multiple select
- [ ] [Android] Pick remote media
- [ ] [Android] Video compression
Expand Down
3 changes: 2 additions & 1 deletion RNImageCropPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ Pod::Spec.new do |s|
s.platform = :ios, "8.0"
s.dependency 'RSKImageCropper'
s.dependency 'QBImagePickerController'
s.dependency 'React/Core'
s.dependency 'React-Core'
s.dependency 'React-RCTImage'
end
20 changes: 12 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_TARGET_SDK_VERSION = 28
def DEFAULT_MIN_SDK_VERSION = 16

android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion 16
targetSdkVersion 27
defaultConfig {
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
}
lintOptions {
Expand All @@ -15,7 +20,6 @@ android {
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.github.yalantis:ucrop:2.2.1-native'
compile 'id.zelory:compressor:2.1.0'
implementation 'com.facebook.react:react-native:+'
implementation 'com.github.yalantis:ucrop:2.2.2-native'
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<application>

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
Expand All @@ -17,7 +17,6 @@

<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
</application>

Expand Down
Loading

0 comments on commit 887e682

Please sign in to comment.