Added Custom Parameters account setting
This commit is contained in:
@@ -40,6 +40,7 @@ class Account(val accp: Long) {
|
|||||||
var telProvider = Utils.aorDomain(aor)
|
var telProvider = Utils.aorDomain(aor)
|
||||||
var resumeUri = ""
|
var resumeUri = ""
|
||||||
var numericKeypad = false
|
var numericKeypad = false
|
||||||
|
var customParams = ""
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
@@ -80,6 +81,7 @@ class Account(val accp: Long) {
|
|||||||
if (Utils.paramExists(extra, "tel_provider"))
|
if (Utils.paramExists(extra, "tel_provider"))
|
||||||
telProvider = URLDecoder.decode(Utils.paramValue(extra, "tel_provider"), "UTF-8")
|
telProvider = URLDecoder.decode(Utils.paramValue(extra, "tel_provider"), "UTF-8")
|
||||||
numericKeypad = Utils.paramExists(extra, "numeric_keypad")
|
numericKeypad = Utils.paramExists(extra, "numeric_keypad")
|
||||||
|
customParams = extra.substringAfter("last=empty").substringAfter(";")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print() : String {
|
fun print() : String {
|
||||||
@@ -166,7 +168,8 @@ class Account(val accp: Long) {
|
|||||||
if (blockUnknown)
|
if (blockUnknown)
|
||||||
extra += ";block_unknown=yes"
|
extra += ";block_unknown=yes"
|
||||||
|
|
||||||
extra += ";tel_provider=${URLEncoder.encode(telProvider, "UTF-8")}"
|
if (telProvider != "")
|
||||||
|
extra += ";tel_provider=${URLEncoder.encode(telProvider, "UTF-8")}"
|
||||||
|
|
||||||
if (countryCode != "")
|
if (countryCode != "")
|
||||||
extra += ";country_code=$countryCode"
|
extra += ";country_code=$countryCode"
|
||||||
@@ -177,8 +180,15 @@ class Account(val accp: Long) {
|
|||||||
if (numericKeypad)
|
if (numericKeypad)
|
||||||
extra += ";numeric_keypad=yes"
|
extra += ";numeric_keypad=yes"
|
||||||
|
|
||||||
if (extra !="")
|
extra += ";last=empty"
|
||||||
res += ";extra=\"" + extra.substringAfter(";") + "\""
|
|
||||||
|
if (customParams != "")
|
||||||
|
extra += ";$customParams"
|
||||||
|
|
||||||
|
res += ";extra=\"" + extra.substringAfter(";") + "\""
|
||||||
|
|
||||||
|
if (customParams != "")
|
||||||
|
res += ";$customParams"
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@@ -261,7 +271,7 @@ class Account(val accp: Long) {
|
|||||||
BaresipService.filesPath + "/accounts",
|
BaresipService.filesPath + "/accounts",
|
||||||
accounts.toByteArray(Charsets.UTF_8)
|
accounts.toByteArray(Charsets.UTF_8)
|
||||||
)
|
)
|
||||||
// Log.d(TAG, "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
|
Log.d(TAG, "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ofAor(aor: String): Account? {
|
fun ofAor(aor: String): Account? {
|
||||||
|
|||||||
@@ -1194,6 +1194,35 @@ private fun AccountContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CustomParams() {
|
||||||
|
val customParamsTitle = stringResource(R.string.custom_parameters)
|
||||||
|
val customParamsHelp = stringResource(R.string.custom_parameters_help)
|
||||||
|
val customParams by viewModel.customParams.collectAsState()
|
||||||
|
Row(
|
||||||
|
Modifier.fillMaxWidth().padding(top = 8.dp, end = 10.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = customParams,
|
||||||
|
placeholder = { Text(customParamsTitle) },
|
||||||
|
onValueChange = { viewModel.customParams.value = it },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable {
|
||||||
|
alertTitle.value = customParamsTitle
|
||||||
|
alertMessage.value = customParamsHelp
|
||||||
|
showAlert.value = true
|
||||||
|
},
|
||||||
|
singleLine = true,
|
||||||
|
textStyle = TextStyle(fontSize = 18.sp),
|
||||||
|
label = { Text(customParamsTitle) },
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showAlert.value) {
|
if (showAlert.value) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
@@ -1248,6 +1277,7 @@ private fun AccountContent(
|
|||||||
TelProvider()
|
TelProvider()
|
||||||
NumericKeypad()
|
NumericKeypad()
|
||||||
DefaultAccount()
|
DefaultAccount()
|
||||||
|
CustomParams()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1615,6 +1645,12 @@ private fun checkOnClick(ctx: Context, viewModel: AccountViewModel, ua: UserAgen
|
|||||||
Log.d(TAG, "New numericKeyboard is ${acc.numericKeypad}")
|
Log.d(TAG, "New numericKeyboard is ${acc.numericKeypad}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val newCustomParams = viewModel.customParams.value
|
||||||
|
if (newCustomParams != acc.customParams) {
|
||||||
|
acc.customParams = newCustomParams
|
||||||
|
Log.d(TAG, "New customParams is ${acc.customParams}")
|
||||||
|
}
|
||||||
|
|
||||||
if (viewModel.defaultAccount.value) ua.makeDefault()
|
if (viewModel.defaultAccount.value) ua.makeDefault()
|
||||||
|
|
||||||
Api.account_debug(acc.accp)
|
Api.account_debug(acc.accp)
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ class AccountViewModel: ViewModel() {
|
|||||||
val vmUri = MutableStateFlow("")
|
val vmUri = MutableStateFlow("")
|
||||||
val countryCode = MutableStateFlow("")
|
val countryCode = MutableStateFlow("")
|
||||||
val telProvider = MutableStateFlow("")
|
val telProvider = MutableStateFlow("")
|
||||||
val defaultAccount = MutableStateFlow(false)
|
|
||||||
val numericKeypad = MutableStateFlow(false)
|
val numericKeypad = MutableStateFlow(false)
|
||||||
|
|
||||||
|
val defaultAccount = MutableStateFlow(false)
|
||||||
|
val customParams = MutableStateFlow("")
|
||||||
|
|
||||||
private var isLoaded = false
|
private var isLoaded = false
|
||||||
|
|
||||||
fun loadAccount(acc: Account) {
|
fun loadAccount(acc: Account) {
|
||||||
@@ -63,5 +65,6 @@ class AccountViewModel: ViewModel() {
|
|||||||
telProvider.value = acc.telProvider
|
telProvider.value = acc.telProvider
|
||||||
numericKeypad.value = acc.numericKeypad
|
numericKeypad.value = acc.numericKeypad
|
||||||
defaultAccount.value = UserAgent.findAorIndex(acc.aor)!! == 0
|
defaultAccount.value = UserAgent.findAorIndex(acc.aor)!! == 0
|
||||||
|
customParams.value = acc.customParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,6 +328,11 @@ object Utils {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun customParams(params: String): String {
|
||||||
|
return params.substringAfter("last=empty")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun checkHostPortParams(hpp: String) : Boolean {
|
fun checkHostPortParams(hpp: String) : Boolean {
|
||||||
val restParams = hpp.split(";", limit = 2)
|
val restParams = hpp.split(";", limit = 2)
|
||||||
return if (restParams.size == 1)
|
return if (restParams.size == 1)
|
||||||
|
|||||||
@@ -240,6 +240,9 @@
|
|||||||
<string name="default_account_help">Jos merkitty, niin tämä tili on
|
<string name="default_account_help">Jos merkitty, niin tämä tili on
|
||||||
valittuna, kun baresip käynnistetään.
|
valittuna, kun baresip käynnistetään.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="custom_parameters">Räätälöidyt parametrit</string>
|
||||||
|
<string name="custom_parameters_help">Puolipisteellä toisistaan eroteltu lista
|
||||||
|
räätälöityjä tilin parametrejä</string>
|
||||||
<!-- Accounts Activity -->
|
<!-- Accounts Activity -->
|
||||||
<string name="accounts">Tilit</string>
|
<string name="accounts">Tilit</string>
|
||||||
<string name="new_account">Uuden tilin SIP URI</string>
|
<string name="new_account">Uuden tilin SIP URI</string>
|
||||||
|
|||||||
@@ -229,6 +229,8 @@
|
|||||||
<string name="default_account">Default Account</string>
|
<string name="default_account">Default Account</string>
|
||||||
<string name="default_account_help">If checked, this account is selected when baresip is started.
|
<string name="default_account_help">If checked, this account is selected when baresip is started.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="custom_parameters">Custom Parameters</string>
|
||||||
|
<string name="custom_parameters_help">Semicolor separeted list of custom account parameters</string>
|
||||||
<!-- Accounts Activity -->
|
<!-- Accounts Activity -->
|
||||||
<string name="accounts">Accounts</string>
|
<string name="accounts">Accounts</string>
|
||||||
<string name="new_account">SIP URI of New Account</string>
|
<string name="new_account">SIP URI of New Account</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user