mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Target API 31 - Handle deprecated API
This commit is contained in:
parent
31809a595c
commit
f7b2059fe1
@ -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<TelephonyManager>()
|
|
||||||
?: return false
|
|
||||||
return telephonyManager.callState != TelephonyManager.CALL_STATE_IDLE
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,7 @@ import java.io.File
|
|||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
abstract class AbstractVoiceRecorder(
|
abstract class AbstractVoiceRecorder(
|
||||||
context: Context,
|
private val context: Context,
|
||||||
private val filenameExt: String
|
private val filenameExt: String
|
||||||
) : VoiceRecorder {
|
) : VoiceRecorder {
|
||||||
private val outputDirectory: File by lazy {
|
private val outputDirectory: File by lazy {
|
||||||
@ -39,7 +39,7 @@ abstract class AbstractVoiceRecorder(
|
|||||||
abstract fun convertFile(recordedFile: File?): File?
|
abstract fun convertFile(recordedFile: File?): File?
|
||||||
|
|
||||||
private fun init() {
|
private fun init() {
|
||||||
MediaRecorder().let {
|
createMediaRecorder().let {
|
||||||
it.setAudioSource(MediaRecorder.AudioSource.DEFAULT)
|
it.setAudioSource(MediaRecorder.AudioSource.DEFAULT)
|
||||||
setOutputFormat(it)
|
setOutputFormat(it)
|
||||||
it.setAudioEncodingBitRate(24000)
|
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() {
|
override fun startRecord() {
|
||||||
init()
|
init()
|
||||||
outputFile = File(outputDirectory, "Voice message.$filenameExt")
|
outputFile = File(outputDirectory, "Voice message.$filenameExt")
|
||||||
|
Loading…
Reference in New Issue
Block a user