Upgrade CameraX to 1.1.0-alpha04 (#128)

* Upgrade CameraX to 1.1.0-alpha4

* Upgrade Kotlin to 1.4.32

* Suppress `UnsafeOptInUsageError` CameraSelector override

* Suppress `UnsafeOptInUsageError` for takePhoto

* Suppress `MissingPermission` for recordVideo

* Remove unreported lint suppressions
This commit is contained in:
Marc Rousavy 2021-04-26 12:56:36 +02:00 committed by GitHub
parent 5e2e9b6912
commit f2a89570c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 11 deletions

View File

@ -135,10 +135,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.4.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3"
implementation "androidx.camera:camera-core:1.1.0-alpha03"
implementation "androidx.camera:camera-camera2:1.1.0-alpha03"
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha03"
implementation "androidx.camera:camera-extensions:1.0.0-alpha23"
implementation "androidx.camera:camera-view:1.0.0-alpha23"
implementation "androidx.camera:camera-core:1.1.0-alpha04"
implementation "androidx.camera:camera-camera2:1.1.0-alpha04"
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha04"
implementation "androidx.camera:camera-extensions:1.0.0-alpha24"
implementation "androidx.camera:camera-view:1.0.0-alpha24"
implementation "androidx.exifinterface:exifinterface:1.3.2"
}

View File

@ -13,7 +13,7 @@
#Fri Feb 19 20:46:14 CET 2021
VisionCamera_buildToolsVersion=30.0.0
VisionCamera_compileSdkVersion=30
VisionCamera_kotlinVersion=1.4.31
VisionCamera_kotlinVersion=1.4.32
VisionCamera_targetSdkVersion=30
android.enableJetifier=true
android.useAndroidX=true

View File

@ -1,7 +1,10 @@
package com.mrousavy.camera
import android.Manifest
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import androidx.camera.core.VideoCapture
import androidx.core.content.ContextCompat
import com.facebook.react.bridge.*
import com.mrousavy.camera.utils.makeErrorMap
import kotlinx.coroutines.*
@ -9,11 +12,15 @@ import java.io.File
data class TemporaryFile(val path: String)
@SuppressLint("RestrictedApi")
@SuppressLint("RestrictedApi", "MissingPermission")
suspend fun CameraView.startRecording(options: ReadableMap, onRecordCallback: Callback): TemporaryFile {
if (videoCapture == null) {
throw CameraNotReadyError()
}
if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
throw MicrophonePermissionError()
}
if (options.hasKey("flash")) {
val enableFlash = options.getString("flash") == "on"
// overrides current torch mode value to enable flash while recording

View File

@ -16,7 +16,7 @@ import java.io.File
private const val TAG = "CameraView.performance"
@SuppressLint("UnsafeExperimentalUsageError")
@SuppressLint("UnsafeOptInUsageError")
suspend fun CameraView.takePhoto(options: ReadableMap): WritableMap = coroutineScope {
val startFunc = System.nanoTime()
Log.d(CameraView.REACT_CLASS, "takePhoto() called")

View File

@ -212,7 +212,7 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
/**
* Configures the camera capture session. This should only be called when the camera device changes.
*/
@SuppressLint("UnsafeExperimentalUsageError", "RestrictedApi")
@SuppressLint("RestrictedApi")
private suspend fun configureSession() {
try {
val startTime = System.currentTimeMillis()

View File

@ -8,7 +8,7 @@ import java.lang.IllegalArgumentException
/**
* Create a new [CameraSelector] which selects the camera with the given [cameraId]
*/
@SuppressLint("UnsafeExperimentalUsageError")
@SuppressLint("UnsafeOptInUsageError")
fun CameraSelector.Builder.byID(cameraId: String): CameraSelector.Builder {
return this.addCameraFilter { cameras ->
cameras.filter { cameraInfoX ->

View File

@ -33,7 +33,6 @@ fun flip(imageBytes: ByteArray, imageWidth: Int): ByteArray {
return holder + subArray
}
@SuppressLint("UnsafeExperimentalUsageError")
fun ImageProxy.save(file: File, flipHorizontally: Boolean) {
when (format) {
// TODO: ImageFormat.RAW_SENSOR