|
1 | 1 | package app.grapheneos.camera.ui
|
2 | 2 |
|
| 3 | +import android.Manifest |
3 | 4 | import android.animation.ArgbEvaluator
|
4 | 5 | import android.animation.ValueAnimator
|
5 | 6 | import android.app.Dialog
|
| 7 | +import android.content.pm.PackageManager |
6 | 8 | import android.graphics.Color
|
7 | 9 | import android.hardware.camera2.CameraCharacteristics
|
8 | 10 | import android.hardware.camera2.CameraMetadata
|
@@ -36,6 +38,7 @@ import androidx.camera.core.DynamicRange
|
36 | 38 | import androidx.camera.core.ImageCapture
|
37 | 39 | import androidx.camera.video.Quality
|
38 | 40 | import androidx.camera.video.Recorder
|
| 41 | +import androidx.core.app.ActivityCompat |
39 | 42 | import app.grapheneos.camera.CamConfig
|
40 | 43 | import app.grapheneos.camera.R
|
41 | 44 | import app.grapheneos.camera.databinding.SettingsBinding
|
@@ -324,6 +327,31 @@ class SettingsDialog(val mActivity: MainActivity) :
|
324 | 327 |
|
325 | 328 | includeAudioToggle = binding.includeAudioSwitch
|
326 | 329 | includeAudioToggle.setOnClickListener {
|
| 330 | + if (mActivity.videoCapturer.isRecording) { |
| 331 | + if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.RECORD_AUDIO) |
| 332 | + != PackageManager.PERMISSION_GRANTED) { |
| 333 | + |
| 334 | + // Inform the user why enabling this option isn't possible |
| 335 | + mActivity.showMessage("Unable to request for audio permission in between a recording") |
| 336 | + |
| 337 | + // Ensure the option is visually off |
| 338 | + includeAudioToggle.isChecked = false |
| 339 | + return@setOnClickListener |
| 340 | + } |
| 341 | + |
| 342 | + if (includeAudioToggle.isChecked) { |
| 343 | + mActivity.videoCapturer.unmuteRecording() |
| 344 | + } else { |
| 345 | + mActivity.videoCapturer.muteRecording() |
| 346 | + } |
| 347 | + } |
| 348 | + |
| 349 | + mActivity.micOffIcon.visibility = if (includeAudioToggle.isChecked) { |
| 350 | + View.GONE |
| 351 | + } else { |
| 352 | + View.VISIBLE |
| 353 | + } |
| 354 | + |
327 | 355 | camConfig.includeAudio = includeAudioToggle.isChecked
|
328 | 356 | }
|
329 | 357 |
|
|
0 commit comments