Aperture: Implement volume key shutter feature
This is necessaary to make Mi Band 7's "Camera Remote" feature to work.
Change-Id: I4431ccb3e944b15920484b5c2313109908fd02aa
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 3098a09..504fb63 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -27,6 +27,7 @@
import android.provider.MediaStore
import android.util.Log
import android.util.Size
+import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
@@ -391,6 +392,19 @@
}
}
+ override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
+ return when (keyCode) {
+ KeyEvent.KEYCODE_VOLUME_UP,
+ KeyEvent.KEYCODE_VOLUME_DOWN -> {
+ if (shutterButton.isEnabled) {
+ shutterButton.performClick()
+ }
+ true
+ }
+ else -> super.onKeyDown(keyCode, event)
+ }
+ }
+
private fun takePhoto() {
// Bail out if a photo is already being taken
if (isTakingPhoto) {