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