Skip to content

Commit 4824d71

Browse files
committed
Fix issue with recorder not working after audio permission
1 parent f106094 commit 4824d71

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/src/main/java/app/grapheneos/camera/ui/activities/MainActivity.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ open class MainActivity : AppCompatActivity(),
235235

236236
lateinit var micOffIcon: ImageView
237237

238+
private var shouldRestartRecording = false
239+
238240
fun startFocusTimer() {
239241
handler.postDelayed(runnable, autoCenterFocusDuration)
240242
}
@@ -247,7 +249,8 @@ open class MainActivity : AppCompatActivity(),
247249
ActivityResultContracts.RequestPermission()
248250
) { granted ->
249251
if (granted) {
250-
videoCapturer.startRecording()
252+
shouldRestartRecording = true
253+
camConfig.startCamera(true)
251254
return@registerForActivityResult
252255
}
253256
showAudioPermissionDeniedDialog {
@@ -655,6 +658,8 @@ open class MainActivity : AppCompatActivity(),
655658
}
656659
settingsIcon.isEnabled = true
657660
}
661+
662+
restartRecordingIfPermissionsWasUnavailable()
658663
} else {
659664
previewGrid.visibility = View.INVISIBLE
660665
val lastFrame = lastFrame
@@ -1787,4 +1792,11 @@ open class MainActivity : AppCompatActivity(),
17871792
}
17881793

17891794
open fun shouldShowCameraModeTabs() = true
1795+
1796+
private fun restartRecordingIfPermissionsWasUnavailable() {
1797+
if (shouldRestartRecording) {
1798+
shouldRestartRecording = false
1799+
videoCapturer.startRecording()
1800+
}
1801+
}
17901802
}

0 commit comments

Comments
 (0)