Skip to content

Commit

Permalink
Update camerax to 1.3.4 and fix the API change, which deprecates setT…
Browse files Browse the repository at this point in the history
…argetSolution
  • Loading branch information
notandyvee committed Jun 18, 2024
1 parent d6f3777 commit bb50a7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
import androidx.camera.core.ImageProxy
import androidx.camera.core.resolutionselector.AspectRatioStrategy
import androidx.camera.core.resolutionselector.ResolutionSelector
import androidx.camera.core.resolutionselector.ResolutionStrategy
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -41,12 +44,18 @@ fun BarcodeScanner(
val preview = CameraPreview.Builder().build()
preview.setSurfaceProvider(previewView.surfaceProvider)
val selector = CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build()
val imageAnalysis = ImageAnalysis.Builder().setTargetResolution(
Size(
previewView.width,
previewView.height
)
)
val imageAnalysis = ImageAnalysis.Builder()
.setResolutionSelector(ResolutionSelector.Builder()
.setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY)
.setResolutionStrategy(
ResolutionStrategy(
Size(
previewView.width,
previewView.height
),
ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER
)
).build())
.setBackpressureStrategy(STRATEGY_KEEP_ONLY_LATEST)
.build()
imageAnalysis.setAnalyzer(ContextCompat.getMainExecutor(context)) { imageProxy ->
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ext {
androidxAnnotationVersion = '1.6.0'
androidxAppcompatVersion = '1.6.1'
androidxArchCoreVersion = '2.2.0'
androidxCameraVersion = '1.2.3'
androidxCameraVersion = '1.3.4'
androidxComposeBomVersion = '2023.10.00'
androidxComposeCompilerVersion = '1.5.9'
androidxComposeNavigationVersion = '2.7.6'
Expand Down

0 comments on commit bb50a7b

Please sign in to comment.