Aperture: Handle volume key long press for video mode
This allows us to start recording by holding volume button and then
stopping the recording by releasing it.
Change-Id: Ib693e7aa5307b8501bcff13800546507acb111b1
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 6f62cea..1280e9d 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -411,7 +411,7 @@
return when (keyCode) {
KeyEvent.KEYCODE_VOLUME_UP,
KeyEvent.KEYCODE_VOLUME_DOWN -> {
- if (shutterButton.isEnabled && event?.repeatCount == 0) {
+ if (cameraMode == CameraMode.VIDEO && shutterButton.isEnabled && event?.repeatCount == 1) {
shutterButton.performClick()
}
true
@@ -420,6 +420,19 @@
}
}
+ override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
+ return when (keyCode) {
+ KeyEvent.KEYCODE_VOLUME_UP,
+ KeyEvent.KEYCODE_VOLUME_DOWN -> {
+ if (cameraMode != CameraMode.QR && shutterButton.isEnabled) {
+ shutterButton.performClick()
+ }
+ true
+ }
+ else -> super.onKeyUp(keyCode, event)
+ }
+ }
+
private fun takePhoto() {
// Bail out if a photo is already being taken
if (isTakingPhoto) {