Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into rncamera
Browse files Browse the repository at this point in the history
* upstream/master: (23 commits)
  Updates Pod Install Instructions
  reenable camera on android emulator
  Create GradleUpgradeGuide.md
  Android: Fix java.lang.ArrayIndexOutOfBoundsException with image rotation
  Fix run time error missing facebook infer annotation
  UPDATED renderChildren to return this.props.children instead of null
  feat(types): add types for react-native-camera#1547 (react-native-camera#1548)
  fix(rn-camera): inject correct status
  feat(rn-camera): use and export constants
  fix status for non authorized/pending camera
  The correct capture preset for photos is AVCaptureSessionPresetPhoto
  add gradle 3 on issue template
  feat(types): add types for react-native-camera#1523
  feat(types): add types for react-native-camera#1518 (FaCC)
  Add missing infer annotation dependency.
  fix(cache): store video recordings in same directory as photos
  fix(rn_camera): improve naming
  feat(rn_camera): add function as children
  1.1.2
  build(change-log): v1.1.2-4
  ...
  • Loading branch information
rad182 committed May 18, 2018
2 parents 91f310a + b84436d commit 1ff1fca
Show file tree
Hide file tree
Showing 34 changed files with 4,125 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
### Warning
RCTCamera is **DEPRECATED** on v1.0.0 follow our migration guide here https://github.com/react-native-community/react-native-camera/blob/master/docs/migration.md

### Gradle 3
This package required Gradle 3, follow this migration guide https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration

### Which implementation are you using

*RNCamera* or RCTCamera (RCTCamera will be removed on v2.0.0)?
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#### 1.1.2-4 (2018-04-25)

##### Chores

* **cameraview:** integrate google's cameraview directly on rncamera? ([d11ed319](https://github.com/react-native-community/react-native-camera/commit/d11ed31917c26df151b4fb46ab166d2921a9ac99))

##### Bug Fixes

