Simplified callClick function

This commit is contained in:
Juha Heinanen
2026-05-01 14:14:30 +03:00
parent 1bbde476c0
commit 4cf2b5c078
@@ -2032,24 +2032,42 @@ private fun spinToAor(viewModel: ViewModel, aor: String) {
} }
private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel.DialerState?) { private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel.DialerState?) {
if (viewModel.selectedAor.value != "") { if (viewModel.selectedAor.value != "" && dialerState != null) {
if (Utils.checkPermissions(ctx, arrayOf(RECORD_AUDIO))) {
if (dialerState != null) {
val uriText = dialerState.callUri.value.trim() val uriText = dialerState.callUri.value.trim()
if (uriText.isNotEmpty()) { if (uriText.isNotEmpty()) {
if (Utils.checkPermissions(ctx, arrayOf(RECORD_AUDIO))) {
val uris = Contact.contactUris(uriText) val uris = Contact.contactUris(uriText)
if (uris.isEmpty()) if (uris.isEmpty())
makeCall(ctx, viewModel, uriText, dialerState.showCallConferenceButton.value) makeCall(
ctx,
viewModel,
uriText,
dialerState.showCallConferenceButton.value
)
else if (uris.size == 1) else if (uris.size == 1)
makeCall(ctx, viewModel, uris[0], dialerState.showCallConferenceButton.value) makeCall(
ctx,
viewModel,
uris[0],
dialerState.showCallConferenceButton.value
)
else { else {
selectItems.value = uris selectItems.value = uris
selectItemAction.value = { index -> selectItemAction.value = { index ->
makeCall(ctx, viewModel, uris[index], dialerState.showCallConferenceButton.value) makeCall(
ctx,
viewModel,
uris[index],
dialerState.showCallConferenceButton.value
)
} }
showSelectItemDialog.value = true showSelectItemDialog.value = true
} }
} else { }
else
Toast.makeText(ctx, R.string.no_calls, Toast.LENGTH_SHORT).show()
}
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)
@@ -2057,10 +2075,6 @@ private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel
} }
} }
} }
else
Toast.makeText(ctx, R.string.no_calls, Toast.LENGTH_SHORT).show()
}
}
private fun makeCall(ctx: Context, viewModel: ViewModel, uriText: String, conferenceCall: Boolean, private fun makeCall(ctx: Context, viewModel: ViewModel, uriText: String, conferenceCall: Boolean,
onHoldCallp: Long = 0L) { onHoldCallp: Long = 0L) {