diff --git a/vector/src/main/java/im/vector/app/features/call/telecom/TelecomUtils.kt b/vector/src/main/java/im/vector/app/features/call/telecom/TelecomUtils.kt deleted file mode 100644 index 819a1f6c0a..0000000000 --- a/vector/src/main/java/im/vector/app/features/call/telecom/TelecomUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package im.vector.app.features.call.telecom - -import android.content.Context -import android.telephony.TelephonyManager -import androidx.core.content.getSystemService - -object TelecomUtils { - - fun isLineBusy(context: Context): Boolean { - val telephonyManager = context.getSystemService() - ?: return false - return telephonyManager.callState != TelephonyManager.CALL_STATE_IDLE - } -} diff --git a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorder.kt b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorder.kt index 786920aa22..1a91c00e11 100644 --- a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorder.kt +++ b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorder.kt @@ -23,7 +23,7 @@ import java.io.File import java.io.FileOutputStream abstract class AbstractVoiceRecorder( - context: Context, + private val context: Context, private val filenameExt: String ) : VoiceRecorder { private val outputDirectory: File by lazy { @@ -39,7 +39,7 @@ abstract class AbstractVoiceRecorder( abstract fun convertFile(recordedFile: File?): File? private fun init() { - MediaRecorder().let { + createMediaRecorder().let { it.setAudioSource(MediaRecorder.AudioSource.DEFAULT) setOutputFormat(it) it.setAudioEncodingBitRate(24000) @@ -48,6 +48,15 @@ abstract class AbstractVoiceRecorder( } } + private fun createMediaRecorder(): MediaRecorder { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + MediaRecorder(context) + } else { + @Suppress("DEPRECATION") + MediaRecorder() + } + } + override fun startRecord() { init() outputFile = File(outputDirectory, "Voice message.$filenameExt")