Remove restartPreview to fix black screen and shifted image
This commit is contained in:
1 parent
73f61d01e2
commit
5136266c11
7 files changed
+6
-40
No files matched your search
@@ -92,8 +92,8 @@ android {
|
||||
applicationId 'de.orfel.schnappix'
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 60
|
||||
versionName "23.01.60"
|
||||
versionCode 61
|
||||
versionName "23.01.61"
|
||||
|
||||
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"newArchEnabled": true,
|
||||
"name": "Schnappix",
|
||||
"slug": "Schnappix",
|
||||
"version": "23.01.60",
|
||||
"version": "23.01.61",
|
||||
"orientation": "landscape",
|
||||
"icon": "./Icon.png",
|
||||
"userInterfaceStyle": "dark",
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"android": {
|
||||
"package": "de.orfel.schnappix",
|
||||
"versionCode": 60,
|
||||
"versionCode": 61,
|
||||
"usesCleartextTraffic": true,
|
||||
"adaptiveIcon": {
|
||||
"backgroundColor": "#050510",
|
||||
|
||||
@@ -50,10 +50,6 @@ class UsbCameraModule : Module() {
|
||||
promise.resolve(view.isCameraConnected())
|
||||
}
|
||||
|
||||
AsyncFunction("restartPreview") { view: UsbCameraView, promise: Promise ->
|
||||
view.restartPreview()
|
||||
promise.resolve(true)
|
||||
}
|
||||
|
||||
OnViewDestroys { view ->
|
||||
view.onDestroy()
|
||||
|
||||
@@ -259,26 +259,6 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
return cameraClient?.isCameraOpened() ?: false
|
||||
}
|
||||
|
||||
fun restartPreview() {
|
||||
try {
|
||||
if (cameraClient != null) {
|
||||
cameraClient?.closeCamera()
|
||||
textureView.postDelayed({
|
||||
try {
|
||||
val safeContext = UsbContextWrapperJava(appContext.currentActivity ?: context)
|
||||
removeView(textureView)
|
||||
textureView = AspectRatioTextureView(safeContext)
|
||||
addView(textureView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
cameraClient?.openCamera(textureView)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 300)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
try {
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface UsbCameraViewProps extends ViewProps {
|
||||
export interface UsbCameraRef {
|
||||
takePicture(savePath: string): Promise<string>;
|
||||
isCameraConnected(): Promise<boolean>;
|
||||
restartPreview(): Promise<boolean>;
|
||||
|
||||
}
|
||||
|
||||
// Export the native view manager component
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "schnappix",
|
||||
"version": "23.01.60",
|
||||
"version": "23.01.61",
|
||||
"main": "index.ts",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
||||
|
||||
@@ -128,17 +128,7 @@ export default function CameraScreen({
|
||||
const isObscuredRef = useRef<boolean>(isObscured);
|
||||
|
||||
useEffect(() => {
|
||||
const wasObscured = isObscuredRef.current;
|
||||
isObscuredRef.current = isObscured;
|
||||
|
||||
// If we just became visible again (e.g. returning from PreviewScreen or AdminScreen)
|
||||
if (wasObscured && !isObscured) {
|
||||
if (usbCameraRef.current && !useFrontCamera) {
|
||||
usbCameraRef.current.restartPreview().catch(e => {
|
||||
logger.error('Failed to restart preview natively', e);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [isObscured, useFrontCamera]);
|
||||
|
||||
const { width } = useWindowDimensions();
|
||||
|
||||
Reference in new issue
Block a user