Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: Upgrade VisionCamera to V4" #39367

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ PODS:
- SDWebImage/Core (~> 5.17)
- SocketRocket (0.6.1)
- Turf (2.7.0)
- VisionCamera (4.0.0-beta.11):
- VisionCamera (2.16.8):
- React
- React-callinvoker
- React-Core
Expand Down Expand Up @@ -1920,7 +1920,7 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: af09429398d99d524cae2fe00f6f0f6e491ed102
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2
VisionCamera: b6b6f46949eae83b71429c971162af337ef34fa3
VisionCamera: 0a6794d1974aed5d653d0d0cb900493e2583e35a
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047

PODFILE CHECKSUM: a431c146e1501391834a2f299a74093bac53b530
Expand Down
15 changes: 4 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"react-native-tab-view": "^3.5.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-view-shot": "3.8.0",
"react-native-vision-camera": "^4.0.0-beta.11",
"react-native-vision-camera": "2.16.8",
"react-native-web": "^0.19.9",
"react-native-web-linear-gradient": "^1.1.2",
"react-native-web-sound": "^0.1.3",
Expand Down
22 changes: 22 additions & 0 deletions patches/react-native-vision-camera+2.16.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/node_modules/react-native-vision-camera/android/build.gradle b/node_modules/react-native-vision-camera/android/build.gradle
index ddfa243..bafffc3 100644
--- a/node_modules/react-native-vision-camera/android/build.gradle
+++ b/node_modules/react-native-vision-camera/android/build.gradle
@@ -334,7 +334,7 @@ if (ENABLE_FRAME_PROCESSORS) {
def thirdPartyVersions = new Properties()
thirdPartyVersions.load(new FileInputStream(thirdPartyVersionsFile))

- def BOOST_VERSION = thirdPartyVersions["BOOST_VERSION"]
+ def BOOST_VERSION = thirdPartyVersions["BOOST_VERSION"] ?: "1.83.0"
def boost_file = new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")
def DOUBLE_CONVERSION_VERSION = thirdPartyVersions["DOUBLE_CONVERSION_VERSION"]
def double_conversion_file = new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz")
@@ -352,7 +352,7 @@ if (ENABLE_FRAME_PROCESSORS) {

task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
def transformedVersion = BOOST_VERSION.replace("_", ".")
- def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
+ def srcUrl = "https://archives.boost.io/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
if (REACT_NATIVE_VERSION < 69) {
srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref)
return (
<Camera
ref={ref}
photoQualityBalance="speed"
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
isActive={isCameraActive}
Expand Down
43 changes: 20 additions & 23 deletions src/pages/iou/request/step/IOURequestStepScan/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'reac
import {Gesture, GestureDetector} from 'react-native-gesture-handler';
import {RESULTS} from 'react-native-permissions';
import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated';
import {useCameraDevice} from 'react-native-vision-camera';
import {useCameraDevices} from 'react-native-vision-camera';
import Hand from '@assets/images/hand.svg';
import Shutter from '@assets/images/shutter.svg';
import AttachmentPicker from '@components/AttachmentPicker';
Expand Down Expand Up @@ -60,11 +60,9 @@ function IOURequestStepScan({
}) {
const theme = useTheme();
const styles = useThemeStyles();
const device = useCameraDevice('back', {
physicalDevices: ['wide-angle-camera'],
});
const devices = useCameraDevices('wide-angle-camera');
const device = devices.back;

const hasFlash = device != null && device.hasFlash;
const camera = useRef(null);
const [flash, setFlash] = useState(false);
const [cameraPermissionStatus, setCameraPermissionStatus] = useState(undefined);
Expand Down Expand Up @@ -238,7 +236,8 @@ function IOURequestStepScan({

return camera.current
.takePhoto({
flash: flash && hasFlash ? 'on' : 'off',
qualityPrioritization: 'speed',
flash: flash ? 'on' : 'off',
})
.then((photo) => {
// Store the receipt on the transaction object in Onyx
Expand All @@ -258,7 +257,7 @@ function IOURequestStepScan({
showCameraAlert();
Log.warn('Error taking photo', error);
});
}, [flash, hasFlash, action, translate, transactionID, updateScanAndNavigate, navigateToConfirmationStep, cameraPermissionStatus]);
}, [flash, action, translate, transactionID, updateScanAndNavigate, navigateToConfirmationStep, cameraPermissionStatus]);

// Wait for camera permission status to render
if (cameraPermissionStatus == null) {
Expand Down Expand Up @@ -357,22 +356,20 @@ function IOURequestStepScan({
height={CONST.RECEIPT.SHUTTER_SIZE}
/>
</PressableWithFeedback>
{hasFlash && (
<PressableWithFeedback
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={translate('receipt.flash')}
style={[styles.alignItemsEnd]}
disabled={cameraPermissionStatus !== RESULTS.GRANTED}
onPress={() => setFlash((prevFlash) => !prevFlash)}
>
<Icon
height={32}
width={32}
src={Expensicons.Bolt}
fill={flash ? theme.iconHovered : theme.textSupporting}
/>
</PressableWithFeedback>
)}
<PressableWithFeedback
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={translate('receipt.flash')}
style={[styles.alignItemsEnd]}
disabled={cameraPermissionStatus !== RESULTS.GRANTED}
onPress={() => setFlash((prevFlash) => !prevFlash)}
>
<Icon
height={32}
width={32}
src={Expensicons.Bolt}
fill={flash ? theme.iconHovered : theme.textSupporting}
/>
</PressableWithFeedback>
</View>
</StepScreenWrapper>
);
Expand Down
Loading