Modified calls and blocked screen click actions when peer is hidden
This commit is contained in:
@ -1946,7 +1946,7 @@ class BaresipService: Service() {
|
||||
}
|
||||
|
||||
fun handleExternalCall(telecomCall: android.telecom.Call, preferredAor: String? = null) {
|
||||
val rawUri = telecomCall.details.handle?.toString() ?: "Unknown"
|
||||
val rawUri = telecomCall.details.handle?.toString() ?: getString(R.string.unknown)
|
||||
val uri = Utils.uriUnescape(rawUri)
|
||||
|
||||
if (uas.value.isEmpty()) {
|
||||
|
||||
@ -253,6 +253,7 @@ private fun Blocked(ctx: Context, navController: NavController, blocked: Mutable
|
||||
val message = remember { mutableStateOf("") }
|
||||
val lastButtonText = remember { mutableStateOf("") }
|
||||
val lastAction = remember { mutableStateOf({}) }
|
||||
val unknown = stringResource(R.string.unknown)
|
||||
|
||||
AlertDialog(
|
||||
showDialog = showDialog,
|
||||
@ -278,15 +279,18 @@ private fun Blocked(ctx: Context, navController: NavController, blocked: Mutable
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.clickable(onClick = {
|
||||
message.value = String.format(ctx.getString(R.string.blocked_contact_question),
|
||||
peerUri)
|
||||
lastButtonText.value = ctx.getString(R.string.add_contact)
|
||||
lastAction.value = {
|
||||
navController.navigate("contact/$peerUri/new")
|
||||
.clickable(
|
||||
enabled = !peerUri.contains("anonymous") && peerUri != unknown,
|
||||
onClick = {
|
||||
message.value = String.format(ctx.getString(R.string.blocked_contact_question),
|
||||
peerUri)
|
||||
lastButtonText.value = ctx.getString(R.string.add_contact)
|
||||
lastAction.value = {
|
||||
navController.navigate("contact/$peerUri/new")
|
||||
}
|
||||
showDialog.value = true
|
||||
}
|
||||
showDialog.value = true
|
||||
})
|
||||
)
|
||||
) {
|
||||
Text(text = "\u2022",
|
||||
modifier = Modifier.padding(start = 8.dp, end = 4.dp),
|
||||
|
||||
@ -304,6 +304,7 @@ private fun Calls(
|
||||
val alertTitle = remember { mutableStateOf("") }
|
||||
val alertMessage = remember { mutableStateOf("") }
|
||||
val showAlert = remember { mutableStateOf(false) }
|
||||
val unknown = stringResource(R.string.unknown)
|
||||
|
||||
AlertDialog(
|
||||
showDialog = showAlert,
|
||||
@ -334,73 +335,81 @@ private fun Calls(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = {
|
||||
val intent = Intent(ctx, MainActivity::class.java)
|
||||
intent.putExtra("uap", ua.uap)
|
||||
intent.putExtra("peer", peerUri)
|
||||
val peerNameWithLabel = Utils.friendlyUri(ctx, peerUri, ua.account)
|
||||
val contact = Contact.findContact(peerUri)
|
||||
if (contact is Contact.BaresipContact && contact.email.isNotEmpty())
|
||||
message.value = String.format(
|
||||
ctx.getString(R.string.contact_email_action_question),
|
||||
peerNameWithLabel
|
||||
)
|
||||
else
|
||||
message.value = String.format(
|
||||
ctx.getString(R.string.contact_action_question),
|
||||
peerNameWithLabel
|
||||
)
|
||||
secondButtonText.value = ctx.getString(R.string.call)
|
||||
secondAction.value = {
|
||||
if (ua.account.isMobile && ua.status != circleGreen.getValue(colorblind)) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value = ctx.getString(R.string.airplane_mode)
|
||||
showAlert.value = true
|
||||
} else {
|
||||
handleIntent(ctx, viewModel, intent, "call")
|
||||
navController.navigate("main") {
|
||||
popUpTo("main")
|
||||
launchSingleTop = true
|
||||
if (!peerUri.contains("anonymous") && peerUri != unknown) {
|
||||
val intent = Intent(ctx, MainActivity::class.java)
|
||||
intent.putExtra("uap", ua.uap)
|
||||
intent.putExtra("peer", peerUri)
|
||||
val peerNameWithLabel = Utils.friendlyUri(ctx, peerUri, ua.account)
|
||||
val contact = Contact.findContact(peerUri)
|
||||
if (contact is Contact.BaresipContact && contact.email.isNotEmpty())
|
||||
message.value = String.format(
|
||||
ctx.getString(R.string.contact_email_action_question),
|
||||
peerNameWithLabel
|
||||
)
|
||||
else
|
||||
message.value = String.format(
|
||||
ctx.getString(R.string.contact_action_question),
|
||||
peerNameWithLabel
|
||||
)
|
||||
secondButtonText.value = ctx.getString(R.string.call)
|
||||
secondAction.value = {
|
||||
if (ua.account.isMobile && ua.status != circleGreen.getValue(
|
||||
colorblind
|
||||
)
|
||||
) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value =
|
||||
ctx.getString(R.string.airplane_mode)
|
||||
showAlert.value = true
|
||||
} else {
|
||||
handleIntent(ctx, viewModel, intent, "call")
|
||||
navController.navigate("main") {
|
||||
popUpTo("main")
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
thirdButtonText.value = ctx.getString(R.string.send_message)
|
||||
thirdAction.value = {
|
||||
if (ua.account.isMobile) {
|
||||
if (ua.status != circleGreen.getValue(colorblind)) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value = ctx.getString(R.string.airplane_mode)
|
||||
showAlert.value = true
|
||||
} else if (!Utils.isDefaultSmsApp(ctx)) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value = ctx.getString(R.string.enable_default_messaging)
|
||||
showAlert.value = true
|
||||
}
|
||||
else {
|
||||
thirdButtonText.value = ctx.getString(R.string.send_message)
|
||||
thirdAction.value = {
|
||||
if (ua.account.isMobile) {
|
||||
if (ua.status != circleGreen.getValue(colorblind)) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value =
|
||||
ctx.getString(R.string.airplane_mode)
|
||||
showAlert.value = true
|
||||
} else if (!Utils.isDefaultSmsApp(ctx)) {
|
||||
alertTitle.value = ctx.getString(R.string.notice)
|
||||
alertMessage.value =
|
||||
ctx.getString(R.string.enable_default_messaging)
|
||||
showAlert.value = true
|
||||
} else {
|
||||
handleIntent(ctx, viewModel, intent, "message")
|
||||
navController.navigateUp()
|
||||
}
|
||||
} else {
|
||||
handleIntent(ctx, viewModel, intent, "message")
|
||||
navController.navigateUp()
|
||||
}
|
||||
}
|
||||
else {
|
||||
handleIntent(ctx, viewModel, intent, "message")
|
||||
navController.navigateUp()
|
||||
}
|
||||
}
|
||||
if (contact is Contact.BaresipContact && contact.email.isNotEmpty()) {
|
||||
lastButtonText.value = ctx.getString(R.string.send_email)
|
||||
lastAction.value = {
|
||||
val emailIntent = Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = "mailto:${contact.email}".toUri()
|
||||
if (contact is Contact.BaresipContact && contact.email.isNotEmpty()) {
|
||||
lastButtonText.value = ctx.getString(R.string.send_email)
|
||||
lastAction.value = {
|
||||
val emailIntent = Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = "mailto:${contact.email}".toUri()
|
||||
}
|
||||
try {
|
||||
ctx.startActivity(emailIntent)
|
||||
} catch (e: Exception) {
|
||||
Log.e(
|
||||
TAG,
|
||||
"Failed to start email activity: ${e.message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
try {
|
||||
ctx.startActivity(emailIntent)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Failed to start email activity: ${e.message}")
|
||||
}
|
||||
}
|
||||
} else
|
||||
lastButtonText.value = ""
|
||||
showDialog.value = true
|
||||
}
|
||||
else
|
||||
lastButtonText.value = ""
|
||||
showDialog.value = true
|
||||
},
|
||||
onLongClick = {
|
||||
val peerName = Utils.friendlyUri(ctx, peerUri, ua.account, includeLabel = false)
|
||||
@ -410,7 +419,7 @@ private fun Calls(
|
||||
else
|
||||
ctx.getString(R.string.calls_call)
|
||||
val contactExists = Contact.nameExists(peerName, BaresipService.contacts, false)
|
||||
if (contactExists) {
|
||||
if (contactExists || peerUri.contains("anonymous") || peerUri == unknown) {
|
||||
message.value = String.format(
|
||||
ctx.getString(R.string.calls_delete_question),
|
||||
peerNameWithLabel, callText
|
||||
|
||||
Reference in New Issue
Block a user