- Added possibility to give transport protocol for account's AoR.
- Do not show account's port or transport protocol except in Account Activity.
This commit is contained in:
@@ -8,6 +8,7 @@ class Account(val accp: String) {
|
||||
|
||||
var displayName = account_display_name(accp)
|
||||
val aor = account_aor(accp)
|
||||
val uri = account_uri(accp)
|
||||
var authUser = account_auth_user(accp)
|
||||
var authPass = account_auth_pass(accp)
|
||||
var outbound = ArrayList<String>()
|
||||
@@ -207,12 +208,21 @@ class Account(val accp: String) {
|
||||
return false
|
||||
}
|
||||
|
||||
fun aor(accp: String): String {
|
||||
return account_aor(accp)
|
||||
}
|
||||
|
||||
fun uri(accp: String): String {
|
||||
return account_uri(accp)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
external fun account_set_display_name(acc: String, dn: String): Int
|
||||
external fun account_display_name(acc: String): String
|
||||
external fun account_aor(acc: String): String
|
||||
external fun account_uri(acc: String): String
|
||||
external fun account_auth_user(acc: String): String
|
||||
external fun account_set_auth_user(acc: String, user: String): Int
|
||||
external fun account_auth_pass(acc: String): String
|
||||
|
||||
@@ -16,6 +16,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
internal lateinit var acc: Account
|
||||
internal lateinit var ua: UserAgent
|
||||
internal lateinit var uri: TextView
|
||||
internal lateinit var displayName: EditText
|
||||
internal lateinit var aor: String
|
||||
internal lateinit var authUser: EditText
|
||||
@@ -47,7 +48,10 @@ class AccountActivity : AppCompatActivity() {
|
||||
uaIndex = UserAgent.findAorIndex(aor)!!
|
||||
ua = UserAgent.uas()[uaIndex]
|
||||
|
||||
setTitle(aor.replace("sip:", ""))
|
||||
setTitle(aor.split(":")[1])
|
||||
|
||||
uri = findViewById(R.id.Uri) as TextView
|
||||
uri.setText(acc.uri)
|
||||
|
||||
displayName = findViewById(R.id.DisplayName) as EditText
|
||||
displayName.setText(acc.displayName)
|
||||
|
||||
@@ -22,7 +22,7 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
val rowView = inflater.inflate(R.layout.account_row, parent, false)
|
||||
val aorView = rowView.findViewById(R.id.aor) as TextView
|
||||
aorView.text = row.aor
|
||||
aorView.text = row.aor.split(":")[0]
|
||||
aorView.textSize = 20f
|
||||
aorView.setPadding(6, 6, 0, 6)
|
||||
aorView.setOnClickListener { _ ->
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.*
|
||||
|
||||
@@ -65,10 +66,16 @@ class AccountsActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.help -> {
|
||||
Utils.alertView(this@AccountsActivity, "New Account",
|
||||
getString(R.string.accounts_help))
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
Log.d("Baresip", "Back array was pressed at Accounts")
|
||||
BaresipService.activities.removeAt(0)
|
||||
@@ -76,10 +83,15 @@ class AccountsActivity : AppCompatActivity() {
|
||||
setResult(RESULT_OK, i)
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
menuInflater.inflate(R.menu.accounts_menu, menu)
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class CallsActivity : AppCompatActivity() {
|
||||
account = ua.account
|
||||
|
||||
val headerView = findViewById(R.id.account) as TextView
|
||||
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
||||
val headerText = "${getString(R.string.account)} ${aor.split(":")[1]}"
|
||||
headerView.text = headerText
|
||||
|
||||
val listView = findViewById(R.id.calls) as ListView
|
||||
|
||||
@@ -34,7 +34,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
BaresipService.activities.add(0, "chats,$aor")
|
||||
|
||||
val headerView = findViewById(R.id.account) as TextView
|
||||
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
||||
val headerText = "${getString(R.string.account)} ${aor.split(":")[1]}"
|
||||
headerView.text = headerText
|
||||
|
||||
uaMessages = uaMessages(aor)
|
||||
|
||||
@@ -26,7 +26,7 @@ class UaSpinnerAdapter(private val cxt: Context, private val uas: ArrayList<User
|
||||
val inflater = cxt.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
val row = inflater.inflate(R.layout.account_spinner, parent, false)
|
||||
val textView = row.findViewById(R.id.spinnerText) as TextView
|
||||
textView.text = uas[position].account.aor.replace("sip:", "")
|
||||
textView.text = uas[position].account.aor.split(":")[1]
|
||||
textView.textSize = 17f
|
||||
val imageView = row.findViewById(R.id.spinnerImage) as ImageView
|
||||
imageView.setImageResource(images[position])
|
||||
|
||||
@@ -97,12 +97,23 @@ object Utils {
|
||||
}
|
||||
|
||||
fun checkAor(aor: String): Boolean {
|
||||
val parts = aor.split(":")
|
||||
if (parts.size == 1)
|
||||
return checkUriUser(aorUser(aor)) && checkDomain(aorDomain(aor))
|
||||
val p = aor.split(":")
|
||||
if (p.size == 2)
|
||||
return checkUriUser(aorUser(p[0])) && checkDomain(aorDomain(p[0])) &&
|
||||
checkPortTransport(p[1])
|
||||
val t = aor.split(";transport=")
|
||||
if (t.size == 2)
|
||||
return checkUriUser(aorUser(t[0])) && checkDomain(aorDomain(t[0])) &&
|
||||
t[1] in arrayOf("udp", "tcp", "tls")
|
||||
return checkUriUser(aorUser(aor)) && checkDomain(aorDomain(aor))
|
||||
}
|
||||
|
||||
private fun checkPortTransport(portTransport: String): Boolean {
|
||||
val pt = portTransport.split(";transport=")
|
||||
if (pt.count() == 1)
|
||||
return checkPort(pt[0])
|
||||
else
|
||||
return checkUriUser(aorUser(parts[0])) && checkDomain(aorDomain(parts[0])) &&
|
||||
checkPort(parts[1])
|
||||
return checkPort(pt[0]) && pt[1] in arrayOf("udp", "tcp", "tls")
|
||||
}
|
||||
|
||||
private fun checkE164Number(no: String): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user