Aperture: Make video recording timer cancellable

Change-Id: I032ca694af199af11ebf0cd1ba5228fcfbb6b8f1
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 2c3bf35..c4e1b79 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -386,6 +386,10 @@
             when (cameraMode) {
                 CameraMode.PHOTO -> startShutterAnimation(ShutterAnimation.PhotoCapture)
                 CameraMode.VIDEO -> {
+                    if (countDownView.cancelCountDown()) {
+                        startShutterAnimation(ShutterAnimation.VideoEnd)
+                        return@setOnClickListener
+                    }
                     if (!cameraController.isRecording) {
                         startShutterAnimation(ShutterAnimation.VideoStart)
                     }
@@ -1256,7 +1260,7 @@
             runnable()
         }
 
-        shutterButton.isEnabled = false
+        shutterButton.isEnabled = cameraMode == CameraMode.VIDEO
 
         val rect = Rect().apply {
             viewFinder.getGlobalVisibleRect(this)
diff --git a/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt b/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
index 2a4b6c5..e13f162 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
@@ -113,12 +113,14 @@
     /**
      * Cancels the on-going countdown in the UI, if any.
      */
-    private fun cancelCountDown() {
+    fun cancelCountDown(): Boolean {
         if (remainingSeconds > 0) {
             remainingSeconds = 0
             handler.removeMessages(SET_TIMER_TEXT)
             isInvisible = true
+            return true
         }
+        return false
     }
 
     companion object {