diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt
index d2c25392..25ccdb03 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt
@@ -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)
diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
index e9ecacab..eadc56bd 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
@@ -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` ->
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index 6cbe9e01..7d857d75 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -292,10 +292,11 @@
Kumppani
Aika
Kesto
- Haluatko luoda uuden yhteystiedon \'%1$s\' tai poistaa
- %2$s puheluhistoriasta\?
+ Haluatko luoda kohteelle \'%1$s\' uuden yhteystiedon,
+ kopioida sen URI:n tai poistaa %2$s puheluhistoriasta\?
- Haluatko poistaa \'%1$s\' %2$s puheluhistoriasta\?
+ Haluatko kopioida yhteystiedon \'%1$s\' URI:n tai poistaa
+ %2$s puheluhistoriasta\?
Poista käytöstä
Ota käyttöön
Haluatko tyhjentää tilin \'%1$s\' puheluhistorian\?
@@ -530,6 +531,8 @@
Lisää
Poista
Muokkaa
+ Kopioi URI
+ Kopioitu leikepöydälle
Tila
Virhe
Vahvistus
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b0cc8218..a5184a76 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -281,9 +281,10 @@
Direction
Time
Duration
- Do you want to add \'%1$s\' to contacts or delete
- %2$s from call history\?
- Do you want to delete \'%1$s\' %2$s from call history\?
+ Do you want to add \'%1$s\' to contacts, copy its URI,
+ or delete this %2$s from call history\?
+ Do you want to copy URI of \'%1$s\' or delete this %2$s
+ from call history\?
Disable
Enable
Do you want to delete call history of account \'%1$s\'\?
@@ -504,6 +505,8 @@
Add
Delete
Edit
+ Copy URI
+ Copied to clipboard
Status
Error
Confirmation