mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
handle 3rd party image/video capture intents
- in MediaOutputHelper, - add support for specifying the output URI if present in the intent - when the output URI is specified, - for Image Capture, we return a `Bitmap` as a `data` extra and also the URI as the Intent data - for Video Capture we return the `Uri` as the Intent data - if no output URI is specified in the capture intent or if there is an error while trying to access the URI, use the default location with MediaStore, so we do not return inconsistent URIs (eg, SAF tree URIs) - add CameraXInitializer to abstract CameraXPreview initialisation logic
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
package com.simplemobiletools.camera.implementations
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.camera.view.PreviewView
|
||||
import com.simplemobiletools.camera.helpers.CameraErrorHandler
|
||||
import com.simplemobiletools.camera.helpers.MediaOutputHelper
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
|
||||
class CameraXInitializer(private val activity: BaseSimpleActivity) {
|
||||
|
||||
fun createCameraXPreview(
|
||||
previewView: PreviewView,
|
||||
listener: CameraXPreviewListener,
|
||||
outputUri: Uri?,
|
||||
is3rdPartyIntent: Boolean,
|
||||
initInPhotoMode: Boolean,
|
||||
): CameraXPreview {
|
||||
val cameraErrorHandler = newCameraErrorHandler()
|
||||
val mediaOutputHelper = newMediaOutputHelper(cameraErrorHandler, outputUri, is3rdPartyIntent)
|
||||
return CameraXPreview(
|
||||
activity,
|
||||
previewView,
|
||||
mediaOutputHelper,
|
||||
cameraErrorHandler,
|
||||
listener,
|
||||
initInPhotoMode,
|
||||
)
|
||||
}
|
||||
|
||||
private fun newMediaOutputHelper(
|
||||
cameraErrorHandler: CameraErrorHandler,
|
||||
outputUri: Uri?,
|
||||
is3rdPartyIntent: Boolean,
|
||||
): MediaOutputHelper {
|
||||
return MediaOutputHelper(
|
||||
activity,
|
||||
cameraErrorHandler,
|
||||
outputUri,
|
||||
is3rdPartyIntent,
|
||||
)
|
||||
}
|
||||
|
||||
private fun newCameraErrorHandler(): CameraErrorHandler {
|
||||
return CameraErrorHandler(activity)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user