Delay calling by 1 sec after call icon is touched because audio mode does
not change to communication immediately
This commit is contained in:
@ -76,7 +76,6 @@ class MainActivity : AppCompatActivity() {
|
||||
private var speakerIcon: MenuItem? = null
|
||||
private lateinit var swipeRefresh: SwipeRefreshLayout
|
||||
private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>
|
||||
|
||||
private lateinit var accountsRequest: ActivityResultLauncher<Intent>
|
||||
private lateinit var chatRequests: ActivityResultLauncher<Intent>
|
||||
private lateinit var configRequest: ActivityResultLauncher<Intent>
|
||||
@ -85,6 +84,8 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var contactsRequest: ActivityResultLauncher<Intent>
|
||||
private lateinit var callsRequest: ActivityResultLauncher<Intent>
|
||||
|
||||
private var callHandler: Handler = Handler(Looper.getMainLooper())
|
||||
private var callRunnable: Runnable? = null
|
||||
private var downloadsInputUri: Uri? = null
|
||||
private var downloadsOutputUri: Uri? = null
|
||||
|
||||
@ -328,6 +329,13 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
hangupButton.setOnClickListener {
|
||||
val ua = BaresipService.uas[aorSpinner.selectedItemPosition]
|
||||
if (callRunnable != null && callHandler.hasCallbacks(callRunnable!!)) {
|
||||
callHandler.removeCallbacks(callRunnable!!)
|
||||
callRunnable = null
|
||||
am.mode = AudioManager.MODE_NORMAL
|
||||
showCall(ua)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val aor = ua.account.aor
|
||||
val uaCalls = ua.calls()
|
||||
if (uaCalls.size > 0) {
|
||||
@ -1758,18 +1766,21 @@ class MainActivity : AppCompatActivity() {
|
||||
)
|
||||
} else {
|
||||
callUri.isFocusable = false
|
||||
if (!call(ua, uri)) {
|
||||
callButton.visibility = View.VISIBLE
|
||||
callButton.isEnabled = true
|
||||
hangupButton.visibility = View.INVISIBLE
|
||||
hangupButton.isEnabled = false
|
||||
} else {
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
callButton.visibility = View.INVISIBLE
|
||||
callButton.isEnabled = false
|
||||
hangupButton.visibility = View.VISIBLE
|
||||
hangupButton.isEnabled = true
|
||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
callButton.visibility = View.INVISIBLE
|
||||
callButton.isEnabled = false
|
||||
hangupButton.visibility = View.VISIBLE
|
||||
hangupButton.isEnabled = true
|
||||
callRunnable = Runnable {
|
||||
if (!call(ua, uri)) {
|
||||
callButton.visibility = View.VISIBLE
|
||||
callButton.isEnabled = true
|
||||
hangupButton.visibility = View.INVISIBLE
|
||||
hangupButton.isEnabled = false
|
||||
}
|
||||
}
|
||||
callHandler.postDelayed(callRunnable!!, 1000)
|
||||
}
|
||||
} else {
|
||||
val latest = NewCallHistory.aorLatestHistory(aor)
|
||||
|
||||
Reference in New Issue
Block a user