mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-17 03:40:38 +01:00
remove a few more direct variable calls at PreviewCameraOne
This commit is contained in:
parent
e529bdd15c
commit
3bc54c2e5f
@ -171,14 +171,14 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||||||
hideToggleModeAbout()
|
hideToggleModeAbout()
|
||||||
val output = intent.extras?.get(MediaStore.EXTRA_OUTPUT)
|
val output = intent.extras?.get(MediaStore.EXTRA_OUTPUT)
|
||||||
if (output != null && output is Uri) {
|
if (output != null && output is Uri) {
|
||||||
mPreview?.mTargetUri = output
|
mPreview?.setTargetUri(output)
|
||||||
}
|
}
|
||||||
} else if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
|
} else if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
|
||||||
mIsVideoCaptureIntent = true
|
mIsVideoCaptureIntent = true
|
||||||
hideToggleModeAbout()
|
hideToggleModeAbout()
|
||||||
shutter.setImageResource(R.drawable.ic_video_rec)
|
shutter.setImageResource(R.drawable.ic_video_rec)
|
||||||
}
|
}
|
||||||
mPreview?.isImageCaptureIntent = isImageCaptureIntent()
|
mPreview?.setIsImageCaptureIntent(isImageCaptureIntent())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isImageCaptureIntent() = intent?.action == MediaStore.ACTION_IMAGE_CAPTURE || intent?.action == MediaStore.ACTION_IMAGE_CAPTURE_SECURE
|
private fun isImageCaptureIntent() = intent?.action == MediaStore.ACTION_IMAGE_CAPTURE || intent?.action == MediaStore.ACTION_IMAGE_CAPTURE_SECURE
|
||||||
|
@ -32,7 +32,6 @@ import java.io.IOException
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||||
private var mCamera: Camera? = null
|
|
||||||
private val FOCUS_AREA_SIZE = 100
|
private val FOCUS_AREA_SIZE = 100
|
||||||
private val PHOTO_PREVIEW_LENGTH = 500L
|
private val PHOTO_PREVIEW_LENGTH = 500L
|
||||||
private val REFOCUS_PERIOD = 3000L
|
private val REFOCUS_PERIOD = 3000L
|
||||||
@ -49,7 +48,11 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
private var mScaleGestureDetector: ScaleGestureDetector? = null
|
private var mScaleGestureDetector: ScaleGestureDetector? = null
|
||||||
private var mZoomRatios = ArrayList<Int>()
|
private var mZoomRatios = ArrayList<Int>()
|
||||||
private var mFlashlightState = FLASH_OFF
|
private var mFlashlightState = FLASH_OFF
|
||||||
|
private var mCamera: Camera? = null
|
||||||
private var mCameraImpl: MyCameraOneImpl? = null
|
private var mCameraImpl: MyCameraOneImpl? = null
|
||||||
|
private var mAutoFocusHandler = Handler()
|
||||||
|
private var mActivity: MainActivity? = null
|
||||||
|
private var mTargetUri: Uri? = null
|
||||||
private var mCameraState = STATE_PREVIEW
|
private var mCameraState = STATE_PREVIEW
|
||||||
|
|
||||||
private var mCurrVideoPath = ""
|
private var mCurrVideoPath = ""
|
||||||
@ -63,17 +66,13 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
private var mWasZooming = false
|
private var mWasZooming = false
|
||||||
private var mIsPreviewShown = false
|
private var mIsPreviewShown = false
|
||||||
private var mWasCameraPreviewSet = false
|
private var mWasCameraPreviewSet = false
|
||||||
|
private var mIsImageCaptureIntent = false
|
||||||
|
private var mIsFocusingBeforeCapture = false
|
||||||
private var mLastClickX = 0f
|
private var mLastClickX = 0f
|
||||||
private var mLastClickY = 0f
|
private var mLastClickY = 0f
|
||||||
private var mCurrCameraId = 0
|
private var mCurrCameraId = 0
|
||||||
private var mMaxZoom = 0
|
private var mMaxZoom = 0
|
||||||
private var mRotationAtCapture = 0
|
private var mRotationAtCapture = 0
|
||||||
private var mIsFocusingBeforeCapture = false
|
|
||||||
private var autoFocusHandler = Handler()
|
|
||||||
private var mActivity: MainActivity? = null
|
|
||||||
|
|
||||||
var mTargetUri: Uri? = null
|
|
||||||
var isImageCaptureIntent = false
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context)
|
constructor(context: Context) : super(context)
|
||||||
|
|
||||||
@ -86,11 +85,6 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
mSurfaceHolder.addCallback(this)
|
mSurfaceHolder.addCallback(this)
|
||||||
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS)
|
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS)
|
||||||
mCameraImpl = MyCameraOneImpl(activity.applicationContext)
|
mCameraImpl = MyCameraOneImpl(activity.applicationContext)
|
||||||
mCanTakePicture = false
|
|
||||||
mIsInVideoMode = false
|
|
||||||
mIsSurfaceCreated = false
|
|
||||||
mSetupPreviewAfterMeasure = false
|
|
||||||
mCurrVideoPath = ""
|
|
||||||
mConfig = activity.config
|
mConfig = activity.config
|
||||||
mScreenSize = getScreenSize()
|
mScreenSize = getScreenSize()
|
||||||
initGestureDetector()
|
initGestureDetector()
|
||||||
@ -363,11 +357,11 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCameraState = STATE_PREVIEW
|
mCameraState = STATE_PREVIEW
|
||||||
if (!isImageCaptureIntent) {
|
if (!mIsImageCaptureIntent) {
|
||||||
handlePreview()
|
handlePreview()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImageCaptureIntent) {
|
if (mIsImageCaptureIntent) {
|
||||||
if (mTargetUri != null) {
|
if (mTargetUri != null) {
|
||||||
storePhoto(data)
|
storePhoto(data)
|
||||||
} else {
|
} else {
|
||||||
@ -481,8 +475,8 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun rescheduleAutofocus() {
|
private fun rescheduleAutofocus() {
|
||||||
autoFocusHandler.removeCallbacksAndMessages(null)
|
mAutoFocusHandler.removeCallbacksAndMessages(null)
|
||||||
autoFocusHandler.postDelayed({
|
mAutoFocusHandler.postDelayed({
|
||||||
if (!mIsInVideoMode || !mIsRecording) {
|
if (!mIsInVideoMode || !mIsRecording) {
|
||||||
focusArea(false, false)
|
focusArea(false, false)
|
||||||
}
|
}
|
||||||
@ -779,6 +773,14 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setTargetUri(uri: Uri) {
|
||||||
|
mTargetUri = uri
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setIsImageCaptureIntent(isImageCaptureIntent: Boolean) {
|
||||||
|
mIsImageCaptureIntent = isImageCaptureIntent
|
||||||
|
}
|
||||||
|
|
||||||
fun toggleRecording(): Boolean {
|
fun toggleRecording(): Boolean {
|
||||||
if (mIsRecording) {
|
if (mIsRecording) {
|
||||||
stopRecording()
|
stopRecording()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user