private fun requestPermissions() {
val perms = mutableListOf(
ACCESS_FINE_LOCATION,
RECORD_AUDIO, // Add microphone permission
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
perms.add(POST_NOTIFICATIONS)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
perms.add(FOREGROUND_SERVICE_MICROPHONE)
}
val permsToRequest = mutableListOf<String>()
val rationaleMessages = mutableListOf<String>()
// Check which permissions are missing and need to be requested
for (perm in perms) {
if (!EasyPermissions.hasPermissions(this, perm)) {
permsToRequest.add(perm)
// Add rationale messages for missing permissions
when (perm) {
ACCESS_FINE_LOCATION -> rationaleMessages.add(getString(R.string.permission_location_rationale))
RECORD_AUDIO -> rationaleMessages.add(getString(R.string.permission_record_audio_rationale))
POST_NOTIFICATIONS -> rationaleMessages.add(getString(R.string.permission_notifications_rationale))
FOREGROUND_SERVICE_MICROPHONE -> rationaleMessages.add(getString(R.string.permission_record_audio_in_background_rationale))
}
}
}