Auto-Commit: 2026-08-22 18:51:45
This commit is contained in:
1 parent
e3a94d132d
commit
c3ddb283dc
6 files changed
+50
-17
No files matched your search
@@ -92,8 +92,8 @@ android {
|
||||
applicationId 'de.orfel.schnappix'
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 54
|
||||
versionName "23.01.54"
|
||||
versionCode 55
|
||||
versionName "23.01.55"
|
||||
|
||||
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"newArchEnabled": true,
|
||||
"name": "Schnappix",
|
||||
"slug": "Schnappix",
|
||||
"version": "23.01.54",
|
||||
"version": "23.01.55",
|
||||
"orientation": "landscape",
|
||||
"icon": "./Icon.png",
|
||||
"userInterfaceStyle": "dark",
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"android": {
|
||||
"package": "de.orfel.schnappix",
|
||||
"versionCode": 54,
|
||||
"versionCode": 55,
|
||||
"usesCleartextTraffic": true,
|
||||
"adaptiveIcon": {
|
||||
"backgroundColor": "#050510",
|
||||
|
||||
@@ -45,6 +45,34 @@ class UsbContextWrapper(base: Context) : android.content.ContextWrapper(base), L
|
||||
super.registerReceiver(receiver, filter, broadcastPermission, scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerReceiver(
|
||||
receiver: android.content.BroadcastReceiver?,
|
||||
filter: android.content.IntentFilter?,
|
||||
flags: Int
|
||||
): android.content.Intent? {
|
||||
val newFlags = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
|
||||
flags or Context.RECEIVER_EXPORTED
|
||||
} else {
|
||||
flags
|
||||
}
|
||||
return super.registerReceiver(receiver, filter, newFlags)
|
||||
}
|
||||
|
||||
override fun registerReceiver(
|
||||
receiver: android.content.BroadcastReceiver?,
|
||||
filter: android.content.IntentFilter?,
|
||||
broadcastPermission: String?,
|
||||
scheduler: android.os.Handler?,
|
||||
flags: Int
|
||||
): android.content.Intent? {
|
||||
val newFlags = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
|
||||
flags or Context.RECEIVER_EXPORTED
|
||||
} else {
|
||||
flags
|
||||
}
|
||||
return super.registerReceiver(receiver, filter, broadcastPermission, scheduler, newFlags)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
@@ -60,7 +88,13 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
private var registeredContext: Context? = null
|
||||
|
||||
init {
|
||||
textureView = AspectRatioTextureView(context)
|
||||
val activityContext = appContext.currentActivity ?: context
|
||||
if (activityContext !is androidx.lifecycle.LifecycleOwner) {
|
||||
throw IllegalStateException("Cannot initialize UsbCameraView because activityContext is not a LifecycleOwner!")
|
||||
}
|
||||
val safeContext = UsbContextWrapper(activityContext)
|
||||
|
||||
textureView = AspectRatioTextureView(safeContext)
|
||||
addView(textureView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
|
||||
try {
|
||||
@@ -68,11 +102,6 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
.setFrontCamera(false)
|
||||
.create()
|
||||
|
||||
val activityContext = appContext.currentActivity ?: context
|
||||
if (activityContext !is androidx.lifecycle.LifecycleOwner) {
|
||||
throw IllegalStateException("Cannot initialize UsbCameraView because activityContext is not a LifecycleOwner!")
|
||||
}
|
||||
|
||||
// Explicitly request permission for any connected USB camera before starting ausbc
|
||||
try {
|
||||
val usbManager = context.getSystemService(Context.USB_SERVICE) as android.hardware.usb.UsbManager
|
||||
@@ -124,8 +153,6 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
activityContext.registerReceiver(permissionReceiver, filter)
|
||||
}
|
||||
|
||||
val safeContext = UsbContextWrapper(activityContext)
|
||||
|
||||
cameraClient = CameraClient.newBuilder(safeContext)
|
||||
.setCameraStrategy(CameraUvcStrategy(safeContext))
|
||||
.setCameraRequest(cameraRequest)
|
||||
@@ -227,7 +254,14 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
fun restartPreview() {
|
||||
try {
|
||||
if (cameraClient != null) {
|
||||
cameraClient?.openCamera(textureView)
|
||||
cameraClient?.closeCamera()
|
||||
textureView.postDelayed({
|
||||
try {
|
||||
cameraClient?.openCamera(textureView)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 300)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "schnappix",
|
||||
"version": "23.01.54",
|
||||
"version": "23.01.55",
|
||||
"main": "index.ts",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
||||
|
||||
@@ -8,7 +8,6 @@ const withLocalAars = (config) => {
|
||||
const dependencyBlock = `
|
||||
// Added by withLocalAars plugin
|
||||
implementation files("../../modules/usb-camera/android/libs/immersionbar-3.0.0.aar")
|
||||
implementation files("../../modules/usb-camera/android/libs/webpdecoder-1.6.4.9.0.aar")
|
||||
`;
|
||||
|
||||
if (!contents.includes('immersionbar-3.0.0.aar')) {
|
||||
|
||||
@@ -133,13 +133,13 @@ export default function CameraScreen({
|
||||
|
||||
// If we just became visible again (e.g. returning from PreviewScreen or AdminScreen)
|
||||
if (wasObscured && !isObscured) {
|
||||
if (usbCameraRef.current && isUsbConnected) {
|
||||
if (usbCameraRef.current && !useFrontCamera) {
|
||||
usbCameraRef.current.restartPreview().catch(e => {
|
||||
logger.error('Failed to restart preview natively', e);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [isObscured, isUsbConnected]);
|
||||
}, [isObscured, useFrontCamera]);
|
||||
|
||||
const { width } = useWindowDimensions();
|
||||
const iconSize = width < 768 ? 18 : 32;
|
||||
|
||||
Reference in new issue
Block a user