Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioutama committed May 8, 2020
2 parents 82140d0 + aef83f9 commit f775b50
Show file tree
Hide file tree
Showing 20 changed files with 1,489 additions and 1,732 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open_collective: react-native-image-crop-picker
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ImagePicker.clean().then(() => {
| 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) | 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. |
| avoidEmptySpaceAroundImage (ios only) | 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 @@ -141,6 +141,7 @@ ImagePicker.clean().then(() => {
| 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 |
| sortOrder (ios only) | string (default 'none', supported values: 'asc', 'desc', 'none') | Applies a sort order on the creation date on how media is displayed within the albums/detail photo views when opening the image picker |
| 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 |
Expand Down Expand Up @@ -196,14 +197,6 @@ pod install

After this use `ios/<project_name>.xcworkspace`. **Do not use** `ios/<project_name>.xcodeproj`.

##### Using local QBImagePicker

It is recommended to use locally provided QBImagePicker pod, because it contains few improvements over original version.

```
pod 'QBImagePickerController', :path => '../node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePickerController.podspec'
```

#### - If you are not using Cocoapods which is not recommended:

```bash
Expand Down
15 changes: 11 additions & 4 deletions RNImageCropPicker.podspec
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
version = package['version']

Pod::Spec.new do |s|
s.name = "RNImageCropPicker"
s.version = version
s.version = package['version']
s.summary = package["description"]
s.requires_arc = true
s.license = 'MIT'
s.homepage = 'n/a'
s.authors = { "ivpusic" => "" }
s.source = { :git => "https://github.com/ivpusic/react-native-image-crop-picker", :tag => 'v#{version}'}
s.source = { :git => "https://github.com/ivpusic/react-native-image-crop-picker", :tag => "v#{s.version}"}
s.source_files = 'ios/src/*.{h,m}'
s.platform = :ios, "8.0"
s.dependency 'RSKImageCropper'
s.dependency 'QBImagePickerController'
s.dependency 'React-Core'
s.dependency 'React-RCTImage'
s.dependency 'TOCropViewController'

s.subspec 'QBImagePickerController' do |qb|
qb.name = "QBImagePickerController"
qb.source_files = "ios/QBImagePicker/QBImagePicker/*.{h,m}"
qb.exclude_files = "ios/QBImagePicker/QBImagePicker/QBImagePicker.h"
qb.resource_bundles = { "QBImagePicker" => "ios/QBImagePicker/QBImagePicker/*.{lproj,storyboard}" }
qb.requires_arc = true
qb.frameworks = "Photos"
end
end
9 changes: 5 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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_COMPILE_SDK_VERSION = 29
def DEFAULT_BUILD_TOOLS_VERSION = "29.0.2"
def DEFAULT_TARGET_SDK_VERSION = 29
def DEFAULT_MIN_SDK_VERSION = 16

android {
Expand All @@ -21,5 +21,6 @@ android {

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.github.yalantis:ucrop:2.2.2-native'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'com.github.yalantis:ucrop:2.2.5-native'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.reactnative.ivpusic.imagepicker;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
Expand All @@ -26,7 +27,7 @@

class Compression {

File resize(String originalImagePath, int maxWidth, int maxHeight, int quality) throws IOException {
File resize(Context context, String originalImagePath, int maxWidth, int maxHeight, int quality) throws IOException {
Bitmap original = BitmapFactory.decodeFile(originalImagePath);

int width = original.getWidth();
Expand Down Expand Up @@ -54,9 +55,8 @@ File resize(String originalImagePath, int maxWidth, int maxHeight, int quality)

Bitmap resized = Bitmap.createScaledBitmap(original, finalWidth, finalHeight, true);
resized = Bitmap.createBitmap(resized, 0, 0, finalWidth, finalHeight, rotationMatrix, true);

File imageDirectory = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);

File imageDirectory = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);

if(!imageDirectory.exists()) {
Log.d("image-crop-picker", "Pictures Directory is not existing. Will create this directory.");
Expand Down Expand Up @@ -88,7 +88,7 @@ int getRotationInDegreesForOrientationTag(int orientationTag) {
}
}

File compressImage(final ReadableMap options, final String originalImagePath, final BitmapFactory.Options bitmapOptions) throws IOException {
File compressImage(final Context context, final ReadableMap options, final String originalImagePath, final BitmapFactory.Options bitmapOptions) throws IOException {
Integer maxWidth = options.hasKey("compressImageMaxWidth") ? options.getInt("compressImageMaxWidth") : null;
Integer maxHeight = options.hasKey("compressImageMaxHeight") ? options.getInt("compressImageMaxHeight") : null;
Double quality = options.hasKey("compressImageQuality") ? options.getDouble("compressImageQuality") : null;
Expand Down Expand Up @@ -123,7 +123,7 @@ File compressImage(final ReadableMap options, final String originalImagePath, fi
maxHeight = Math.min(maxHeight, bitmapOptions.outHeight);
}

return resize(originalImagePath, maxWidth, maxHeight, targetQuality);
return resize(context, originalImagePath, maxWidth, maxHeight, targetQuality);
}

synchronized void compressVideo(final Activity activity, final ReadableMap options, final String originalVideo, final String compressedVideo, final Promise promise) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ private WritableMap getImage(final Activity activity, String path) throws Except

// if compression options are provided image will be compressed. If none options is provided,
// then original image will be returned
File compressedImage = compression.compressImage(options, path, original);
File compressedImage = compression.compressImage(this.reactContext, options, path, original);
String compressedImagePath = compressedImage.getPath();
BitmapFactory.Options options = validateImage(compressedImagePath);
long modificationDate = new File(path).lastModified();
Expand Down Expand Up @@ -613,10 +613,10 @@ private void configureCropperColors(UCrop.Options options) {
Default tint is grey => use a more flashy color that stands out more as the call to action
Here we use 'Light Blue 500' from https://material.google.com/style/color.html#color-color-palette
*/
options.setActiveWidgetColor(Color.parseColor(DEFAULT_WIDGET_COLOR));
options.setActiveControlsWidgetColor(Color.parseColor(DEFAULT_WIDGET_COLOR));
} else {
//If they pass a custom tint color in, we use this for everything
options.setActiveWidgetColor(activeWidgetColor);
options.setActiveControlsWidgetColor(activeWidgetColor);
}
}

Expand Down Expand Up @@ -736,7 +736,8 @@ private void croppingResult(Activity activity, final int requestCode, final int
if (resultUri != null) {
try {
if (width > 0 && height > 0) {
resultUri = Uri.fromFile(compression.resize(resultUri.getPath(), width, height, 100));
File resized = compression.resize(this.reactContext, resultUri.getPath(), width, height, 100);
resultUri = Uri.fromFile(resized);
}

WritableMap result = getSelection(activity, resultUri, false);
Expand Down Expand Up @@ -783,8 +784,7 @@ private boolean isCameraAvailable(Activity activity) {
private File createImageFile() throws IOException {

String imageFileName = "image-" + UUID.randomUUID().toString();
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File path = this.reactContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);

if (!path.exists() && !path.isDirectory()) {
path.mkdirs();
Expand All @@ -802,8 +802,7 @@ private File createImageFile() throws IOException {
private File createVideoFile() throws IOException {

String videoFileName = "video-" + UUID.randomUUID().toString();
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File path = this.reactContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);

if (!path.exists() && !path.isDirectory()) {
path.mkdirs();
Expand Down
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

buildscript {
ext {
buildToolsVersion = "28.0.3"
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = "28.0.0"
}
repositories {
Expand All @@ -17,7 +17,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.5.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 10 14:06:26 CEST 2019
#Thu Apr 23 17:23:32 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
2 changes: 2 additions & 0 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class App extends Component {
height: 500,
cropping: cropit,
cropperCircleOverlay: circular,
sortOrder: 'none',
compressImageMaxWidth: 1000,
compressImageMaxHeight: 1000,
compressImageQuality: 1,
Expand All @@ -134,6 +135,7 @@ export default class App extends Component {
ImagePicker.openPicker({
multiple: true,
waitAnimationEnd: false,
sortOrder: 'desc',
includeExif: true,
forceJpg: true,
}).then(images => {
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ target 'example' do
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'RNImageCropPicker', :path => '../../'

use_native_modules!
end
19 changes: 10 additions & 9 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ PODS:
- DoubleConversion
- glog
- glog (0.3.5)
- QBImagePickerController (3.4.0)
- RCTRequired (0.61.2)
- RCTTypeSafety (0.61.2):
- FBLazyVector (= 0.61.2)
Expand Down Expand Up @@ -223,8 +222,12 @@ PODS:
- React-cxxreact (= 0.61.2)
- React-jsi (= 0.61.2)
- ReactCommon/jscallinvoker (= 0.61.2)
- RNImageCropPicker (0.25.3):
- QBImagePickerController
- RNImageCropPicker (0.27.0):
- React-Core
- React-RCTImage
- RNImageCropPicker/QBImagePickerController (= 0.27.0)
- RSKImageCropper
- RNImageCropPicker/QBImagePickerController (0.27.0):
- React-Core
- React-RCTImage
- RSKImageCropper
Expand Down Expand Up @@ -260,13 +263,12 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`)
- RNImageCropPicker (from `../../`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
trunk:
- boost-for-react-native
- QBImagePickerController
- RSKImageCropper

EXTERNAL SOURCES:
Expand Down Expand Up @@ -321,7 +323,7 @@ EXTERNAL SOURCES:
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNImageCropPicker:
:path: "../node_modules/react-native-image-crop-picker"
:path: "../../"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand All @@ -332,7 +334,6 @@ SPEC CHECKSUMS:
FBReactNativeSpec: 5a764c60abdc3336a213e5310c40b74741f32839
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022
RCTRequired: c639d59ed389cfb1f1203f65c2ea946d8ec586e2
RCTTypeSafety: dc23fb655d6c77667c78e327bf661bc11e3b8aec
React: 7e586e5d7bec12b91c1a096826b0fc9ab1da7865
Expand All @@ -353,10 +354,10 @@ SPEC CHECKSUMS:
React-RCTText: e3ef6191cdb627855ff7fe8fa0c1e14094967fb8
React-RCTVibration: fb54c732fd20405a76598e431aa2f8c2bf527de9
ReactCommon: 5848032ed2f274fcb40f6b9ec24067787c42d479
RNImageCropPicker: bfb3ea9c8622f290532e2fe63f369e0d5a52f597
RNImageCropPicker: 9d74cf3dadd8774c05a5f772b9a3397027576fa8
RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a
Yoga: 14927e37bd25376d216b150ab2a561773d57911f

PODFILE CHECKSUM: 61ffb4ec62885bf26d3320925ac20ddbefc82e79
PODFILE CHECKSUM: c105f81c59b354c8c6043ddcc6156cc74cc4a621

COCOAPODS: 1.8.3
2 changes: 1 addition & 1 deletion example/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/QBImagePickerController/QBImagePicker.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNImageCropPicker/QBImagePicker.bundle",
"${PODS_ROOT}/RSKImageCropper/RSKImageCropper/RSKImageCropperStrings.bundle",
);
name = "[CP] Copy Pods Resources";
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"react-native-video": "5.1.0-alpha1"
},
"devDependencies": {
"react-native-cli": "2.0.1"
"@react-native-community/cli": "3.0.4"
}
}
Loading

0 comments on commit f775b50

Please sign in to comment.