Added possibility on calls screen to copy URI of call to clipboard
This commit is contained in:
@ -414,6 +414,10 @@ private fun Calls(
|
|||||||
peerNameWithLabel, callText
|
peerNameWithLabel, callText
|
||||||
)
|
)
|
||||||
secondButtonText.value = ""
|
secondButtonText.value = ""
|
||||||
|
thirdButtonText.value = ctx.getString(R.string.copy_uri)
|
||||||
|
thirdAction.value = {
|
||||||
|
Utils.copyToClipboard(ctx, peerUri)
|
||||||
|
}
|
||||||
lastButtonText.value = ctx.getString(R.string.delete)
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
lastAction.value = {
|
lastAction.value = {
|
||||||
removeFromHistory(callHistory, callRow)
|
removeFromHistory(callHistory, callRow)
|
||||||
@ -422,13 +426,18 @@ private fun Calls(
|
|||||||
else {
|
else {
|
||||||
message.value = String.format(
|
message.value = String.format(
|
||||||
ctx.getString(R.string.calls_add_delete_question),
|
ctx.getString(R.string.calls_add_delete_question),
|
||||||
peerNameWithLabel, callText
|
peerNameWithLabel,
|
||||||
|
callText
|
||||||
)
|
)
|
||||||
secondButtonText.value = ctx.getString(R.string.add_contact)
|
secondButtonText.value = ctx.getString(R.string.add_contact)
|
||||||
secondAction.value = {
|
secondAction.value = {
|
||||||
val uri = Utils.sipToTel(peerUri)
|
val uri = Utils.sipToTel(peerUri)
|
||||||
navController.navigate("contact/$uri/new")
|
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)
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
lastAction.value = {
|
lastAction.value = {
|
||||||
removeFromHistory(callHistory, callRow)
|
removeFromHistory(callHistory, callRow)
|
||||||
|
|||||||
@ -5,6 +5,9 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.KeyguardManager
|
import android.app.KeyguardManager
|
||||||
import android.app.role.RoleManager
|
import android.app.role.RoleManager
|
||||||
|
import android.widget.Toast
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
import android.content.ContentResolver
|
import android.content.ContentResolver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.ROLE_SERVICE
|
import android.content.Context.ROLE_SERVICE
|
||||||
@ -263,7 +266,7 @@ object Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkUriUser(user: String): Boolean {
|
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 {
|
escaped.replace(user, "").forEach {
|
||||||
if (!(it.isLetterOrDigit() || "-_.!~*\'()&=+$,;?/".contains(it))) return false }
|
if (!(it.isLetterOrDigit() || "-_.!~*\'()&=+$,;?/".contains(it))) return false }
|
||||||
return user.isNotEmpty() && !checkIpV4(user) && !checkIpV6(user)
|
return user.isNotEmpty() && !checkIpV4(user) && !checkIpV6(user)
|
||||||
@ -522,6 +525,13 @@ object Utils {
|
|||||||
return true
|
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) {
|
fun copyAssetToFile(context: Context, asset: String, path: String) {
|
||||||
try {
|
try {
|
||||||
context.assets.open(asset).use { `is` ->
|
context.assets.open(asset).use { `is` ->
|
||||||
|
|||||||
@ -292,10 +292,11 @@
|
|||||||
<string name="peer">Kumppani</string>
|
<string name="peer">Kumppani</string>
|
||||||
<string name="time">Aika</string>
|
<string name="time">Aika</string>
|
||||||
<string name="calls_duration">Kesto</string>
|
<string name="calls_duration">Kesto</string>
|
||||||
<string name="calls_add_delete_question">Haluatko luoda uuden yhteystiedon \'%1$s\' tai poistaa
|
<string name="calls_add_delete_question">Haluatko luoda kohteelle \'%1$s\' uuden yhteystiedon,
|
||||||
%2$s puheluhistoriasta\?
|
kopioida sen URI:n tai poistaa %2$s puheluhistoriasta\?
|
||||||
</string>
|
</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="disable_history">Poista käytöstä</string>
|
||||||
<string name="enable_history">Ota käyttöön</string>
|
<string name="enable_history">Ota käyttöön</string>
|
||||||
<string name="delete_history_alert">Haluatko tyhjentää tilin \'%1$s\' puheluhistorian\?</string>
|
<string name="delete_history_alert">Haluatko tyhjentää tilin \'%1$s\' puheluhistorian\?</string>
|
||||||
@ -530,6 +531,8 @@
|
|||||||
<string name="add">Lisää</string>
|
<string name="add">Lisää</string>
|
||||||
<string name="delete">Poista</string>
|
<string name="delete">Poista</string>
|
||||||
<string name="edit">Muokkaa</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="status">Tila</string>
|
||||||
<string name="error">Virhe</string>
|
<string name="error">Virhe</string>
|
||||||
<string name="confirmation">Vahvistus</string>
|
<string name="confirmation">Vahvistus</string>
|
||||||
|
|||||||
@ -281,9 +281,10 @@
|
|||||||
<string name="direction">Direction</string>
|
<string name="direction">Direction</string>
|
||||||
<string name="time">Time</string>
|
<string name="time">Time</string>
|
||||||
<string name="calls_duration">Duration</string>
|
<string name="calls_duration">Duration</string>
|
||||||
<string name="calls_add_delete_question">Do you want to add \'%1$s\' to contacts or delete
|
<string name="calls_add_delete_question">Do you want to add \'%1$s\' to contacts, copy its URI,
|
||||||
%2$s from call history\?</string>
|
or delete this %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_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="disable_history">Disable</string>
|
||||||
<string name="enable_history">Enable</string>
|
<string name="enable_history">Enable</string>
|
||||||
<string name="delete_history_alert">Do you want to delete call history of account \'%1$s\'\?</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="add">Add</string>
|
||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
<string name="edit">Edit</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="status">Status</string>
|
||||||
<string name="error">Error</string>
|
<string name="error">Error</string>
|
||||||
<string name="confirmation">Confirmation</string>
|
<string name="confirmation">Confirmation</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user