From eb4e13af46c7b1e4132fa669a91209e08f3fb967 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Mon, 17 Apr 2023 18:50:46 +0200 Subject: [PATCH] Disable settings buttons during video recording --- .../sushi/hardcore/droidfs/CameraActivity.kt | 14 +++++++++-- app/src/main/res/layout/activity_camera.xml | 24 ++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt index 5cc8b19..7a38daf 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt @@ -14,6 +14,7 @@ import android.view.* import android.view.animation.Animation import android.view.animation.LinearInterpolator import android.view.animation.RotateAnimation +import android.widget.ImageButton import android.widget.ImageView import android.widget.RelativeLayout import android.widget.Toast @@ -533,21 +534,30 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { withAudioEnabled() } }?.start(executor) { + val buttons = arrayOf(binding.imageCaptureMode, binding.imageRatio, binding.imageTimer, binding.imageModeSwitch, binding.imageCameraSwitch) when (it) { is VideoRecordEvent.Start -> { binding.recordVideoButton.setImageResource(R.drawable.stop_recording_video_button) + for (i in buttons) { + i.isEnabled = false + i.alpha = 0.5F + } isRecording = true } is VideoRecordEvent.Finalize -> { if (it.hasError()) { it.cause?.printStackTrace() - Toast.makeText(applicationContext, it.cause?.message, Toast.LENGTH_SHORT).show() + Toast.makeText(applicationContext, it.cause?.message ?: ("Error: " + it.error), Toast.LENGTH_SHORT).show() videoRecording?.close() videoRecording = null } else { Toast.makeText(applicationContext, getString(R.string.video_save_success, path), Toast.LENGTH_SHORT).show() } binding.recordVideoButton.setImageResource(R.drawable.record_video_button) + for (i in buttons) { + i.isEnabled = true + i.alpha = 1F + } isRecording = false } } @@ -588,7 +598,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { orientedIcons.map { it.startAnimation(rotateAnimation) } previousOrientation = realOrientation imageCapture?.targetRotation = newOrientation - videoCapture?.setTargetRotation(newOrientation) + videoCapture?.targetRotation = newOrientation } } diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml index 731469c..d09157c 100644 --- a/app/src/main/res/layout/activity_camera.xml +++ b/app/src/main/res/layout/activity_camera.xml @@ -18,41 +18,49 @@ android:layout_height="40dp" android:layout_marginTop="20dp"> - - - - - @@ -104,11 +114,13 @@ -