Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
fix(android-camera): revert to old camera api
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfidelis committed Mar 2, 2018
1 parent f7f2ea5 commit 8d9c06a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ dependencies {
compile 'com.google.android.gms:play-services-vision:+'
compile "com.android.support:exifinterface:+"

compile 'com.github.react-native-community:cameraview:d5d9b0d925494ef451ce3eef3fdf14cc874d9baa'
compile 'com.github.react-native-community:cameraview:cc47bb28ed2fc54a8c56a4ce9ce53edd1f0af3a5'
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ public void setBarCodeScanning(RNCameraView view, boolean barCodeScannerEnabled)
view.setShouldScanBarCodes(barCodeScannerEnabled);
}

@ReactProp(name = "useCamera2Api")
public void setUseCamera2Api(RNCameraView view, boolean useCamera2Api) {
view.setUsingCamera2Api(useCamera2Api);
}

@ReactProp(name = "faceDetectorEnabled")
public void setFaceDetecting(RNCameraView view, boolean faceDetectorEnabled) {
view.setShouldDetectFaces(faceDetectorEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
private int mFaceDetectionClassifications = RNFaceDetector.NO_CLASSIFICATIONS;

public RNCameraView(ThemedReactContext themedReactContext) {
super(themedReactContext);
super(themedReactContext, true);
initBarcodeReader();
mThemedReactContext = themedReactContext;
mFaceDetector = new RNFaceDetector(themedReactContext);
Expand Down
74 changes: 41 additions & 33 deletions src/RNCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { mapValues } from 'lodash';
import {
findNodeHandle,
Platform,
NativeModules,
ViewPropTypes,
requireNativeComponent,
View,
ActivityIndicator,
import {
findNodeHandle,
Platform,
NativeModules,
ViewPropTypes,
requireNativeComponent,
View,
ActivityIndicator,
Text,
} from 'react-native';
} from 'react-native';

import type { FaceFeature } from './FaceDetector';

Expand Down Expand Up @@ -58,33 +58,34 @@ type PropsType = ViewPropTypes & {
faceDetectionClassifications?: number,
onFacesDetected?: ({ faces: Array<TrackedFaceFeature> }) => void,
captureAudio?: boolean,
useCamera2Api?: boolean,
};

const CameraManager: Object =
NativeModules.RNCameraManager || NativeModules.RNCameraModule || {
stubbed: true,
Type: {
back: 1,
},
AutoFocus: {
on: 1
},
FlashMode: {
off: 1,
},
WhiteBalance: {},
BarCodeType: {},
FaceDetection: {
fast: 1,
Mode: {},
Landmarks: {
none: 0,
const CameraManager: Object = NativeModules.RNCameraManager ||
NativeModules.RNCameraModule || {
stubbed: true,
Type: {
back: 1,
},
Classifications: {
none: 0,
AutoFocus: {
on: 1,
},
},
};
FlashMode: {
off: 1,
},
WhiteBalance: {},
BarCodeType: {},
FaceDetection: {
fast: 1,
Mode: {},
Landmarks: {
none: 0,
},
Classifications: {
none: 0,
},
},
};

const EventThrottleMs = 500;

Expand Down Expand Up @@ -132,6 +133,7 @@ export default class Camera extends React.Component<PropsType> {
notAuthorizedView: PropTypes.element,
pendingAuthorizationView: PropTypes.element,
captureAudio: PropTypes.bool,
useCamera2Api: PropTypes.bool,
};

static defaultProps: Object = {
Expand Down Expand Up @@ -178,6 +180,7 @@ export default class Camera extends React.Component<PropsType> {
</View>
),
captureAudio: false,
useCamera2Api: false,
};

_cameraRef: ?Object;
Expand Down Expand Up @@ -269,7 +272,12 @@ export default class Camera extends React.Component<PropsType> {

async componentWillMount() {
const hasVideoAndAudio = this.props.captureAudio;
const isAuthorized = await requestPermissions(hasVideoAndAudio, CameraManager, this.props.permissionDialogTitle, this.props.permissionDialogMessage);
const isAuthorized = await requestPermissions(
hasVideoAndAudio,
CameraManager,
this.props.permissionDialogTitle,
this.props.permissionDialogMessage,
);
this.setState({ isAuthorized, isAuthorizationChecked: true });
}

Expand Down

0 comments on commit 8d9c06a

Please sign in to comment.