- Fixed crash when returning to the previous activity after received call
or message. - Better handling of proximity sensor and speaker phone. - Use aorSpinner.tag to store aor of the selected account.
This commit is contained in:
@@ -40,7 +40,6 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
private var newCodecs = ArrayList<String>()
|
private var newCodecs = ArrayList<String>()
|
||||||
private var save = false
|
private var save = false
|
||||||
private var uaIndex= -1
|
private var uaIndex= -1
|
||||||
private var accp = ""
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
||||||
@@ -49,13 +48,12 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
||||||
accp = intent.getStringExtra("accp")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
Utils.addActivity("account,$accp")
|
ua = Account.findUa(aor)!!
|
||||||
|
acc = ua.account
|
||||||
acc = Account.find(accp)!!
|
|
||||||
aor = acc.aor
|
|
||||||
uaIndex = UserAgent.findAorIndex(aor)!!
|
uaIndex = UserAgent.findAorIndex(aor)!!
|
||||||
ua = UserAgent.uas()[uaIndex]
|
|
||||||
|
Utils.addActivity("account,$aor")
|
||||||
|
|
||||||
setTitle(aor.split(":")[1])
|
setTitle(aor.split(":")[1])
|
||||||
|
|
||||||
@@ -211,7 +209,7 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|
||||||
if (BaresipService.activities.indexOf("account,$accp") == -1)
|
if (BaresipService.activities.indexOf("account,$aor") == -1)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
@@ -458,7 +456,7 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
if (regCheck.isChecked && !((acc.authUser != "") && (acc.authPass == "")))
|
if (regCheck.isChecked && !((acc.authUser != "") && (acc.authPass == "")))
|
||||||
Api.ua_register(ua.uap)
|
Api.ua_register(ua.uap)
|
||||||
|
|
||||||
BaresipService.activities.remove("account,$accp")
|
BaresipService.activities.remove("account,$aor")
|
||||||
returnResult(Activity.RESULT_OK)
|
returnResult(Activity.RESULT_OK)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -475,14 +473,13 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
BaresipService.activities.remove("account,$accp")
|
BaresipService.activities.remove("account,$aor")
|
||||||
returnResult(Activity.RESULT_CANCELED)
|
returnResult(Activity.RESULT_CANCELED)
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
/* Without this, data is null at MainActivity onActivityResult */
|
MainActivity.activityAor = aor
|
||||||
returnResult(Activity.RESULT_CANCELED)
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +542,8 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun returnResult(code: Int) {
|
private fun returnResult(code: Int) {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
i.putExtra("aor", aor)
|
if (code == Activity.RESULT_OK)
|
||||||
|
i.putExtra("aor", aor)
|
||||||
setResult(code, i)
|
setResult(code, i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
|
|||||||
aorView.setOnClickListener { _ ->
|
aorView.setOnClickListener { _ ->
|
||||||
val i = Intent(cxt, AccountActivity::class.java)
|
val i = Intent(cxt, AccountActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("accp", UserAgent.uas()[position].account.accp)
|
b.putString("aor", UserAgent.uas()[position].account.aor)
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
(cxt as Activity).startActivityForResult(i, ACCOUNT_CODE)
|
(cxt as Activity).startActivityForResult(i, ACCOUNT_CODE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
saveAccounts()
|
saveAccounts()
|
||||||
val i = Intent(this, AccountActivity::class.java)
|
val i = Intent(this, AccountActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("accp", ua.account.accp)
|
b.putString("aor", ua.account.aor)
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, ACCOUNT_CODE)
|
startActivityForResult(i, ACCOUNT_CODE)
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
ACCOUNT_CODE -> {
|
ACCOUNT_CODE -> {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
val aor = data!!.getStringExtra("aor")!!
|
val aor = data!!.getStringExtra("aor")!!
|
||||||
val ua = UserAgent.uas()[UserAgent.findAorIndex(aor)!!]
|
val ua = Account.findUa(aor)!!
|
||||||
if (aorPasswords.containsKey(aor) && aorPasswords[aor] == "")
|
if (aorPasswords.containsKey(aor) && aorPasswords[aor] == "")
|
||||||
askPassword(String.format(getString(R.string.account_password),
|
askPassword(String.format(getString(R.string.account_password),
|
||||||
Utils.plainAor(aor)), ua)
|
Utils.plainAor(aor)), ua)
|
||||||
@@ -156,23 +156,17 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
BaresipService.activities.remove("accounts,$aor")
|
BaresipService.activities.remove("accounts,$aor")
|
||||||
returnResult()
|
val i = Intent()
|
||||||
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
|
finish()
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
/* Without this, data is null at MainActivity onActivityResult */
|
MainActivity.activityAor = aor
|
||||||
returnResult()
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun returnResult() {
|
|
||||||
val i = Intent()
|
|
||||||
i.putExtra("aor", aor)
|
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
var accounts = ArrayList<AccountRow>()
|
var accounts = ArrayList<AccountRow>()
|
||||||
|
|||||||
@@ -416,14 +416,11 @@ class BaresipService: Service() {
|
|||||||
updateStatusNotification()
|
updateStatusNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
"ToggleSpeaker" -> {
|
"SetSpeaker" -> {
|
||||||
Log.d(LOG_TAG, "Toggling speakerphone from $speakerPhone")
|
Log.d(LOG_TAG, "Set speakerphone $speakerPhone")
|
||||||
am.isSpeakerphoneOn = !am.isSpeakerphoneOn
|
am.isSpeakerphoneOn = speakerPhone
|
||||||
speakerPhone = am.isSpeakerphoneOn
|
if (Call.call("established") != null)
|
||||||
}
|
proximitySensing(!speakerPhone)
|
||||||
|
|
||||||
"ProximitySensing" -> {
|
|
||||||
proximitySensing(intent!!.getBooleanExtra("enable", false))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"Stop", "Stop Force" -> {
|
"Stop", "Stop Force" -> {
|
||||||
@@ -652,6 +649,7 @@ class BaresipService: Service() {
|
|||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
||||||
setCallVolume()
|
setCallVolume()
|
||||||
|
proximitySensing(!speakerPhone)
|
||||||
if (!Utils.isVisible())
|
if (!Utils.isVisible())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -741,6 +739,7 @@ class BaresipService: Service() {
|
|||||||
abandonAudioFocus()
|
abandonAudioFocus()
|
||||||
}
|
}
|
||||||
speakerPhone = false
|
speakerPhone = false
|
||||||
|
am.isSpeakerphoneOn = false
|
||||||
proximitySensing(false)
|
proximitySensing(false)
|
||||||
}
|
}
|
||||||
if (ua.account.callHistory && !call.hasHistory) {
|
if (ua.account.callHistory && !call.hasHistory) {
|
||||||
@@ -748,8 +747,7 @@ class BaresipService: Service() {
|
|||||||
CallHistory.save()
|
CallHistory.save()
|
||||||
if (call.dir == "in") ua.account.missedCalls = true
|
if (call.dir == "in") ua.account.missedCalls = true
|
||||||
}
|
}
|
||||||
if (!Utils.isVisible())
|
if (!Utils.isVisible()) return
|
||||||
return
|
|
||||||
}
|
}
|
||||||
"transfer failed" -> {
|
"transfer failed" -> {
|
||||||
Log.d(LOG_TAG, "AoR $aor hanging up call $callp with ${ev[1]}")
|
Log.d(LOG_TAG, "AoR $aor hanging up call $callp with ${ev[1]}")
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ class Call(val callp: String, val ua: UserAgent, val peerURI: String, val dir: S
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun incomingCall(): Call? {
|
fun call(status: String): Call? {
|
||||||
for (c in BaresipService.calls)
|
for (c in BaresipService.calls)
|
||||||
if (c.status == "incoming") return c
|
if (c.status == status) return c
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
when (which) {
|
when (which) {
|
||||||
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
||||||
BaresipService.activities.remove("calls,$aor")
|
BaresipService.activities.remove("calls,$aor")
|
||||||
|
MainActivity.activityAor = aor
|
||||||
returnResult()
|
returnResult()
|
||||||
val i = Intent(this@CallsActivity, MainActivity::class.java)
|
val i = Intent(this@CallsActivity, MainActivity::class.java)
|
||||||
i.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
i.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
@@ -98,6 +99,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
DialogInterface.BUTTON_POSITIVE -> {
|
DialogInterface.BUTTON_POSITIVE -> {
|
||||||
removeUaHistoryAt(pos)
|
removeUaHistoryAt(pos)
|
||||||
|
CallHistory.save()
|
||||||
clAdapter.notifyDataSetChanged()
|
clAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
DialogInterface.BUTTON_NEUTRAL -> {
|
DialogInterface.BUTTON_NEUTRAL -> {
|
||||||
@@ -180,14 +182,12 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
CallHistory.save()
|
MainActivity.activityAor = aor
|
||||||
returnResult()
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun returnResult() {
|
private fun returnResult() {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
i.putExtra("aor", aor)
|
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
val userAgent = Account.findUa(aor)
|
val userAgent = Account.findUa(aor)
|
||||||
if (userAgent == null) {
|
if (userAgent == null) {
|
||||||
Log.w("Baresip", "MessageActivity did not find ua of $aor")
|
Log.w("Baresip", "MessageActivity did not find ua of $aor")
|
||||||
|
MainActivity.activityAor = aor
|
||||||
returnResult(Activity.RESULT_CANCELED)
|
returnResult(Activity.RESULT_CANCELED)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -175,7 +176,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
Log.d("Baresip", "Saving newMessage ${newMessage.text} for $aor::$peerUri")
|
Log.d("Baresip", "Saving newMessage ${newMessage.text} for $aor::$peerUri")
|
||||||
BaresipService.chatTexts.put("$aor::$peerUri", newMessage.text.toString())
|
BaresipService.chatTexts.put("$aor::$peerUri", newMessage.text.toString())
|
||||||
}
|
}
|
||||||
returnResult(Activity.RESULT_CANCELED)
|
MainActivity.activityAor = aor
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +256,6 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun returnResult(code: Int) {
|
private fun returnResult(code: Int) {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
i.putExtra("aor", aor)
|
|
||||||
setResult(code, i)
|
setResult(code, i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
BaresipService.activities.remove("chats,$aor")
|
onBackPressed()
|
||||||
returnResult()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,14 +194,12 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
/* Without this, data is null at MainActivity onActivityResult */
|
MainActivity.activityAor = aor
|
||||||
returnResult()
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun returnResult() {
|
private fun returnResult() {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
i.putExtra("aor", aor)
|
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,15 +126,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
uaAdapter = UaSpinnerAdapter(applicationContext, BaresipService.uas, BaresipService.status)
|
uaAdapter = UaSpinnerAdapter(applicationContext, BaresipService.uas, BaresipService.status)
|
||||||
aorSpinner.adapter = uaAdapter
|
aorSpinner.adapter = uaAdapter
|
||||||
aorSpinner.setSelection(-1)
|
aorSpinner.setSelection(-1)
|
||||||
|
aorSpinner.tag = ""
|
||||||
aorSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
aorSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
// Have to allow NULL view, since sometimes when onItemSelected is called, view is NULL.
|
// Have to allow NULL view, since sometimes when onItemSelected is called, view is NULL.
|
||||||
// Haven't found any explanation why this can happen.
|
// Haven't found any explanation why this can happen.
|
||||||
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
|
||||||
Log.d("Baresip", "aorSpinner selecting $position")
|
Log.d("Baresip", "aorSpinner selecting $position")
|
||||||
val acc = UserAgent.uas()[position].account
|
val acc = UserAgent.uas()[position].account
|
||||||
val aor = acc.aor
|
aorSpinner.tag = acc.aor
|
||||||
val ua = UserAgent.uas()[position]
|
val ua = UserAgent.uas()[position]
|
||||||
Log.d("Baresip", "Setting $aor current")
|
Log.d("Baresip", "Setting ${aorSpinner.tag} current")
|
||||||
Api.uag_current_set(UserAgent.uas()[position].uap)
|
Api.uag_current_set(UserAgent.uas()[position].uap)
|
||||||
showCall(ua)
|
showCall(ua)
|
||||||
updateIcons(acc)
|
updateIcons(acc)
|
||||||
@@ -156,7 +157,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if ((event.x - view.left) < 100) {
|
if ((event.x - view.left) < 100) {
|
||||||
val i = Intent(this@MainActivity, AccountActivity::class.java)
|
val i = Intent(this@MainActivity, AccountActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("accp", UserAgent.uas()[aorSpinner.selectedItemPosition].account.accp)
|
b.putString("aor", aorSpinner.tag.toString())
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, ACCOUNT_CODE)
|
startActivityForResult(i, ACCOUNT_CODE)
|
||||||
true
|
true
|
||||||
@@ -202,8 +203,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
unverifyDialog.setTitle(getString(R.string.info))
|
unverifyDialog.setTitle(getString(R.string.info))
|
||||||
unverifyDialog.setMessage(getString(R.string.call_is_secure))
|
unverifyDialog.setMessage(getString(R.string.call_is_secure))
|
||||||
unverifyDialog.setPositiveButton(getString(R.string.unverify)) { dialog, _ ->
|
unverifyDialog.setPositiveButton(getString(R.string.unverify)) { dialog, _ ->
|
||||||
val calls = Call.uaCalls(UserAgent.uas()[aorSpinner.selectedItemPosition],
|
val calls = Call.uaCalls(UserAgent.uas()[aorSpinner.selectedItemPosition], "")
|
||||||
"")
|
|
||||||
if (calls.size > 0) {
|
if (calls.size > 0) {
|
||||||
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
|
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
|
||||||
Log.e("Baresip",
|
Log.e("Baresip",
|
||||||
@@ -383,7 +383,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val i = Intent(this@MainActivity, ContactsActivity::class.java)
|
val i = Intent(this@MainActivity, ContactsActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
if (aorSpinner.selectedItemPosition >= 0)
|
if (aorSpinner.selectedItemPosition >= 0)
|
||||||
b.putString("aor", UserAgent.uas()[aorSpinner.selectedItemPosition].account.aor)
|
b.putString("aor", aorSpinner.tag.toString())
|
||||||
else
|
else
|
||||||
b.putString("aor", "")
|
b.putString("aor", "")
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
@@ -394,7 +394,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (aorSpinner.selectedItemPosition >= 0) {
|
if (aorSpinner.selectedItemPosition >= 0) {
|
||||||
val i = Intent(this@MainActivity, ChatsActivity::class.java)
|
val i = Intent(this@MainActivity, ChatsActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("aor", UserAgent.uas()[aorSpinner.selectedItemPosition].account.aor)
|
b.putString("aor", aorSpinner.tag.toString())
|
||||||
b.putString("peer", resumeUri)
|
b.putString("peer", resumeUri)
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, CHATS_CODE)
|
startActivityForResult(i, CHATS_CODE)
|
||||||
@@ -405,7 +405,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (aorSpinner.selectedItemPosition >= 0) {
|
if (aorSpinner.selectedItemPosition >= 0) {
|
||||||
val i = Intent(this@MainActivity, CallsActivity::class.java)
|
val i = Intent(this@MainActivity, CallsActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("aor", UserAgent.uas()[aorSpinner.selectedItemPosition].account.aor)
|
b.putString("aor", aorSpinner.tag.toString())
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, CALLS_CODE)
|
startActivityForResult(i, CALLS_CODE)
|
||||||
}
|
}
|
||||||
@@ -477,8 +477,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Log.w("Baresip", "handleIntent 'call' did not find ua $uap")
|
Log.w("Baresip", "handleIntent 'call' did not find ua $uap")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ((aorSpinner.selectedItemPosition == -1) ||
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
(ua != UserAgent.uas()[aorSpinner.selectedItemPosition]))
|
|
||||||
spinToAor(ua.account.aor)
|
spinToAor(ua.account.aor)
|
||||||
resumeAction = action
|
resumeAction = action
|
||||||
resumeUri = intent.getStringExtra("peer")!!
|
resumeUri = intent.getStringExtra("peer")!!
|
||||||
@@ -491,8 +490,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val ua = call.ua
|
val ua = call.ua
|
||||||
if ((aorSpinner.selectedItemPosition == -1) ||
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
(ua != UserAgent.uas()[aorSpinner.selectedItemPosition]))
|
|
||||||
spinToAor(ua.account.aor)
|
spinToAor(ua.account.aor)
|
||||||
resumeAction = action
|
resumeAction = action
|
||||||
resumeCall = call
|
resumeCall = call
|
||||||
@@ -516,8 +514,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Log.w("Baresip", "onNewIntent did not find ua $uap")
|
Log.w("Baresip", "onNewIntent did not find ua $uap")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ((aorSpinner.selectedItemPosition == -1) ||
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
(ua != UserAgent.uas()[aorSpinner.selectedItemPosition]))
|
|
||||||
spinToAor(ua.account.aor)
|
spinToAor(ua.account.aor)
|
||||||
resumeAction = action
|
resumeAction = action
|
||||||
resumeUap = uap
|
resumeUap = uap
|
||||||
@@ -528,7 +525,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
Log.d("Baresip", "Main resumed with action '$resumeAction'")
|
Log.d("Baresip", "Main onResume with action '$resumeAction'")
|
||||||
visible = true
|
visible = true
|
||||||
when (resumeAction) {
|
when (resumeAction) {
|
||||||
"call show" ->
|
"call show" ->
|
||||||
@@ -550,20 +547,19 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"message", "message show", "message reply" ->
|
"message", "message show", "message reply" ->
|
||||||
handleServiceEvent(resumeAction, arrayListOf(resumeUap, resumeUri))
|
handleServiceEvent(resumeAction, arrayListOf(resumeUap, resumeUri))
|
||||||
else -> {
|
else -> {
|
||||||
val incomingCall = Call.incomingCall()
|
val incomingCall = Call.call("incoming")
|
||||||
if (incomingCall != null) {
|
if (incomingCall != null) {
|
||||||
spinToAor(incomingCall.ua.account.aor)
|
spinToAor(incomingCall.ua.account.aor)
|
||||||
} else {
|
} else {
|
||||||
restoreActivities()
|
restoreActivities()
|
||||||
if (UserAgent.uas().size > 0) {
|
if (UserAgent.uas().size > 0) {
|
||||||
val currentPosition = aorSpinner.selectedItemPosition
|
if (aorSpinner.selectedItemPosition == -1) {
|
||||||
if (currentPosition == -1) {
|
|
||||||
if (Call.calls().size > 0)
|
if (Call.calls().size > 0)
|
||||||
spinToAor(Call.calls()[0].ua.account.aor)
|
spinToAor(Call.calls()[0].ua.account.aor)
|
||||||
else
|
else {
|
||||||
aorSpinner.setSelection(0)
|
aorSpinner.setSelection(0)
|
||||||
} else {
|
aorSpinner.tag = UserAgent.uas()[0].account.aor
|
||||||
aorSpinner.setSelection(currentPosition)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +573,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
Log.d("Baresip", "Main paused")
|
Log.d("Baresip", "Main onPause")
|
||||||
Utils.addActivity("main")
|
Utils.addActivity("main")
|
||||||
visible = false
|
visible = false
|
||||||
super.onPause()
|
super.onPause()
|
||||||
@@ -627,7 +623,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
when (ev[0]) {
|
when (ev[0]) {
|
||||||
"ua added" -> {
|
"ua added" -> {
|
||||||
uaAdapter.notifyDataSetChanged()
|
uaAdapter.notifyDataSetChanged()
|
||||||
if (aorSpinner.selectedItemPosition == -1) aorSpinner.setSelection(0)
|
if (aorSpinner.selectedItemPosition == -1) {
|
||||||
|
aorSpinner.setSelection(0)
|
||||||
|
aorSpinner.tag = UserAgent.uas()[0].account.aor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"registered", "unregistering" -> {
|
"registered", "unregistering" -> {
|
||||||
uaAdapter.notifyDataSetChanged()
|
uaAdapter.notifyDataSetChanged()
|
||||||
@@ -643,7 +642,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
||||||
}
|
}
|
||||||
"call rejected" -> {
|
"call rejected" -> {
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
callsButton.setImageResource(R.drawable.calls_missed)
|
callsButton.setImageResource(R.drawable.calls_missed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,9 +659,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
volumeControlStream = AudioManager.STREAM_RING
|
volumeControlStream = AudioManager.STREAM_RING
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if ((aorSpinner.selectedItemPosition == -1) ||
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
(ua != UserAgent.uas()[aorSpinner.selectedItemPosition]))
|
spinToAor(ua.account.aor)
|
||||||
aorSpinner.setSelection(account_index)
|
|
||||||
showCall(ua)
|
showCall(ua)
|
||||||
} else {
|
} else {
|
||||||
Log.d("Baresip", "Reordering to front")
|
Log.d("Baresip", "Reordering to front")
|
||||||
@@ -682,7 +680,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
dtmf.setText("")
|
dtmf.setText("")
|
||||||
dtmf.hint = getString(R.string.dtmf)
|
dtmf.hint = getString(R.string.dtmf)
|
||||||
showCall(ua)
|
showCall(ua)
|
||||||
@@ -709,7 +707,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
call.security = security
|
call.security = security
|
||||||
call.zid = ev[3]
|
call.zid = ev[3]
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
securityButton.setImageResource(security)
|
securityButton.setImageResource(security)
|
||||||
setSecurityButtonTag(securityButton, security)
|
setSecurityButtonTag(securityButton, security)
|
||||||
securityButton.visibility = View.VISIBLE
|
securityButton.visibility = View.VISIBLE
|
||||||
@@ -719,7 +717,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
verifyDialog.setNegativeButton(getString(R.string.no)) { dialog, _ ->
|
verifyDialog.setNegativeButton(getString(R.string.no)) { dialog, _ ->
|
||||||
call.security = R.drawable.box_yellow
|
call.security = R.drawable.box_yellow
|
||||||
call.zid = ev[3]
|
call.zid = ev[3]
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
securityButton.setImageResource(R.drawable.box_yellow)
|
securityButton.setImageResource(R.drawable.box_yellow)
|
||||||
securityButton.tag = "yellow"
|
securityButton.tag = "yellow"
|
||||||
securityButton.visibility = View.VISIBLE
|
securityButton.visibility = View.VISIBLE
|
||||||
@@ -740,7 +738,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
tag = "yellow"
|
tag = "yellow"
|
||||||
else
|
else
|
||||||
tag = "green"
|
tag = "green"
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
securityButton.setImageResource(call.security)
|
securityButton.setImageResource(call.security)
|
||||||
securityButton.tag = tag
|
securityButton.tag = tag
|
||||||
}
|
}
|
||||||
@@ -784,7 +782,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
showCall(ua)
|
showCall(ua)
|
||||||
}
|
}
|
||||||
"call closed" -> {
|
"call closed" -> {
|
||||||
if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) {
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
showCall(ua)
|
showCall(ua)
|
||||||
if (ua.account.missedCalls)
|
if (ua.account.missedCalls)
|
||||||
callsButton.setImageResource(R.drawable.calls_missed)
|
callsButton.setImageResource(R.drawable.calls_missed)
|
||||||
@@ -808,9 +806,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val peer = params[1]
|
val peer = params[1]
|
||||||
Log.d("Baresip", "Message for $aor from $peer")
|
Log.d("Baresip", "Message for $aor from $peer")
|
||||||
Log.d("Baresip", "Activity stack ${BaresipService.activities.toString()}")
|
Log.d("Baresip", "Activity stack ${BaresipService.activities.toString()}")
|
||||||
if ((aorSpinner.selectedItemPosition == -1) ||
|
|
||||||
(ua != UserAgent.uas()[aorSpinner.selectedItemPosition]))
|
|
||||||
aorSpinner.setSelection(account_index)
|
|
||||||
val i = Intent(applicationContext, ChatActivity::class.java)
|
val i = Intent(applicationContext, ChatActivity::class.java)
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
@@ -830,8 +825,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((aorSpinner.selectedItemPosition >= 0) &&
|
if (ua.account.aor == aorSpinner.tag) {
|
||||||
(ua == UserAgent.uas()[aorSpinner.selectedItemPosition])) {
|
|
||||||
if (acc.vmNew > 0)
|
if (acc.vmNew > 0)
|
||||||
voicemailButton.setImageResource(R.drawable.voicemail_new)
|
voicemailButton.setImageResource(R.drawable.voicemail_new)
|
||||||
else
|
else
|
||||||
@@ -881,12 +875,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
item.setIcon(R.drawable.speaker_off)
|
item.setIcon(R.drawable.speaker_off)
|
||||||
else
|
else
|
||||||
item.setIcon(R.drawable.speaker_on)
|
item.setIcon(R.drawable.speaker_on)
|
||||||
if (Call.calls().size > 0) {
|
BaresipService.speakerPhone = !BaresipService.speakerPhone
|
||||||
baresipService.putExtra("enable", BaresipService.speakerPhone)
|
baresipService.setAction("SetSpeaker")
|
||||||
baresipService.setAction("ProximitySensing")
|
|
||||||
startService(baresipService)
|
|
||||||
}
|
|
||||||
baresipService.setAction("ToggleSpeaker")
|
|
||||||
startService(baresipService)
|
startService(baresipService)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,10 +888,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
R.id.accounts -> {
|
R.id.accounts -> {
|
||||||
i = Intent(this, AccountsActivity::class.java)
|
i = Intent(this, AccountsActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
if (aorSpinner.selectedItemPosition != -1)
|
b.putString("aor", aorSpinner.tag.toString())
|
||||||
b.putString("aor", UserAgent.uas()[aorSpinner.selectedItemPosition].account.aor)
|
|
||||||
else
|
|
||||||
b.putString("aor", "")
|
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, ACCOUNTS_CODE)
|
startActivityForResult(i, ACCOUNTS_CODE)
|
||||||
}
|
}
|
||||||
@@ -933,16 +920,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
|
||||||
Log.d("Baresip", "onActivity result $requestCode $resultCode $data")
|
Log.d("Baresip", "onActivity result $requestCode $resultCode")
|
||||||
|
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
|
|
||||||
ACCOUNTS_CODE -> {
|
ACCOUNTS_CODE -> {
|
||||||
uaAdapter.notifyDataSetChanged()
|
uaAdapter.notifyDataSetChanged()
|
||||||
val aor = data!!.getStringExtra("aor")!!
|
spinToAor(activityAor)
|
||||||
spinToAor(aor)
|
if (aorSpinner.tag != "")
|
||||||
if (aorSpinner.selectedItemPosition != -1)
|
updateIcons(Account.findUa(aorSpinner.tag.toString())!!.account)
|
||||||
updateIcons(UserAgent.uas()[aorSpinner.selectedItemPosition].account)
|
|
||||||
if (BaresipService.isServiceRunning) {
|
if (BaresipService.isServiceRunning) {
|
||||||
baresipService.setAction("UpdateNotification")
|
baresipService.setAction("UpdateNotification")
|
||||||
startService(baresipService)
|
startService(baresipService)
|
||||||
@@ -950,14 +936,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ACCOUNT_CODE -> {
|
ACCOUNT_CODE -> {
|
||||||
val aor = data!!.getStringExtra("aor")!!
|
spinToAor(activityAor)
|
||||||
spinToAor(aor)
|
val ua = Account.findUa(activityAor)!!
|
||||||
val ua = Account.findUa(aor)!!
|
|
||||||
updateIcons(ua.account)
|
updateIcons(ua.account)
|
||||||
if (resultCode == Activity.RESULT_OK)
|
if (resultCode == Activity.RESULT_OK)
|
||||||
if (aorPasswords.containsKey(aor) && aorPasswords[aor] == "")
|
if (aorPasswords.containsKey(activityAor) && aorPasswords[activityAor] == "")
|
||||||
askPassword(String.format(getString(R.string.account_password),
|
askPassword(String.format(getString(R.string.account_password),
|
||||||
Utils.plainAor(aor)), ua)
|
Utils.plainAor(activityAor)), ua)
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTACTS_CODE -> {
|
CONTACTS_CODE -> {
|
||||||
@@ -981,13 +966,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CALLS_CODE -> {
|
CALLS_CODE -> {
|
||||||
spinToAor(data!!.getStringExtra("aor")!!)
|
spinToAor(activityAor)
|
||||||
callsButton.setImageResource(R.drawable.calls)
|
callsButton.setImageResource(R.drawable.calls)
|
||||||
}
|
}
|
||||||
|
|
||||||
CHATS_CODE, CHAT_CODE -> {
|
CHATS_CODE, CHAT_CODE -> {
|
||||||
spinToAor(data!!.getStringExtra("aor")!!)
|
spinToAor(activityAor)
|
||||||
updateIcons(UserAgent.uas()[aorSpinner.selectedItemPosition].account)
|
updateIcons(Account.findUa(activityAor)!!.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
ABOUT_CODE -> { }
|
ABOUT_CODE -> { }
|
||||||
@@ -1191,12 +1176,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
for (account_index in UserAgent.uas().indices)
|
for (account_index in UserAgent.uas().indices)
|
||||||
if (UserAgent.uas()[account_index].account.aor == aor) {
|
if (UserAgent.uas()[account_index].account.aor == aor) {
|
||||||
aorSpinner.setSelection(account_index)
|
aorSpinner.setSelection(account_index)
|
||||||
|
aorSpinner.tag = aor
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (UserAgent.uas().isNotEmpty())
|
if (UserAgent.uas().isNotEmpty()) {
|
||||||
aorSpinner.setSelection(0)
|
aorSpinner.setSelection(0)
|
||||||
else
|
aorSpinner.tag = UserAgent.uas()[0].account.aor
|
||||||
|
} else {
|
||||||
aorSpinner.setSelection(-1)
|
aorSpinner.setSelection(-1)
|
||||||
|
aorSpinner.tag = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun call(ua: UserAgent, uri: String, status: String): Boolean {
|
private fun call(ua: UserAgent, uri: String, status: String): Boolean {
|
||||||
@@ -1205,7 +1194,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Toast.LENGTH_LONG).show()
|
Toast.LENGTH_LONG).show()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition]) spinToAor(ua.account.aor)
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
|
spinToAor(ua.account.aor)
|
||||||
val callp = Api.ua_connect(ua.uap, uri, Api.VIDMODE_OFF)
|
val callp = Api.ua_connect(ua.uap, uri, Api.VIDMODE_OFF)
|
||||||
if (callp != "") {
|
if (callp != "") {
|
||||||
Log.d("Baresip", "Adding outgoing call ${ua.uap}/$callp/$uri")
|
Log.d("Baresip", "Adding outgoing call ${ua.uap}/$callp/$uri")
|
||||||
@@ -1231,7 +1221,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val err = newCall.connect(uri)
|
val err = newCall.connect(uri)
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
newCall.startAudio()
|
newCall.startAudio()
|
||||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
spinToAor(ua.account.aor)
|
spinToAor(ua.account.aor)
|
||||||
showCall(ua)
|
showCall(ua)
|
||||||
} else {
|
} else {
|
||||||
@@ -1278,9 +1268,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
holdButton.visibility = View.INVISIBLE
|
holdButton.visibility = View.INVISIBLE
|
||||||
dtmf.visibility = View.INVISIBLE
|
dtmf.visibility = View.INVISIBLE
|
||||||
infoButton.visibility = View.INVISIBLE
|
infoButton.visibility = View.INVISIBLE
|
||||||
baresipService.putExtra("enable", false)
|
|
||||||
baresipService.setAction("ProximitySensing")
|
|
||||||
startService(baresipService)
|
|
||||||
} else {
|
} else {
|
||||||
val callsOut = Call.uaCalls(ua, "out")
|
val callsOut = Call.uaCalls(ua, "out")
|
||||||
val callsIn = Call.uaCalls(ua, "in")
|
val callsIn = Call.uaCalls(ua, "in")
|
||||||
@@ -1300,9 +1287,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Utils.aorDomain(ua.account.aor)))
|
Utils.aorDomain(ua.account.aor)))
|
||||||
callUri.isFocusable = false
|
callUri.isFocusable = false
|
||||||
imm.hideSoftInputFromWindow(callUri.windowToken, 0)
|
imm.hideSoftInputFromWindow(callUri.windowToken, 0)
|
||||||
baresipService.putExtra("enable", !BaresipService.speakerPhone)
|
|
||||||
baresipService.setAction("ProximitySensing")
|
|
||||||
startService(baresipService)
|
|
||||||
when (call.status) {
|
when (call.status) {
|
||||||
"outgoing", "transferring" -> {
|
"outgoing", "transferring" -> {
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
@@ -1403,7 +1387,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"account" -> {
|
"account" -> {
|
||||||
val i = Intent(this, AccountActivity::class.java)
|
val i = Intent(this, AccountActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("accp", activity[1])
|
b.putString("aor", activity[1])
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, ACCOUNT_CODE)
|
startActivityForResult(i, ACCOUNT_CODE)
|
||||||
}
|
}
|
||||||
@@ -1480,6 +1464,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
var resumeUap = ""
|
var resumeUap = ""
|
||||||
var resumeCall: Call? = null
|
var resumeCall: Call? = null
|
||||||
var resumeUri = ""
|
var resumeUri = ""
|
||||||
|
var activityAor = ""
|
||||||
|
|
||||||
// <aor, password> of those accounts that have auth username without auth password
|
// <aor, password> of those accounts that have auth username without auth password
|
||||||
val aorPasswords = mutableMapOf<String, String>()
|
val aorPasswords = mutableMapOf<String, String>()
|
||||||
|
|||||||
Reference in New Issue
Block a user