Added Call/Dial option to contacts screen menu

This commit is contained in:
Juha Heinanen
2026-07-09 09:39:21 +03:00
parent da22fbc5f5
commit bc4659859a
6 changed files with 26 additions and 2 deletions

View File

@ -3156,6 +3156,7 @@ class BaresipService: Service() {
}
var contactsMode by mutableStateOf("baresip")
var contactAction by mutableStateOf("call")
var addressFamily = ""
var dnsServers = listOf<InetAddress>()

View File

@ -172,6 +172,13 @@ object Config {
config = "${config}contacts_mode $contactsMode\n"
BaresipService.contactsMode = contactsMode
val contactAction = previousVariable("contact_action")
config = if (contactAction != "")
"${config}contact_action $contactAction\n"
else
"${config}contact_action call\n"
BaresipService.contactAction = if (contactAction != "") contactAction else "call"
config = "${config}snd_path ${BaresipService.filesPath}/recordings\n"
val callVolume = previousVariable("call_volume")

View File

@ -740,7 +740,7 @@ private fun UrisSection(
val intent = Intent(ctx, MainActivity::class.java)
intent.putExtra("uap", ua.uap)
intent.putExtra("peer", uri)
handleIntent(ctx, viewModel, intent, "call")
handleIntent(ctx, viewModel, intent, BaresipService.contactAction)
navController.navigate("main") {
popUpTo("main") { inclusive = false }
launchSingleTop = true

View File

@ -292,6 +292,13 @@ private fun ContactsScreen(navController: NavController) {
}
}
val call = stringResource(R.string.call)
val dial = stringResource(R.string.dial)
val contactActionName = remember(BaresipService.contactAction) {
listOf(if (BaresipService.contactAction == "call") call else dial)
}
val contactNames = remember(BaresipService.contactsMode) {
val names = mutableListOf("baresip", "Android", both)
val values = listOf("baresip", "android", "both")
@ -413,9 +420,16 @@ private fun ContactsScreen(navController: NavController) {
CustomElements.DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
items = contactNames + import + export + delete,
items = contactNames + contactActionName + import + export + delete,
onItemClick = { name ->
expanded = false
if (name == call || name == dial) {
val newAction = if (BaresipService.contactAction == "call") "dial" else "call"
BaresipService.contactAction = newAction
Config.replaceVariable("contact_action", newAction)
Config.save()
return@DropdownMenu
}
if (name == import) {
vcfImportLauncher.launch(arrayOf("text/vcard", "text/x-vcard"))
return@DropdownMenu

View File

@ -295,6 +295,7 @@
<!-- Calls Activity -->
<string name="call_history">Puheluhistoria</string>
<string name="call">Soita</string>
<string name="dial">Näytä</string>
<string name="calls_calls">puhelut</string>
<string name="calls_call">puhelun</string>
<string name="direction">Suunta</string>

View File

@ -291,6 +291,7 @@
<string name="call_history">Call History</string>
<string name="call_details">Call Details</string>
<string name="call">Call</string>
<string name="dial">Dial</string>
<string name="calls_calls">calls</string>
<string name="calls_call">call</string>
<string name="peer">Peer</string>