@momo-kits/camerakit 0.163.1-beta.3 → 0.163.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(./gradlew :react-native-camera-kit:compileDebugKotlin --offline)",
|
|
5
|
+
"Bash(gradle --version)",
|
|
6
|
+
"Bash(unzip -p /Users/sophia/Workspace/momo/momo-kits/android/gradle/wrapper/gradle-wrapper.jar META-INF/MANIFEST.MF)",
|
|
7
|
+
"Bash(unzip -p /Users/sophia/Workspace/momo/momo-kits/packages/react-native-camera-kit/android/gradle/wrapper/gradle-wrapper.jar META-INF/MANIFEST.MF)",
|
|
8
|
+
"Bash(java -version)",
|
|
9
|
+
"Bash(unzip -l /Users/sophia/Workspace/momo/momo-kits/android/gradle/wrapper/gradle-wrapper.jar)",
|
|
10
|
+
"Bash(java -classpath gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain :react-native-camera-kit:compileDebugKotlin)",
|
|
11
|
+
"Bash(java -classpath gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain -I /private/tmp/claude-503/-Users-sophia-Workspace-momo-momo-kits-packages-react-native-camera-kit/cdde22e6-fd1c-4745-a90e-3d8987357568/scratchpad/inject-sdk.gradle :react-native-camera-kit:compileDebugKotlin)",
|
|
12
|
+
"Bash(PATH=/Users/sophia/.nvm/versions/node/v24.15.0/bin:__TRACKED_VAR__ java -classpath gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain -I /private/tmp/claude-503/-Users-sophia-Workspace-momo-momo-kits-packages-react-native-camera-kit/cdde22e6-fd1c-4745-a90e-3d8987357568/scratchpad/inject-sdk.gradle :react-native-camera-kit:compileDebugKotlin)",
|
|
13
|
+
"Bash(awk '/What went wrong/{f=1} f{print} /BUILD FAILED/{exit}' /private/tmp/claude-503/-Users-sophia-Workspace-momo-momo-kits-packages-react-native-camera-kit/cdde22e6-fd1c-4745-a90e-3d8987357568/tasks/bl46msqcx.output)",
|
|
14
|
+
"Bash(node -e \"console.log\\(require\\('/Users/sophia/Workspace/momo/momo-kits/node_modules/react-native/package.json'\\).version\\)\")"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -143,8 +143,8 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
143
143
|
private var scanText: Boolean = false
|
|
144
144
|
private var useMLKit: Boolean = GoogleApiAvailability().isGooglePlayServicesAvailable(context) == 0
|
|
145
145
|
|
|
146
|
-
private fun getActivity() : Activity {
|
|
147
|
-
return currentContext.currentActivity
|
|
146
|
+
private fun getActivity() : Activity? {
|
|
147
|
+
return currentContext.currentActivity
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
init {
|
|
@@ -219,7 +219,12 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
219
219
|
/** Initialize CameraX, and prepare to bind the camera use cases */
|
|
220
220
|
@SuppressLint("ClickableViewAccessibility")
|
|
221
221
|
private fun setupCamera() {
|
|
222
|
-
val
|
|
222
|
+
val activity = getActivity() ?: run {
|
|
223
|
+
Log.w(TAG, "setupCamera: no current activity, skipping")
|
|
224
|
+
isStarting = false
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
val cameraProviderFuture = ProcessCameraProvider.getInstance(activity)
|
|
223
228
|
cameraProviderFuture.addListener({
|
|
224
229
|
// Used to bind the lifecycle of cameras to the lifecycle owner
|
|
225
230
|
cameraProvider = cameraProviderFuture.get()
|
|
@@ -291,7 +296,7 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
291
296
|
isNeedStop = false
|
|
292
297
|
stopCamera()
|
|
293
298
|
}
|
|
294
|
-
}, ContextCompat.getMainExecutor(
|
|
299
|
+
}, ContextCompat.getMainExecutor(activity))
|
|
295
300
|
}
|
|
296
301
|
|
|
297
302
|
private fun setZoomFor(videoDevice: Camera, zoom: Double) {
|
|
@@ -418,7 +423,9 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
418
423
|
try {
|
|
419
424
|
// A variable number of use-cases can be passed here -
|
|
420
425
|
// camera provides access to CameraControl & CameraInfo
|
|
421
|
-
val
|
|
426
|
+
val activity = getActivity() as? AppCompatActivity
|
|
427
|
+
?: throw IllegalStateException("No AppCompatActivity available to bind camera lifecycle")
|
|
428
|
+
val newCamera = cameraProvider.bindToLifecycle(activity, cameraSelector, *useCases.toTypedArray())
|
|
422
429
|
camera = newCamera
|
|
423
430
|
|
|
424
431
|
resetZoom(newCamera)
|
|
@@ -477,6 +484,10 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
477
484
|
}
|
|
478
485
|
|
|
479
486
|
open fun capture(options: Map<String, Any>, promise: Promise) {
|
|
487
|
+
val activity = getActivity() ?: run {
|
|
488
|
+
promise.reject("E_CAPTURE_FAILED", "No current activity")
|
|
489
|
+
return
|
|
490
|
+
}
|
|
480
491
|
// Create the output file option to store the captured image in MediaStore
|
|
481
492
|
val outputPath: String = when {
|
|
482
493
|
outputPath != null -> outputPath!!
|
|
@@ -495,15 +506,15 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
495
506
|
flashViewFinder()
|
|
496
507
|
|
|
497
508
|
if (shutterPhotoSound) {
|
|
498
|
-
val audio =
|
|
499
|
-
if (audio
|
|
509
|
+
val audio = activity.getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
|
510
|
+
if (audio?.ringerMode == AudioManager.RINGER_MODE_NORMAL) {
|
|
500
511
|
MediaActionSound().play(MediaActionSound.SHUTTER_CLICK)
|
|
501
512
|
}
|
|
502
513
|
}
|
|
503
514
|
|
|
504
515
|
// Setup image capture listener which is triggered after photo has been taken
|
|
505
516
|
imageCapture?.takePicture(
|
|
506
|
-
outputOptions, ContextCompat.getMainExecutor(
|
|
517
|
+
outputOptions, ContextCompat.getMainExecutor(activity), object : ImageCapture.OnImageSavedCallback {
|
|
507
518
|
override fun onError(ex: ImageCaptureException) {
|
|
508
519
|
Log.e(TAG, "CameraView: Photo capture failed: ${ex.message}", ex)
|
|
509
520
|
promise.reject("E_CAPTURE_FAILED", "takePicture failed: ${ex.message}")
|
|
@@ -879,11 +890,13 @@ open class CKCamera(context: ThemedReactContext) : FrameLayout(context), Lifecyc
|
|
|
879
890
|
}) {
|
|
880
891
|
return true
|
|
881
892
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
893
|
+
getActivity()?.let {
|
|
894
|
+
ActivityCompat.requestPermissions(
|
|
895
|
+
it,
|
|
896
|
+
requiredPermissions,
|
|
897
|
+
42 // random callback identifier
|
|
898
|
+
)
|
|
899
|
+
}
|
|
887
900
|
return false
|
|
888
901
|
}
|
|
889
902
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.rncamerakit
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.facebook.react.bridge.*
|
|
4
5
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
5
6
|
|
|
@@ -66,8 +67,11 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
|
|
|
66
67
|
if (viewTag != null ) {
|
|
67
68
|
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactContext, viewTag)
|
|
68
69
|
reactContext.runOnUiQueueThread {
|
|
69
|
-
val camera = uiManager?.resolveView(viewTag) as CKCamera
|
|
70
|
-
|
|
70
|
+
val camera = uiManager?.resolveView(viewTag) as? CKCamera
|
|
71
|
+
if (camera == null) {
|
|
72
|
+
Log.w(REACT_CLASS, "startCamera: view $viewTag no longer resolves to a CKCamera")
|
|
73
|
+
return@runOnUiQueueThread
|
|
74
|
+
}
|
|
71
75
|
camera.startCamera()
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -79,8 +83,11 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
|
|
|
79
83
|
if (viewTag != null ) {
|
|
80
84
|
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactContext, viewTag)
|
|
81
85
|
reactContext.runOnUiQueueThread {
|
|
82
|
-
val camera = uiManager?.resolveView(viewTag) as CKCamera
|
|
83
|
-
|
|
86
|
+
val camera = uiManager?.resolveView(viewTag) as? CKCamera
|
|
87
|
+
if (camera == null) {
|
|
88
|
+
Log.w(REACT_CLASS, "stopCamera: view $viewTag no longer resolves to a CKCamera")
|
|
89
|
+
return@runOnUiQueueThread
|
|
90
|
+
}
|
|
84
91
|
camera.stopCamera()
|
|
85
92
|
}
|
|
86
93
|
}
|
|
@@ -92,8 +99,11 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
|
|
|
92
99
|
if (viewTag != null ) {
|
|
93
100
|
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactContext, viewTag)
|
|
94
101
|
reactContext.runOnUiQueueThread {
|
|
95
|
-
val camera = uiManager?.resolveView(viewTag) as CKCamera
|
|
96
|
-
|
|
102
|
+
val camera = uiManager?.resolveView(viewTag) as? CKCamera
|
|
103
|
+
if (camera == null) {
|
|
104
|
+
Log.w(REACT_CLASS, "readImageQRCode: view $viewTag no longer resolves to a CKCamera")
|
|
105
|
+
return@runOnUiQueueThread
|
|
106
|
+
}
|
|
97
107
|
if (data != null) {
|
|
98
108
|
camera.readImageQRCode(data)
|
|
99
109
|
}
|
|
@@ -114,7 +124,11 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
|
|
|
114
124
|
if (viewTag != null && options != null) {
|
|
115
125
|
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactContext, viewTag)
|
|
116
126
|
reactContext.runOnUiQueueThread {
|
|
117
|
-
val camera = uiManager?.resolveView(viewTag) as CKCamera
|
|
127
|
+
val camera = uiManager?.resolveView(viewTag) as? CKCamera
|
|
128
|
+
if (camera == null) {
|
|
129
|
+
promise.reject("E_CAPTURE_FAILED", "view $viewTag no longer resolves to a CKCamera")
|
|
130
|
+
return@runOnUiQueueThread
|
|
131
|
+
}
|
|
118
132
|
val optionsMap = options.toHashMap()
|
|
119
133
|
.mapValues { (_, value) ->
|
|
120
134
|
when (value) {
|