show shutter animation along with sound

This commit is contained in:
darthpaul 2022-10-11 00:24:41 +01:00
parent 375bce1163
commit ac3044f52b
3 changed files with 7 additions and 2 deletions

View File

@ -432,8 +432,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
toggleBottomButtons(true)
change_resolution.isEnabled = true
mPreview?.tryTakePicture()
shutter_animation.alpha = 1.0f
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
} else {
mPreview?.toggleRecording()
}
@ -648,6 +646,11 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
}
override fun shutterAnimation() {
shutter_animation.alpha = 1.0f
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
}
override fun onMediaSaved(uri: Uri) {
change_resolution.isEnabled = true
loadLastTakenMedia(uri)

View File

@ -423,6 +423,7 @@ class CameraXPreview(
val mediaOutput = mediaOutputHelper.getImageMediaOutput()
imageCapture.takePicture(mainExecutor, object : OnImageCapturedCallback() {
override fun onCaptureSuccess(image: ImageProxy) {
listener.shutterAnimation()
playShutterSoundIfEnabled()
ensureBackgroundThread {
image.use {

View File

@ -10,6 +10,7 @@ interface CameraXPreviewListener {
fun setFlashAvailable(available: Boolean)
fun onChangeCamera(frontCamera: Boolean)
fun toggleBottomButtons(hide: Boolean)
fun shutterAnimation()
fun onMediaSaved(uri: Uri)
fun onImageCaptured(bitmap: Bitmap)
fun onChangeFlashMode(flashMode: Int)