More contact related improvements and fixes
This commit is contained in:
@@ -698,7 +698,7 @@ class BaresipService: Service() {
|
|||||||
piFlags)
|
piFlags)
|
||||||
val nb = NotificationCompat.Builder(this,
|
val nb = NotificationCompat.Builder(this,
|
||||||
if (shouldVibrate()) MEDIUM_CHANNEL_ID else HIGH_CHANNEL_ID)
|
if (shouldVibrate()) MEDIUM_CHANNEL_ID else HIGH_CHANNEL_ID)
|
||||||
val caller = Utils.friendlyUri(this, peerUri, ua.account, true)
|
val caller = Utils.friendlyUri(this, peerUri, ua.account)
|
||||||
nb.setSmallIcon(R.drawable.ic_stat_call)
|
nb.setSmallIcon(R.drawable.ic_stat_call)
|
||||||
.setColor(ContextCompat.getColor(this, R.color.colorBaresip))
|
.setColor(ContextCompat.getColor(this, R.color.colorBaresip))
|
||||||
.setContentIntent(pi)
|
.setContentIntent(pi)
|
||||||
@@ -956,7 +956,7 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
@SuppressLint("UnspecifiedImmutableFlag")
|
@SuppressLint("UnspecifiedImmutableFlag")
|
||||||
@Keep
|
@Keep
|
||||||
fun messageEvent(uap: Long, peer: String, msg: ByteArray) {
|
fun messageEvent(uap: Long, peerUri: String, msg: ByteArray) {
|
||||||
var text = "Decoding of message failed!"
|
var text = "Decoding of message failed!"
|
||||||
try {
|
try {
|
||||||
text = String(msg, StandardCharsets.UTF_8)
|
text = String(msg, StandardCharsets.UTF_8)
|
||||||
@@ -970,8 +970,8 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
val timeStamp = System.currentTimeMillis()
|
val timeStamp = System.currentTimeMillis()
|
||||||
val timeStampString = timeStamp.toString()
|
val timeStampString = timeStamp.toString()
|
||||||
Log.d(TAG, "Message event for $uap from $peer at $timeStampString")
|
Log.d(TAG, "Message event for $uap from $peerUri at $timeStampString")
|
||||||
Message(ua.account.aor, peer, text, timeStamp,
|
Message(ua.account.aor, peerUri, text, timeStamp,
|
||||||
R.drawable.arrow_down_green, 0, "", true).add()
|
R.drawable.arrow_down_green, 0, "", true).add()
|
||||||
Message.save()
|
Message.save()
|
||||||
ua.account.unreadMessages = true
|
ua.account.unreadMessages = true
|
||||||
@@ -984,10 +984,10 @@ class BaresipService: Service() {
|
|||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
intent.putExtra("action", "message show").putExtra("uap", uap)
|
intent.putExtra("action", "message show").putExtra("uap", uap)
|
||||||
.putExtra("peer", peer)
|
.putExtra("peer", peerUri)
|
||||||
val pi = PendingIntent.getActivity(applicationContext, MESSAGE_REQ_CODE, intent, piFlags)
|
val pi = PendingIntent.getActivity(applicationContext, MESSAGE_REQ_CODE, intent, piFlags)
|
||||||
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
val sender = Utils.friendlyUri(this, peer, ua.account)
|
val sender = Utils.friendlyUri(this, peerUri, ua.account)
|
||||||
nb.setSmallIcon(R.drawable.ic_stat_message)
|
nb.setSmallIcon(R.drawable.ic_stat_message)
|
||||||
.setColor(ContextCompat.getColor(this, R.color.colorBaresip))
|
.setColor(ContextCompat.getColor(this, R.color.colorBaresip))
|
||||||
.setContentIntent(pi)
|
.setContentIntent(pi)
|
||||||
@@ -1005,7 +1005,7 @@ class BaresipService: Service() {
|
|||||||
replyIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
replyIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
replyIntent.putExtra("action", "message reply")
|
replyIntent.putExtra("action", "message reply")
|
||||||
.putExtra("uap", uap).putExtra("peer", peer)
|
.putExtra("uap", uap).putExtra("peer", peerUri)
|
||||||
val rpi = PendingIntent.getActivity(applicationContext, REPLY_REQ_CODE, replyIntent,
|
val rpi = PendingIntent.getActivity(applicationContext, REPLY_REQ_CODE, replyIntent,
|
||||||
piFlags)
|
piFlags)
|
||||||
val saveIntent = Intent(this, BaresipService::class.java)
|
val saveIntent = Intent(this, BaresipService::class.java)
|
||||||
@@ -1031,7 +1031,7 @@ class BaresipService: Service() {
|
|||||||
nt.play()
|
nt.play()
|
||||||
} else
|
} else
|
||||||
nt.play()
|
nt.play()
|
||||||
postServiceEvent(ServiceEvent("message show", arrayListOf(uap, peer), System.nanoTime()))
|
postServiceEvent(ServiceEvent("message show", arrayListOf(uap, peerUri), System.nanoTime()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class CallListAdapter(private val ctx: Context, private val account: Account,
|
|||||||
if (count <= 3)
|
if (count <= 3)
|
||||||
viewHolder.etcView.text = ""
|
viewHolder.etcView.text = ""
|
||||||
|
|
||||||
viewHolder.peerURIView.text = Utils.friendlyUri(ctx, callRow.peerUri, account, true)
|
viewHolder.peerURIView.text = Utils.friendlyUri(ctx, callRow.peerUri, account)
|
||||||
viewHolder.timeView.text = Utils.relativeTime(ctx, callRow.stopTime)
|
viewHolder.timeView.text = Utils.relativeTime(ctx, callRow.stopTime)
|
||||||
|
|
||||||
viewHolder.timeView.setOnClickListener {
|
viewHolder.timeView.setOnClickListener {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
|
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
|
||||||
val peerUri = uaHistory[pos].peerUri
|
val peerUri = uaHistory[pos].peerUri
|
||||||
val peerName = Contact.contactName(peerUri)
|
val peerName = Utils.friendlyUri(this, peerUri, account)
|
||||||
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
||||||
when (which) {
|
when (which) {
|
||||||
DialogInterface.BUTTON_NEGATIVE -> {
|
DialogInterface.BUTTON_NEGATIVE -> {
|
||||||
@@ -126,11 +126,11 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
else
|
else
|
||||||
getString(R.string.calls_call)
|
getString(R.string.calls_call)
|
||||||
val builder = MaterialAlertDialogBuilder(this@CallsActivity, R.style.AlertDialogTheme)
|
val builder = MaterialAlertDialogBuilder(this@CallsActivity, R.style.AlertDialogTheme)
|
||||||
if (peerName.startsWith("sip:"))
|
if (!Contact.nameExists(peerName, false))
|
||||||
with (builder) {
|
with (builder) {
|
||||||
setTitle(R.string.confirmation)
|
setTitle(R.string.confirmation)
|
||||||
setMessage(String.format(getString(R.string.calls_add_delete_question),
|
setMessage(String.format(getString(R.string.calls_add_delete_question),
|
||||||
Utils.friendlyUri(this@CallsActivity, peerName, account), callText))
|
peerName, callText))
|
||||||
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
||||||
setNegativeButton(getString(R.string.add_contact), dialogClickListener)
|
setNegativeButton(getString(R.string.add_contact), dialogClickListener)
|
||||||
@@ -140,7 +140,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
with (builder) {
|
with (builder) {
|
||||||
setTitle(R.string.confirmation)
|
setTitle(R.string.confirmation)
|
||||||
setMessage(String.format(getString(R.string.calls_delete_question),
|
setMessage(String.format(getString(R.string.calls_delete_question),
|
||||||
Utils.friendlyUri(this@CallsActivity, peerName, account), callText))
|
peerName, callText))
|
||||||
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
setNeutralButton(getString(R.string.cancel), dialogClickListener)
|
||||||
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
setPositiveButton(String.format(getString(R.string.delete), callText), dialogClickListener)
|
||||||
show()
|
show()
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
this@ChatActivity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
this@ChatActivity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
||||||
|
|
||||||
val chatPeer = Utils.friendlyUri(this, peerUri, userAgent.account, true)
|
val chatPeer = Utils.friendlyUri(this, peerUri, userAgent.account)
|
||||||
|
|
||||||
title = String.format(getString(R.string.chat_with), chatPeer)
|
title = String.format(getString(R.string.chat_with), chatPeer)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ChatListAdapter(private val ctx: Context, private val account: Account, pr
|
|||||||
|
|
||||||
val message = rows[position]
|
val message = rows[position]
|
||||||
|
|
||||||
viewHolder.peerView.text = Utils.friendlyUri(ctx, message.peerUri, account, true)
|
viewHolder.peerView.text = Utils.friendlyUri(ctx, message.peerUri, account)
|
||||||
Utils.setAvatar(ctx, viewHolder.imageAvatarView, viewHolder.textAvatarView,
|
Utils.setAvatar(ctx, viewHolder.imageAvatarView, viewHolder.textAvatarView,
|
||||||
if (Contact.contactName(message.peerUri) == message.peerUri)
|
if (Contact.contactName(message.peerUri) == message.peerUri)
|
||||||
Utils.e164Uri(message.peerUri, account.countryCode)
|
Utils.e164Uri(message.peerUri, account.countryCode)
|
||||||
|
|||||||
@@ -107,12 +107,12 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val builder = MaterialAlertDialogBuilder(this@ChatsActivity, R.style.AlertDialogTheme)
|
val builder = MaterialAlertDialogBuilder(this@ChatsActivity, R.style.AlertDialogTheme)
|
||||||
val peer = Contact.contactName(uaMessages[pos].peerUri)
|
val peer = Utils.friendlyUri(this@ChatsActivity, uaMessages[pos].peerUri, account)
|
||||||
if (peer.startsWith("sip:"))
|
if (!Contact.nameExists(peer, false))
|
||||||
with (builder) {
|
with (builder) {
|
||||||
setTitle(R.string.confirmation)
|
setTitle(R.string.confirmation)
|
||||||
setMessage(String.format(getString(R.string.long_chat_question),
|
setMessage(String.format(getString(R.string.long_chat_question),
|
||||||
Utils.friendlyUri(this@ChatsActivity, peer, account, true)))
|
Utils.friendlyUri(this@ChatsActivity, peer, account)))
|
||||||
setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
setNeutralButton(getText(R.string.cancel), dialogClickListener)
|
||||||
setNegativeButton(getText(R.string.delete), dialogClickListener)
|
setNegativeButton(getText(R.string.delete), dialogClickListener)
|
||||||
setPositiveButton(getText(R.string.add_contact), dialogClickListener)
|
setPositiveButton(getText(R.string.add_contact), dialogClickListener)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ sealed class Contact {
|
|||||||
if (contact.thumbnailUri == null && thumb != null)
|
if (contact.thumbnailUri == null && thumb != null)
|
||||||
contact.thumbnailUri = thumb
|
contact.thumbnailUri = thumb
|
||||||
if (mime == ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
if (mime == ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
||||||
contact.uris.add("tel:${data.filterNot{setOf('-', ' ').contains(it)}}")
|
contact.uris.add("tel:${data.filterNot{setOf('-', ' ', '(', ')').contains(it)}}")
|
||||||
else if (mime == ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE)
|
else if (mime == ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE)
|
||||||
contact.uris.add("sip:$data")
|
contact.uris.add("sip:$data")
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -522,7 +522,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chatRequests = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
chatRequests = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
Log.d(TAG, "************ activityAor = $activityAor")
|
|
||||||
spinToAor(activityAor)
|
spinToAor(activityAor)
|
||||||
updateIcons(Account.ofAor(activityAor)!!)
|
updateIcons(Account.ofAor(activityAor)!!)
|
||||||
}
|
}
|
||||||
@@ -1893,8 +1892,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
else
|
else
|
||||||
getString(R.string.outgoing_call_to_dots)
|
getString(R.string.outgoing_call_to_dots)
|
||||||
callTimer.visibility = View.INVISIBLE
|
callTimer.visibility = View.INVISIBLE
|
||||||
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account,
|
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account))
|
||||||
call.status == "answered"))
|
//call.status == "answered"))
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
diverter.visibility = View.GONE
|
diverter.visibility = View.GONE
|
||||||
callButton.visibility = View.INVISIBLE
|
callButton.visibility = View.INVISIBLE
|
||||||
@@ -1909,12 +1908,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"incoming" -> {
|
"incoming" -> {
|
||||||
callTitle.text = getString(R.string.incoming_call_from_dots)
|
callTitle.text = getString(R.string.incoming_call_from_dots)
|
||||||
callTimer.visibility = View.INVISIBLE
|
callTimer.visibility = View.INVISIBLE
|
||||||
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account, true))
|
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account))
|
||||||
callUri.setAdapter(null)
|
callUri.setAdapter(null)
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
val uri = call.diverterUri()
|
val uri = call.diverterUri()
|
||||||
if (uri != "") {
|
if (uri != "") {
|
||||||
diverterUri.text = Utils.friendlyUri(this, uri, ua.account, true)
|
diverterUri.text = Utils.friendlyUri(this, uri, ua.account)
|
||||||
diverter.visibility = View.VISIBLE
|
diverter.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
diverter.visibility = View.GONE
|
diverter.visibility = View.GONE
|
||||||
@@ -1943,7 +1942,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account))
|
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account))
|
||||||
} else {
|
} else {
|
||||||
callTitle.text = getString(R.string.incoming_call_from_dots)
|
callTitle.text = getString(R.string.incoming_call_from_dots)
|
||||||
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account, true))
|
callUri.setText(Utils.friendlyUri(this, call.peerUri, ua.account))
|
||||||
}
|
}
|
||||||
transferButton.isEnabled = true
|
transferButton.isEnabled = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ object Utils {
|
|||||||
return if (params.size == 1) listOf() else params.subList(1, params.size)
|
return if (params.size == 1) listOf() else params.subList(1, params.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun friendlyUri(ctx: Context, uri: String, account: Account, e164Check: Boolean = false): String {
|
fun friendlyUri(ctx: Context, uri: String, account: Account, e164Check: Boolean = true): String {
|
||||||
var u = Contact.contactName(uri)
|
var u = Contact.contactName(uri)
|
||||||
if (u != uri)
|
if (u != uri)
|
||||||
return u
|
return u
|
||||||
|
|||||||
Reference in New Issue
Block a user