mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-16 19:30:40 +01:00
adding some initial camera states
This commit is contained in:
parent
a52716a3a5
commit
e529bdd15c
@ -97,7 +97,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
||||
mPreview?.releaseCamera()
|
||||
mOrientationEventListener.disable()
|
||||
|
||||
if (mPreview?.isWaitingForTakePictureCallback == true) {
|
||||
if (mPreview?.getCameraState() == STATE_PICTURE_TAKEN) {
|
||||
toast(R.string.photo_not_saved)
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
||||
|
||||
private fun toggleCamera() {
|
||||
if (checkCameraAvailable()) {
|
||||
mPreview!!.toggleCamera()
|
||||
mPreview!!.toggleFrontBackCamera()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,3 +27,7 @@ const val PHOTO_QUALITY = "photo_quality"
|
||||
const val FLASH_OFF = 0
|
||||
const val FLASH_ON = 1
|
||||
const val FLASH_AUTO = 2
|
||||
|
||||
// camera states
|
||||
const val STATE_PREVIEW = 0
|
||||
const val STATE_PICTURE_TAKEN = 1
|
||||
|
@ -50,6 +50,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
private var mZoomRatios = ArrayList<Int>()
|
||||
private var mFlashlightState = FLASH_OFF
|
||||
private var mCameraImpl: MyCameraOneImpl? = null
|
||||
private var mCameraState = STATE_PREVIEW
|
||||
|
||||
private var mCurrVideoPath = ""
|
||||
private var mCanTakePicture = false
|
||||
@ -71,7 +72,6 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
private var autoFocusHandler = Handler()
|
||||
private var mActivity: MainActivity? = null
|
||||
|
||||
var isWaitingForTakePictureCallback = false
|
||||
var mTargetUri: Uri? = null
|
||||
var isImageCaptureIntent = false
|
||||
|
||||
@ -195,7 +195,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
return true
|
||||
}
|
||||
|
||||
fun toggleCamera() {
|
||||
fun toggleFrontBackCamera() {
|
||||
mCurrCameraId = if (mCurrCameraId == mCameraImpl!!.getBackCameraId()) {
|
||||
mCameraImpl!!.getFrontCameraId()
|
||||
} else {
|
||||
@ -213,6 +213,8 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
fun getCameraState() = mCameraState
|
||||
|
||||
private fun refreshPreview() {
|
||||
mIsSixteenToNine = getSelectedResolution().isSixteenToNine()
|
||||
mSetupPreviewAfterMeasure = true
|
||||
@ -332,7 +334,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
|
||||
mRotationAtCapture = mActivity!!.mLastHandledOrientation
|
||||
updateCameraParameters()
|
||||
isWaitingForTakePictureCallback = true
|
||||
mCameraState = STATE_PICTURE_TAKEN
|
||||
mIsPreviewShown = true
|
||||
try {
|
||||
Thread {
|
||||
@ -360,7 +362,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback {
|
||||
return@PictureCallback
|
||||
}
|
||||
|
||||
isWaitingForTakePictureCallback = false
|
||||
mCameraState = STATE_PREVIEW
|
||||
if (!isImageCaptureIntent) {
|
||||
handlePreview()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user