From d7c4c76640edbe2b0ce953d7ce5ce8fcd266a409 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 8 Jun 2018 14:11:43 +0200 Subject: [PATCH] avoid launching multiple shutter actions at pressing volumes --- .../com/simplemobiletools/camera/activities/MainActivity.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index b61d262e..ec8a82ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -128,7 +128,8 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener { mIsHardwareShutterHandled = true shutterPressed() true - } else if (config.volumeButtonsAsShutter && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { + } else if (!mIsHardwareShutterHandled && config.volumeButtonsAsShutter && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { + mIsHardwareShutterHandled = true shutterPressed() true } else { @@ -137,7 +138,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener { } override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { - if (keyCode == KeyEvent.KEYCODE_CAMERA) { + if (keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mIsHardwareShutterHandled = false } return super.onKeyUp(keyCode, event)