Added possibility on calls screen to copy URI of call to clipboard

This commit is contained in:
Juha Heinanen
2026-06-05 10:05:15 +03:00
parent d51ca57217
commit 7df6ee5b37
4 changed files with 33 additions and 8 deletions

View File

@ -414,6 +414,10 @@ private fun Calls(
peerNameWithLabel, callText
)
secondButtonText.value = ""
thirdButtonText.value = ctx.getString(R.string.copy_uri)
thirdAction.value = {
Utils.copyToClipboard(ctx, peerUri)
}
lastButtonText.value = ctx.getString(R.string.delete)
lastAction.value = {
removeFromHistory(callHistory, callRow)
@ -422,13 +426,18 @@ private fun Calls(
else {
message.value = String.format(
ctx.getString(R.string.calls_add_delete_question),
peerNameWithLabel, callText
peerNameWithLabel,
callText
)
secondButtonText.value = ctx.getString(R.string.add_contact)
secondAction.value = {
val uri = Utils.sipToTel(peerUri)
navController.navigate("contact/$uri/new")
}
thirdButtonText.value = ctx.getString(R.string.copy_uri)
thirdAction.value = {
Utils.copyToClipboard(ctx, peerUri)
}
lastButtonText.value = ctx.getString(R.string.delete)
lastAction.value = {
removeFromHistory(callHistory, callRow)

View File

@ -5,6 +5,9 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.app.KeyguardManager
import android.app.role.RoleManager
import android.widget.Toast
import android.content.ClipData
import android.content.ClipboardManager
import android.content.ContentResolver
import android.content.Context
import android.content.Context.ROLE_SERVICE
@ -263,7 +266,7 @@ object Utils {
}
fun checkUriUser(user: String): Boolean {
val escaped = """%(\d|A|B|C|D|E|F|a|b|c|d|e|f){2}""".toRegex()
val escaped = """%([\dABCDEFabcdef]){2}""".toRegex()
escaped.replace(user, "").forEach {
if (!(it.isLetterOrDigit() || "-_.!~*\'()&=+$,;?/".contains(it))) return false }
return user.isNotEmpty() && !checkIpV4(user) && !checkIpV6(user)
@ -522,6 +525,13 @@ object Utils {
return true
}
fun copyToClipboard(ctx: Context, text: String) {
val clipboard = ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("text", text)
clipboard.setPrimaryClip(clip)
Toast.makeText(ctx, ctx.getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
}
fun copyAssetToFile(context: Context, asset: String, path: String) {
try {
context.assets.open(asset).use { `is` ->

View File

@ -292,10 +292,11 @@
<string name="peer">Kumppani</string>
<string name="time">Aika</string>
<string name="calls_duration">Kesto</string>
<string name="calls_add_delete_question">Haluatko luoda uuden yhteystiedon \'%1$s\' tai poistaa
%2$s puheluhistoriasta\?
<string name="calls_add_delete_question">Haluatko luoda kohteelle \'%1$s\' uuden yhteystiedon,
kopioida sen URI:n tai poistaa %2$s puheluhistoriasta\?
</string>
<string name="calls_delete_question">Haluatko poistaa \'%1$s\' %2$s puheluhistoriasta\?</string>
<string name="calls_delete_question">Haluatko kopioida yhteystiedon \'%1$s\' URI:n tai poistaa
%2$s puheluhistoriasta\?</string>
<string name="disable_history">Poista käytöstä</string>
<string name="enable_history">Ota käyttöön</string>
<string name="delete_history_alert">Haluatko tyhjentää tilin \'%1$s\' puheluhistorian\?</string>
@ -530,6 +531,8 @@
<string name="add">Lisää</string>
<string name="delete">Poista</string>
<string name="edit">Muokkaa</string>
<string name="copy_uri">Kopioi URI</string>
<string name="copied_to_clipboard">Kopioitu leikepöydälle</string>
<string name="status">Tila</string>
<string name="error">Virhe</string>
<string name="confirmation">Vahvistus</string>

View File

@ -281,9 +281,10 @@
<string name="direction">Direction</string>
<string name="time">Time</string>
<string name="calls_duration">Duration</string>
<string name="calls_add_delete_question">Do you want to add \'%1$s\' to contacts or delete
%2$s from call history\?</string>
<string name="calls_delete_question">Do you want to delete \'%1$s\' %2$s from call history\?</string>
<string name="calls_add_delete_question">Do you want to add \'%1$s\' to contacts, copy its URI,
or delete this %2$s from call history\?</string>
<string name="calls_delete_question">Do you want to copy URI of \'%1$s\' or delete this %2$s
from call history\?</string>
<string name="disable_history">Disable</string>
<string name="enable_history">Enable</string>
<string name="delete_history_alert">Do you want to delete call history of account \'%1$s\'\?</string>
@ -504,6 +505,8 @@
<string name="add">Add</string>
<string name="delete">Delete</string>
<string name="edit">Edit</string>
<string name="copy_uri">Copy URI</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="status">Status</string>
<string name="error">Error</string>
<string name="confirmation">Confirmation</string>