- Added UserAgent add, remove, and updateStatus methods.
This commit is contained in:
@@ -323,12 +323,12 @@ class AccountActivity : AppCompatActivity() {
|
|||||||
if (regCheck.isChecked) {
|
if (regCheck.isChecked) {
|
||||||
if (acc.regint != 3600) {
|
if (acc.regint != 3600) {
|
||||||
newRegint = 3600
|
newRegint = 3600
|
||||||
UserAgent.updateStatus(ua, R.drawable.dot_yellow)
|
ua.updateStatus(R.drawable.dot_yellow)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (acc.regint != 0) {
|
if (acc.regint != 0) {
|
||||||
Api.ua_unregister(ua.uap)
|
Api.ua_unregister(ua.uap)
|
||||||
UserAgent.updateStatus(ua, R.drawable.dot_white)
|
ua.updateStatus(R.drawable.dot_white)
|
||||||
newRegint = 0
|
newRegint = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
|
|||||||
Api.ua_destroy(ua.uap)
|
Api.ua_destroy(ua.uap)
|
||||||
CallHistory.clear(ua.account.aor)
|
CallHistory.clear(ua.account.aor)
|
||||||
Message.clear(ua.account.aor)
|
Message.clear(ua.account.aor)
|
||||||
UserAgent.remove(ua)
|
ua.remove()
|
||||||
AccountsActivity.generateAccounts()
|
AccountsActivity.generateAccounts()
|
||||||
AccountsActivity.saveAccounts()
|
AccountsActivity.saveAccounts()
|
||||||
this.notifyDataSetChanged()
|
this.notifyDataSetChanged()
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
newAorView.setText("")
|
newAorView.setText("")
|
||||||
newAorView.hint = getString(R.string.user_domain)
|
newAorView.hint = getString(R.string.user_domain)
|
||||||
newAorView.clearFocus()
|
newAorView.clearFocus()
|
||||||
UserAgent.add(ua, R.drawable.dot_white)
|
ua.add(R.drawable.dot_white)
|
||||||
generateAccounts()
|
generateAccounts()
|
||||||
alAdapter.notifyDataSetChanged()
|
alAdapter.notifyDataSetChanged()
|
||||||
saveAccounts()
|
saveAccounts()
|
||||||
|
|||||||
@@ -5,6 +5,21 @@ class UserAgent(val uap: String) {
|
|||||||
val account = Account(Api.ua_account(uap))
|
val account = Account(Api.ua_account(uap))
|
||||||
var registrationFailed = false
|
var registrationFailed = false
|
||||||
|
|
||||||
|
fun add(status: Int) {
|
||||||
|
BaresipService.uas.add(this)
|
||||||
|
BaresipService.status.add(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun remove() {
|
||||||
|
val index = BaresipService.uas.indexOf(this)
|
||||||
|
BaresipService.uas.remove(this)
|
||||||
|
BaresipService.status.removeAt(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateStatus(status: Int) {
|
||||||
|
BaresipService.status[BaresipService.uas.indexOf(this)] = status
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun uas(): ArrayList<UserAgent> {
|
fun uas(): ArrayList<UserAgent> {
|
||||||
@@ -15,26 +30,6 @@ class UserAgent(val uap: String) {
|
|||||||
return BaresipService.status
|
return BaresipService.status
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(ua: UserAgent, status: Int) {
|
|
||||||
BaresipService.uas.add(ua)
|
|
||||||
BaresipService.status.add(status)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun remove(ua: UserAgent) {
|
|
||||||
val index = BaresipService.uas.indexOf(ua)
|
|
||||||
if (index != -1) {
|
|
||||||
BaresipService.uas.removeAt(index)
|
|
||||||
BaresipService.status.removeAt(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateStatus(ua: UserAgent, status: Int) {
|
|
||||||
val index = BaresipService.uas.indexOf(ua)
|
|
||||||
if (index != -1) {
|
|
||||||
BaresipService.status[index] = status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ofAor(aor: String): UserAgent? {
|
fun ofAor(aor: String): UserAgent? {
|
||||||
for (ua in BaresipService.uas)
|
for (ua in BaresipService.uas)
|
||||||
if (ua.account.aor == aor) return ua
|
if (ua.account.aor == aor) return ua
|
||||||
|
|||||||
Reference in New Issue
Block a user