When redialing, don't ask again to select contact uri

This commit is contained in:
Juha Heinanen
2026-05-22 20:56:15 +03:00
parent 6a34328b97
commit 5eeb8a8b02
2 changed files with 34 additions and 35 deletions

View File

@ -1227,6 +1227,7 @@ private fun CallUriRow(
if (isDialer) { if (isDialer) {
if (it != dialerState.callUri.value) { if (it != dialerState.callUri.value) {
dialerState.callUri.value = it dialerState.callUri.value = it
dialerState.redialUri = ""
if (it == "") { if (it == "") {
dialerState.showCallButton.value = true dialerState.showCallButton.value = true
dialerState.showCallConferenceButton.value = true dialerState.showCallConferenceButton.value = true
@ -2042,6 +2043,7 @@ private fun spinToAor(viewModel: ViewModel, aor: String, call: Call? = null) {
} }
} }
// In MainScreen.kt, update callClick function
private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel.DialerState?) { private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel.DialerState?) {
if (viewModel.selectedAor.value != "" && dialerState != null) { if (viewModel.selectedAor.value != "" && dialerState != null) {
val uriText = dialerState.callUri.value.trim() val uriText = dialerState.callUri.value.trim()
@ -2049,43 +2051,37 @@ private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel
if (Utils.checkPermissions(ctx, arrayOf(RECORD_AUDIO))) { if (Utils.checkPermissions(ctx, arrayOf(RECORD_AUDIO))) {
val aor = viewModel.selectedAor.value val aor = viewModel.selectedAor.value
val ua = UserAgent.ofAor(aor) val ua = UserAgent.ofAor(aor)
val uris = Contact.contactUris(uriText, ua?.account?.isMobile ?: false) val uriToCall = if (dialerState.redialUri != "" &&
if (uris.isEmpty()) { uriText == Utils.friendlyUri(ctx, dialerState.redialUri, ua!!.account))
if (Contact.nameExists(uriText, BaresipService.contacts, true)) { dialerState.redialUri
alertTitle.value = ctx.getString(R.string.notice)
alertMessage.value = if (ua?.account?.isMobile == true)
String.format(ctx.getString(R.string.contact_no_tel_uri), uriText)
else
String.format(ctx.getString(R.string.contact_no_sip_or_tel_uri), uriText)
showAlert.value = true
}
else
makeCall(
ctx,
viewModel,
uriText,
dialerState
)
}
else if (uris.size == 1)
makeCall(
ctx,
viewModel,
uris[0],
dialerState
)
else { else {
selectItems.value = uris val uris = Contact.contactUris(uriText, ua?.account?.isMobile ?: false)
selectItemAction.value = { index -> if (uris.isEmpty()) {
makeCall( if (Contact.nameExists(uriText, BaresipService.contacts, true)) {
ctx, alertTitle.value = ctx.getString(R.string.notice)
viewModel, alertMessage.value = if (ua?.account?.isMobile == true)
uris[index], String.format(ctx.getString(R.string.contact_no_tel_uri), uriText)
dialerState else
) String.format(ctx.getString(R.string.contact_no_sip_or_tel_uri), uriText)
showAlert.value = true
return
}
uriText
}
else if (uris.size == 1)
uris[0]
else {
selectItems.value = uris
selectItemAction.value = { index ->
makeCall(ctx, viewModel, uris[index], dialerState)
}
showSelectItemDialog.value = true
return
} }
showSelectItemDialog.value = true
} }
dialerState.redialUri = ""
makeCall(ctx, viewModel, uriToCall, dialerState)
} }
else else
Toast.makeText(ctx, R.string.no_calls, Toast.LENGTH_SHORT).show() Toast.makeText(ctx, R.string.no_calls, Toast.LENGTH_SHORT).show()
@ -2093,8 +2089,10 @@ private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel
else { else {
val ua = UserAgent.ofAor(viewModel.selectedAor.value)!! val ua = UserAgent.ofAor(viewModel.selectedAor.value)!!
val latestPeerUri = CallHistoryNew.aorLatestPeerUri(ua.account.aor) val latestPeerUri = CallHistoryNew.aorLatestPeerUri(ua.account.aor)
if (latestPeerUri != null) if (latestPeerUri != null) {
dialerState.redialUri = latestPeerUri
dialerState.callUri.value = Utils.friendlyUri(ctx, latestPeerUri, ua.account) dialerState.callUri.value = Utils.friendlyUri(ctx, latestPeerUri, ua.account)
}
} }
} }
} }

View File

@ -42,6 +42,7 @@ class ViewModel: ViewModel() {
val callUri: MutableState<String> = mutableStateOf(""), val callUri: MutableState<String> = mutableStateOf(""),
val callUriEnabled: MutableState<Boolean> = mutableStateOf(true), val callUriEnabled: MutableState<Boolean> = mutableStateOf(true),
val callUriLabel: MutableState<String> = mutableStateOf(""), val callUriLabel: MutableState<String> = mutableStateOf(""),
var redialUri: String = "",
val showSuggestions: MutableState<Boolean> = mutableStateOf(false), val showSuggestions: MutableState<Boolean> = mutableStateOf(false),
val showCallButton: MutableState<Boolean> = mutableStateOf(true), val showCallButton: MutableState<Boolean> = mutableStateOf(true),
val showCallConferenceButton: MutableState<Boolean> = mutableStateOf(true), val showCallConferenceButton: MutableState<Boolean> = mutableStateOf(true),