* **search-paths:** remove unnecessary search paths and add missing one ([dee298b4](https://github.com/react-native-community/react-native-camera/commit/dee298b4fefca4659468fd43e914fd1c970ca930))

#### 1.1.1-3 (2018-04-15)

##### Build System / Dependencies
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ And add something like this to the `scripts` section in your `package.json`:
##### Installing GMV frameworks
GMV (Google Mobile Vision) is used for Face detection by the iOS RNCamera. You have to link the google frameworks to your project to successfully compile the RNCamera project.

1. If using **CocoaPods** modify the dependency towards `react-native-camera` in your
###### CocoaPods Path
1. Modify the dependency towards `react-native-camera` in your
`Podfile`, from

```
Expand All @@ -128,8 +129,17 @@ to
pod 'react-native-camera', subspecs: ['RCT', 'RN', 'FaceDetector'], path: '../node_modules/react-native-camera'
```

2. Add the following to your `Podfile`:
```
pod 'GoogleMobileVision/Detector', '~> 1.1.0'
pod 'GoogleMobileVision/MVDataOutput', '~> 1.1.0'
pod 'GoogleMobileVision/FaceDetector', '~> 1.1.0'
```

3. In XCode, On your target -> Build Phases -> Link Binary with Libraries -> add AddressBook.framework

2. Download:
###### Non-CocoaPods Path
1. Download:
Google Symbol Utilities: https://www.gstatic.com/cpdc/dbffca986f6337f8-GoogleSymbolUtilities-1.1.1.tar.gz

Google Utilities: https://dl.google.com/dl/cpdc/978f81964b50a7c0/GoogleUtilities-1.3.2.tar.gz
Expand All @@ -140,13 +150,13 @@ Google Symbol Utilities: https://www.gstatic.com/cpdc/dbffca986f6337f8-GoogleSym

Google Interchange Utilities: https://dl.google.com/dl/cpdc/1a7f7ba905b2c029/GoogleInterchangeUtilities-1.2.2.tar.gz

3. Extract everything to one folder. Delete "BarcodeDetector" and "copy" folders from Google Mobile Vision.
2. Extract everything to one folder. Delete "BarcodeDetector" and "copy" folders from Google Mobile Vision.

4. Open XCode, right click on your project and choose "New Group". Rename the new folder to "Frameworks". Right click on "Frameworks" and select "add files to 'YOUR_PROJECT'". Select all content from the folder of step 2, click on Options. Select "Copy items if needed", leave "Create groups" selected and choose all your targets on the "Add to targets" section. Then, click on "Add".
3. Open XCode, right click on your project and choose "New Group". Rename the new folder to "Frameworks". Right click on "Frameworks" and select "add files to 'YOUR_PROJECT'". Select all content from the folder of step 2, click on Options. Select "Copy items if needed", leave "Create groups" selected and choose all your targets on the "Add to targets" section. Then, click on "Add".

5. On your target -> Build Phases -> Link Binary with Libraries -> add AddressBook.framework
6. On your target -> Build Settings -> Other Linker Flags -> add -lz, -ObjC and -lc++
7. To force indexing and prevent errors, restart xcode and reopen your project again before compiling.
4. On your target -> Build Phases -> Link Binary with Libraries -> add AddressBook.framework
5. On your target -> Build Settings -> Other Linker Flags -> add -lz, -ObjC and -lc++
6. To force indexing and prevent errors, restart xcode and reopen your project again before compiling.

#### Android
1. `npm install react-native-camera --save`
Expand Down
6 changes: 4 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com'
}
Expand Down Expand Up @@ -53,10 +54,11 @@ dependencies {
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIBRARY_VERSION

compileOnly 'com.facebook.react:react-native:+'
implementation 'com.facebook.infer.annotation:infer-annotation:+'
implementation "com.google.zxing:core:3.2.1"
implementation "com.drewnoakes:metadata-extractor:2.9.1"
implementation "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
implementation "com.android.support:exifinterface:$supportLibVersion"

implementation 'com.github.react-native-community:cameraview:eb9f726215bbbfcc03a54db92e480d4d02e0c001'
implementation "com.android.support:support-annotations:$supportLibVersion"
implementation "com.android.support:support-v4:$supportLibVersion"
}
189 changes: 189 additions & 0 deletions android/src/main/java/com/google/android/cameraview/AspectRatio.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.android.cameraview;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.util.SparseArrayCompat;

/**
* Immutable class for describing proportional relationship between width and height.
*/
public class AspectRatio implements Comparable<AspectRatio>, Parcelable {

private final static SparseArrayCompat<SparseArrayCompat<AspectRatio>> sCache
= new SparseArrayCompat<>(16);

private final int mX;
private final int mY;

/**
* Returns an instance of {@link AspectRatio} specified by {@code x} and {@code y} values.
* The values {@code x} and {@code} will be reduced by their greatest common divider.
*
* @param x The width
* @param y The height
* @return An instance of {@link AspectRatio}
*/
public static AspectRatio of(int x, int y) {
int gcd = gcd(x, y);
x /= gcd;
y /= gcd;
SparseArrayCompat<AspectRatio> arrayX = sCache.get(x);
if (arrayX == null) {
AspectRatio ratio = new AspectRatio(x, y);
arrayX = new SparseArrayCompat<>();
arrayX.put(y, ratio);
sCache.put(x, arrayX);
return ratio;
} else {
AspectRatio ratio = arrayX.get(y);
if (ratio == null) {
ratio = new AspectRatio(x, y);
arrayX.put(y, ratio);
}
return ratio;
}
}

/**
* Parse an {@link AspectRatio} from a {@link String} formatted like "4:3".
*
* @param s The string representation of the aspect ratio
* @return The aspect ratio
* @throws IllegalArgumentException when the format is incorrect.
*/
public static AspectRatio parse(String s) {
int position = s.indexOf(':');
if (position == -1) {
throw new IllegalArgumentException("Malformed aspect ratio: " + s);
}
try {
int x = Integer.parseInt(s.substring(0, position));
int y = Integer.parseInt(s.substring(position + 1));
return AspectRatio.of(x, y);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Malformed aspect ratio: " + s, e);
}
}

private AspectRatio(int x, int y) {
mX = x;
mY = y;
}

public int getX() {
return mX;
}

public int getY() {
return mY;
}

public boolean matches(Size size) {
int gcd = gcd(size.getWidth(), size.getHeight());
int x = size.getWidth() / gcd;
int y = size.getHeight() / gcd;
return mX == x && mY == y;
}

@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (this == o) {
return true;
}
if (o instanceof AspectRatio) {
AspectRatio ratio = (AspectRatio) o;
return mX == ratio.mX && mY == ratio.mY;
}
return false;
}

@Override
public String toString() {
return mX + ":" + mY;
}

public float toFloat() {
return (float) mX / mY;
}

@Override
public int hashCode() {
// assuming most sizes are <2^16, doing a rotate will give us perfect hashing
return mY ^ ((mX << (Integer.SIZE / 2)) | (mX >>> (Integer.SIZE / 2)));
}

@Override
public int compareTo(@NonNull AspectRatio another) {
if (equals(another)) {
return 0;
} else if (toFloat() - another.toFloat() > 0) {
return 1;
}
return -1;
}

/**
* @return The inverse of this {@link AspectRatio}.
*/
public AspectRatio inverse() {
//noinspection SuspiciousNameCombination
return AspectRatio.of(mY, mX);
}

private static int gcd(int a, int b) {
while (b != 0) {
int c = b;
b = a % b;
a = c;
}
return a;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mX);
dest.writeInt(mY);
}

public static final Parcelable.Creator<AspectRatio> CREATOR
= new Parcelable.Creator<AspectRatio>() {

@Override
public AspectRatio createFromParcel(Parcel source) {
int x = source.readInt();
int y = source.readInt();
return AspectRatio.of(x, y);
}

@Override
public AspectRatio[] newArray(int size) {
return new AspectRatio[size];
}
};

}
Loading

0 comments on commit 1ff1fca

Please sign in to comment.