Simplified callClick function
This commit is contained in:
@@ -2032,34 +2032,48 @@ 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)
|
||||||
dialerState.callUri.value = Utils.friendlyUri(ctx, latestPeerUri, ua.account)
|
dialerState.callUri.value = Utils.friendlyUri(ctx, latestPeerUri, ua.account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user