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