mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
let the user know if the photo wasnt saved because he quit too early
This commit is contained in:
@ -61,6 +61,8 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
private var mIsFocusing = false
|
||||
private var autoFocusHandler = Handler()
|
||||
|
||||
var isWaitingForTakePictureCallback = false
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(activity: MainActivity, surfaceView: SurfaceView, previewListener: PreviewListener) : super(activity) {
|
||||
@ -275,6 +277,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
val selectedResolution = getSelectedResolution()
|
||||
mParameters!!.setPictureSize(selectedResolution.width, selectedResolution.height);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
mCamera!!.enableShutterSound(false)
|
||||
}
|
||||
|
||||
mRotationAtCapture = MainActivity.mLastHandledOrientation
|
||||
mCamera!!.parameters = mParameters
|
||||
isWaitingForTakePictureCallback = true
|
||||
mCamera!!.takePicture(null, null, takePictureCallback)
|
||||
|
||||
if (config.isSoundEnabled) {
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val volume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM)
|
||||
@ -283,20 +294,13 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
mp?.start()
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
mCamera!!.enableShutterSound(false)
|
||||
}
|
||||
|
||||
mRotationAtCapture = MainActivity.mLastHandledOrientation
|
||||
mCamera!!.parameters = mParameters
|
||||
mCamera!!.takePicture(null, null, takePictureCallback)
|
||||
}
|
||||
mCanTakePicture = false
|
||||
mIsFocusing = false
|
||||
}
|
||||
|
||||
private val takePictureCallback = Camera.PictureCallback { data, cam ->
|
||||
isWaitingForTakePictureCallback = false
|
||||
if (config.isShowPreviewEnabled) {
|
||||
mIsPreviewShown = true
|
||||
if (!config.wasPhotoPreviewHintShown) {
|
||||
|
@ -501,6 +501,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
||||
hideTimer()
|
||||
mPreview?.releaseCamera()
|
||||
mOrientationEventListener.disable()
|
||||
|
||||
if (mPreview?.isWaitingForTakePictureCallback == true) {
|
||||
toast(R.string.photo_not_saved)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupOrientationEventListener() {
|
||||
|
Reference in New Issue
Block a user