diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 79fda6e..267de78 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,10 @@ + + = Build.VERSION_CODES.TIRAMISU) { audioPermission.add(Manifest.permission.POST_NOTIFICATIONS) } + val internalAudio = Preferences.prefs.getInt( + Preferences.audioDeviceSourceKey, + 0 + ) == AudioDeviceSource.REMOTE_SUBMIX.value + if (internalAudio) { + audioPermission.add(Manifest.permission.CAPTURE_AUDIO_OUTPUT) + } - if (!PermissionHelper.checkPermissions(context, audioPermission.toTypedArray())) return + if (!PermissionHelper.checkPermissions(context, audioPermission.toTypedArray())) { + Toast.makeText( + context, + context.getString(R.string.no_sufficient_permissions), Toast.LENGTH_SHORT + ) + .show() + return + } val serviceIntent = if (Preferences.prefs.getBoolean(Preferences.losslessRecorderKey, false)) { @@ -161,12 +178,27 @@ class RecorderModel : ViewModel() { Preferences.prefs.getInt(Preferences.audioSourceKey, 0) == AudioSource.MICROPHONE.value if (recordAudio) requiredPermissions.add(Manifest.permission.RECORD_AUDIO) + + val internalAudio = Preferences.prefs.getInt( + Preferences.audioDeviceSourceKey, + 0 + ) == AudioDeviceSource.REMOTE_SUBMIX.value + if (internalAudio) requiredPermissions.add(Manifest.permission.CAPTURE_AUDIO_OUTPUT) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { requiredPermissions.add(Manifest.permission.POST_NOTIFICATIONS) } if (requiredPermissions.isEmpty()) return true - return PermissionHelper.checkPermissions(context, requiredPermissions.toTypedArray()) + val granted = PermissionHelper.checkPermissions(context, requiredPermissions.toTypedArray()) + if (!granted) { + Toast.makeText( + context, + context.getString(R.string.no_sufficient_permissions), Toast.LENGTH_SHORT + ) + .show() + } + return granted } } diff --git a/app/src/main/java/com/bnyro/recorder/ui/screens/SettingsScreen.kt b/app/src/main/java/com/bnyro/recorder/ui/screens/SettingsScreen.kt index 6bff054..755a17b 100644 --- a/app/src/main/java/com/bnyro/recorder/ui/screens/SettingsScreen.kt +++ b/app/src/main/java/com/bnyro/recorder/ui/screens/SettingsScreen.kt @@ -173,7 +173,8 @@ fun SettingsScreen() { R.string.default_audio, R.string.microphone, R.string.camcorder, - R.string.unprocessed + R.string.unprocessed, + R.string.internal_audio ).map { stringResource(it) }, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 73d9f26..2f9d9d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -85,4 +85,6 @@ Can\'t access selected folder! Draw Mode Erase Mode + Internal Audio (Root) + No sufficient permissions to start recording \ No newline at end of file