Added Numeric Keypad to account settings

This commit is contained in:
Juha Heinanen
2025-04-29 08:27:46 +03:00
parent 3d2c1b3fef
commit 494c6501ff
5 changed files with 46 additions and 5 deletions

View File

@ -40,7 +40,7 @@ class Account(val accp: Long) {
var countryCode = ""
var telProvider = Utils.aorDomain(aor)
var resumeUri = ""
var numericKeyboard = false
var numericKeypad = false
init {
@ -79,7 +79,7 @@ class Account(val accp: Long) {
countryCode = Utils.paramValue(extra, "country_code")
if (Utils.paramExists(extra, "tel_provider"))
telProvider = URLDecoder.decode(Utils.paramValue(extra, "tel_provider"), "UTF-8")
numericKeyboard = Utils.paramExists(extra, "numeric_keyboard")
numericKeypad = Utils.paramExists(extra, "numeric_keypad")
}
fun print() : String {
@ -169,8 +169,8 @@ class Account(val accp: Long) {
if (configuredRegInt != REGISTRATION_INTERVAL)
extra += ";regint=$configuredRegInt"
if (numericKeyboard)
extra += ";numeric_keyboard=yes"
if (numericKeypad)
extra += ";numeric_keypad=yes"
if (extra !="")
res += ";extra=\"" + extra.substringAfter(";") + "\""

View File

@ -126,6 +126,7 @@ class AccountActivity : ComponentActivity() {
private var newTelProvider = ""
private var oldDefaultAccount = false
private var newDefaultAccount = false
private var newNumericKeypad = false
private var arrowTint = Color.Unspecified
private var password = mutableStateOf("")
private var showPasswordDialog = mutableStateOf(false)
@ -237,6 +238,7 @@ class AccountActivity : ComponentActivity() {
newCountryCode = oldCountryCode
oldTelProvider = acc.telProvider
newTelProvider = oldTelProvider
newNumericKeypad = acc.numericKeypad
oldDefaultAccount = UserAgent.findAorIndex(aor)!! == 0
newDefaultAccount = oldDefaultAccount
@ -356,6 +358,7 @@ class AccountActivity : ComponentActivity() {
Voicemail()
CountryCode()
TelProvider()
NumericKeypad()
DefaultAccount()
AskPassword(ctx)
}
@ -1208,6 +1211,33 @@ class AccountActivity : ComponentActivity() {
}
}
@Composable
fun NumericKeypad() {
Row(
Modifier.fillMaxWidth().padding(end=10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
Text(text = stringResource(R.string.numeric_keypad),
modifier = Modifier.weight(1f)
.clickable {
alertTitle.value = getString(R.string.numeric_keypad)
alertMessage.value = getString(R.string.numeric_keypad_help)
showAlert.value = true
},
fontSize = 18.sp,
color = LocalCustomColors.current.itemText)
var numericKeypad by remember { mutableStateOf(acc.numericKeypad) }
Switch(
checked = numericKeypad,
onCheckedChange = {
numericKeypad = it
newNumericKeypad = numericKeypad
}
)
}
}
@Composable
fun DefaultAccount() {
Row(
@ -1591,6 +1621,11 @@ class AccountActivity : ComponentActivity() {
Log.d(TAG, "New tel provider is ${acc.telProvider}")
}
if (newNumericKeypad != acc.numericKeypad) {
acc.numericKeypad = newNumericKeypad
Log.d(TAG, "New numericKeyboard is ${acc.numericKeypad}")
}
val uaIndex = UserAgent.findAorIndex(aor)!!
if (newDefaultAccount && (uaIndex > 0)) {
val updatedUas = uas.value.toMutableList()

View File

@ -1083,7 +1083,7 @@ class MainActivity : ComponentActivity() {
.onFocusChanged {
val account = Account.ofAor(viewModel.selectedAor.value)
if (account != null) {
dialpad = account.numericKeyboard
dialpad = account.numericKeypad
}
},
label = {

View File

@ -223,6 +223,9 @@
voi käyttää soitettaessa puhelinnumeroihin.
</string>
<string name="telephony_provider_hint">SIP URI:n domain osa</string>
<string name="numeric_keypad">Numeerinen näppäimistö</string>"
<string name="numeric_keypad_help">Jos valittu, \"Puhelu ulos …\" kentässä käytetään numeerista
näppäimistöä.</string>"
<string name="invalid_sip_uri_hostpart">Virheellinen SIP URI:n domain-osa \'%1$s\'</string>
<string name="default_account">Oletustili</string>
<string name="default_account_help">Jos merkitty, niin tämä tili on

View File

@ -209,6 +209,9 @@
telephone numbers.
</string>
<string name="telephony_provider_hint">SIP URI host part</string>
<string name="numeric_keypad">Numeric Keypad</string>"
<string name="numeric_keypad_help">If checked, numeric keypad is shown when \"Call to …\"
field is focused.</string>"
<string name="invalid_sip_uri_hostpart">Invalid SIP URI host part \'%1$s\'</string>
<string name="default_account">Default Account</string>
<string name="default_account_help">If checked, this account is selected when baresip is started.