Add radial mode, UI controls, front camera, update to API 35
- Add radial/elliptical blur mode with aspect ratio control - Add UI sliders for blur intensity, falloff, and shape - Add front camera support with flip button - Update minimum SDK to API 35 (Android 15) - Enable landscape orientation (fullSensor) - Rename app to "Naiv Tilt Shift Camera" - Set APK output name to naiv-tilt-shift - Add project specification document Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e8a5fa4811
commit
d3ca23b71c
11 changed files with 679 additions and 94 deletions
|
|
@ -41,8 +41,12 @@ class CameraManager(private val context: Context) {
|
|||
private val _maxZoomRatio = MutableStateFlow(1.0f)
|
||||
val maxZoomRatio: StateFlow<Float> = _maxZoomRatio.asStateFlow()
|
||||
|
||||
private val _isFrontCamera = MutableStateFlow(false)
|
||||
val isFrontCamera: StateFlow<Boolean> = _isFrontCamera.asStateFlow()
|
||||
|
||||
private var surfaceTextureProvider: (() -> SurfaceTexture?)? = null
|
||||
private var surfaceSize: Size = Size(1920, 1080)
|
||||
private var lifecycleOwnerRef: LifecycleOwner? = null
|
||||
|
||||
/**
|
||||
* Starts the camera with the given lifecycle owner.
|
||||
|
|
@ -53,6 +57,7 @@ class CameraManager(private val context: Context) {
|
|||
surfaceTextureProvider: () -> SurfaceTexture?
|
||||
) {
|
||||
this.surfaceTextureProvider = surfaceTextureProvider
|
||||
this.lifecycleOwnerRef = lifecycleOwner
|
||||
|
||||
val cameraProviderFuture = ProcessCameraProvider.getInstance(context)
|
||||
cameraProviderFuture.addListener({
|
||||
|
|
@ -82,9 +87,13 @@ class CameraManager(private val context: Context) {
|
|||
.setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)
|
||||
.build()
|
||||
|
||||
// Get camera selector from lens controller
|
||||
val cameraSelector = lensController.getCurrentLens()?.selector
|
||||
?: CameraSelector.DEFAULT_BACK_CAMERA
|
||||
// Select camera based on front/back preference
|
||||
val cameraSelector = if (_isFrontCamera.value) {
|
||||
CameraSelector.DEFAULT_FRONT_CAMERA
|
||||
} else {
|
||||
// Use lens controller for back camera lens selection
|
||||
lensController.getCurrentLens()?.selector ?: CameraSelector.DEFAULT_BACK_CAMERA
|
||||
}
|
||||
|
||||
try {
|
||||
// Bind use cases to camera
|
||||
|
|
@ -146,10 +155,19 @@ class CameraManager(private val context: Context) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Switches to a different lens.
|
||||
* Switches between front and back camera.
|
||||
*/
|
||||
fun switchCamera() {
|
||||
_isFrontCamera.value = !_isFrontCamera.value
|
||||
_zoomRatio.value = 1.0f // Reset zoom when switching
|
||||
lifecycleOwnerRef?.let { bindCameraUseCases(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to a different lens (back camera only).
|
||||
*/
|
||||
fun switchLens(lensId: String, lifecycleOwner: LifecycleOwner) {
|
||||
if (lensController.selectLens(lensId)) {
|
||||
if (!_isFrontCamera.value && lensController.selectLens(lensId)) {
|
||||
bindCameraUseCases(lifecycleOwner)
|
||||
}
|
||||
}
|
||||
|
|
@ -169,5 +187,6 @@ class CameraManager(private val context: Context) {
|
|||
camera = null
|
||||
preview = null
|
||||
imageCapture = null
|
||||
lifecycleOwnerRef = null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue