implement the "Focus before capture" functionality

This commit is contained in:
tibbi 2017-05-07 11:55:17 +02:00
parent 6ffea6c542
commit c608407fc1
2 changed files with 10 additions and 2 deletions

View File

@ -256,7 +256,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
}) })
} }
fun takePicture() { fun tryTakePicture() {
if (config.focusBeforeCapture) {
focusArea(true)
} else {
takePicture()
}
}
private fun takePicture() {
if (mCanTakePicture) { if (mCanTakePicture) {
val selectedResolution = getSelectedResolution() val selectedResolution = getSelectedResolution()
mParameters!!.setPictureSize(selectedResolution.width, selectedResolution.height); mParameters!!.setPictureSize(selectedResolution.width, selectedResolution.height);

View File

@ -269,7 +269,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
private fun handleShutter() { private fun handleShutter() {
if (mIsInPhotoMode) { if (mIsInPhotoMode) {
toggleBottomButtons(true) toggleBottomButtons(true)
mPreview?.takePicture() mPreview?.tryTakePicture()
Handler().postDelayed({ Handler().postDelayed({
toggleBottomButtons(false) toggleBottomButtons(false)
}, Preview.PHOTO_PREVIEW_LENGTH) }, Preview.PHOTO_PREVIEW_LENGTH)