From 5886245bbffb6a77be4c864610b6f5ab305ca80b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Sep 2022 17:35:26 +0200 Subject: [PATCH] Reverse condition for code clarity with `ChecksSdkIntAtLeast` --- .../app/features/voice/VoiceRecorderProvider.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderProvider.kt b/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderProvider.kt index c024e0c6d4..05e537b2b0 100644 --- a/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderProvider.kt +++ b/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderProvider.kt @@ -33,18 +33,18 @@ class VoiceRecorderProvider @Inject constructor( private val buildVersionSdkIntProvider: BuildVersionSdkIntProvider, ) { fun provideVoiceRecorder(): VoiceRecorder { - return if (useFallbackRecorder()) { - VoiceRecorderL(context, Dispatchers.IO) - } else { + return if (useNativeRecorder()) { VoiceRecorderQ(context) + } else { + VoiceRecorderL(context, Dispatchers.IO) } } - @ChecksSdkIntAtLeast(api = 29) - private fun useFallbackRecorder(): Boolean { - return buildVersionSdkIntProvider.get() < Build.VERSION_CODES.Q || - !hasOpusEncoder() || - vectorFeatures.forceUsageOfOpusEncoder() + @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.Q) + private fun useNativeRecorder(): Boolean { + return buildVersionSdkIntProvider.get() >= Build.VERSION_CODES.Q && + hasOpusEncoder() && + !vectorFeatures.forceUsageOfOpusEncoder() } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)