Ask record audio permission when baresip is started
This commit is contained in:
@@ -5,7 +5,7 @@ const val TAG = "Baresip"
|
|||||||
const val DEFAULT_CHANNEL_ID = "com.tutpro.baresip.default"
|
const val DEFAULT_CHANNEL_ID = "com.tutpro.baresip.default"
|
||||||
const val HIGH_CHANNEL_ID = "com.tutpro.baresip.high"
|
const val HIGH_CHANNEL_ID = "com.tutpro.baresip.high"
|
||||||
|
|
||||||
const val CALL_PERMISSION_REQUEST_CODE = 1
|
const val MIC_PERMISSION_REQUEST_CODE = 1
|
||||||
const val CONTACT_PERMISSION_REQUEST_CODE = 2
|
const val CONTACT_PERMISSION_REQUEST_CODE = 2
|
||||||
|
|
||||||
const val STATUS_NOTIFICATION_ID = 101
|
const val STATUS_NOTIFICATION_ID = 101
|
||||||
|
|||||||
@@ -310,12 +310,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
callButton.setOnClickListener {
|
callButton.setOnClickListener {
|
||||||
if (aorSpinner.selectedItemPosition == -1)
|
if (aorSpinner.selectedItemPosition == -1)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
val permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
|
if (Utils.checkPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO)))
|
||||||
if (Utils.checkPermissions(this, permissions))
|
|
||||||
makeCall()
|
makeCall()
|
||||||
else
|
else
|
||||||
ActivityCompat.requestPermissions(this, permissions,
|
Toast.makeText(applicationContext, R.string.no_calls, Toast.LENGTH_SHORT).show()
|
||||||
CALL_PERMISSION_REQUEST_CODE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hangupButton.setOnClickListener {
|
hangupButton.setOnClickListener {
|
||||||
@@ -620,8 +618,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
Log.i(TAG, "Main onStart")
|
Log.i(TAG, "Main onStart")
|
||||||
super.onStart()
|
super.onStart()
|
||||||
requestPermissionLauncher =
|
requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
||||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA),
|
||||||
|
MIC_PERMISSION_REQUEST_CODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@@ -1254,9 +1253,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
CALL_PERMISSION_REQUEST_CODE -> {
|
MIC_PERMISSION_REQUEST_CODE -> {
|
||||||
if ((grantResults.isNotEmpty()) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
if ((grantResults.isNotEmpty()) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||||
makeCall()
|
Log.d(TAG, "Record audio permission granted")
|
||||||
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
|
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
|
||||||
Manifest.permission.RECORD_AUDIO)) {
|
Manifest.permission.RECORD_AUDIO)) {
|
||||||
layout.showSnackBar(
|
layout.showSnackBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user