Migration of user interface to Jetpack Compose
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.tutpro.baresip
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import java.net.URLEncoder
|
||||
@@ -8,10 +10,10 @@ import java.net.URLDecoder
|
||||
|
||||
class Account(val accp: Long) {
|
||||
|
||||
var nickName = ""
|
||||
val nickName: MutableState<String> = mutableStateOf("")
|
||||
var displayName = Api.account_display_name(accp)
|
||||
val aor = Api.account_aor(accp)
|
||||
var luri = Api.account_luri(accp)
|
||||
private var luri = Api.account_luri(accp)
|
||||
var authUser = Api.account_auth_user(accp)
|
||||
var authPass = Api.account_auth_pass(accp)
|
||||
var outbound = ArrayList<String>()
|
||||
@@ -68,7 +70,7 @@ class Account(val accp: Long) {
|
||||
|
||||
val extra = Api.account_extra(accp)
|
||||
if (Utils.paramExists(extra, "nickname"))
|
||||
nickName = Utils.paramValue(extra,"nickname")
|
||||
nickName.value = Utils.paramValue(extra,"nickname")
|
||||
if (Utils.paramExists(extra, "regint"))
|
||||
configuredRegInt = Utils.paramValue(extra,"regint").toInt()
|
||||
callHistory = Utils.paramValue(extra,"call_history") == ""
|
||||
@@ -151,8 +153,8 @@ class Account(val accp: Long) {
|
||||
|
||||
var extra = ""
|
||||
|
||||
if (nickName != "")
|
||||
extra += ";nickname=$nickName"
|
||||
if (nickName.value != "")
|
||||
extra += ";nickname=${nickName.value}"
|
||||
|
||||
if (!callHistory)
|
||||
extra += ";call_history=no"
|
||||
@@ -207,6 +209,13 @@ class Account(val accp: Long) {
|
||||
return aor.split("@")[1]
|
||||
}
|
||||
|
||||
fun text(): String {
|
||||
return if (nickName.value != "")
|
||||
nickName.value
|
||||
else
|
||||
aor.split(":")[1].substringBefore(";")
|
||||
}
|
||||
|
||||
private fun removeAudioCodecsStartingWith(prefix: String) {
|
||||
val newCodecs = ArrayList<String>()
|
||||
for (acSpec in audioCodec)
|
||||
@@ -229,14 +238,14 @@ class Account(val accp: Long) {
|
||||
|
||||
fun accounts(): ArrayList<Account> {
|
||||
val res = ArrayList<Account>()
|
||||
for (ua in BaresipService.uas) {
|
||||
for (ua in BaresipService.uas.value) {
|
||||
res.add(ua.account)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
fun ofAor(aor: String): Account? {
|
||||
for (ua in BaresipService.uas)
|
||||
for (ua in BaresipService.uas.value)
|
||||
if (ua.account.aor == aor) return ua.account
|
||||
return null
|
||||
}
|
||||
@@ -263,8 +272,8 @@ class Account(val accp: Long) {
|
||||
}
|
||||
|
||||
fun uniqueNickName(nickName: String): Boolean {
|
||||
for (ua in BaresipService.uas)
|
||||
if (ua.account.nickName == nickName)
|
||||
for (ua in BaresipService.uas.value)
|
||||
if (ua.account.nickName.value == nickName)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user