Added Anonymous and Unknown checks to friendlyUri
This commit is contained in:
@@ -553,17 +553,17 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
if (!isServiceRunning) return
|
if (!isServiceRunning) return
|
||||||
|
|
||||||
val ev = event.split(",")
|
|
||||||
val ua = UserAgent.ofUap(uap)
|
val ua = UserAgent.ofUap(uap)
|
||||||
val aor = ua?.account?.aor
|
|
||||||
|
|
||||||
Log.d(TAG, "got uaEvent $event/$aor/$callp")
|
|
||||||
|
|
||||||
if (ua == null) {
|
if (ua == null) {
|
||||||
Log.w(TAG, "uaEvent $event did not find ua $uap")
|
Log.w(TAG, "uaEvent $event did not find ua $uap")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val ev = event.split(",")
|
||||||
|
val aor = ua.account.aor
|
||||||
|
|
||||||
|
Log.d(TAG, "got uaEvent $event/$aor/$callp")
|
||||||
|
|
||||||
val call = Call.ofCallp(callp)
|
val call = Call.ofCallp(callp)
|
||||||
if (call == null && callp != 0L && ev[0] != "call incoming" && ev[0] != "call rejected") {
|
if (call == null && callp != 0L && ev[0] != "call incoming" && ev[0] != "call rejected") {
|
||||||
Log.w(TAG, "uaEvent $event did not find call $callp")
|
Log.w(TAG, "uaEvent $event did not find call $callp")
|
||||||
@@ -681,7 +681,7 @@ class BaresipService: Service() {
|
|||||||
PendingIntent.getActivity(applicationContext, CALL_REQ_CODE, intent,
|
PendingIntent.getActivity(applicationContext, CALL_REQ_CODE, intent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
val caller = Utils.friendlyUri(Contact.contactName(peerUri), Utils.aorDomain(aor))
|
val caller = Utils.friendlyUri(this, Contact.contactName(peerUri), Utils.aorDomain(aor))
|
||||||
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)
|
||||||
@@ -788,7 +788,7 @@ class BaresipService: Service() {
|
|||||||
PendingIntent.getActivity(applicationContext, TRANSFER_REQ_CODE,
|
PendingIntent.getActivity(applicationContext, TRANSFER_REQ_CODE,
|
||||||
intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
val target = Utils.friendlyUri(Contact.contactName(ev[1]), Utils.aorDomain(aor))
|
val target = Utils.friendlyUri(this, Contact.contactName(ev[1]), Utils.aorDomain(aor))
|
||||||
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)
|
||||||
@@ -869,7 +869,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
if (missed) {
|
if (missed) {
|
||||||
val caller = Utils.friendlyUri(Contact.contactName(call.peerUri), Utils.aorDomain(aor))
|
val caller = Utils.friendlyUri(this, Contact.contactName(call.peerUri), Utils.aorDomain(aor))
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
||||||
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -976,7 +976,7 @@ class BaresipService: Service() {
|
|||||||
PendingIntent.getActivity(applicationContext, MESSAGE_REQ_CODE, intent,
|
PendingIntent.getActivity(applicationContext, MESSAGE_REQ_CODE, intent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
val sender = Utils.friendlyUri(Contact.contactName(peer), Utils.aorDomain(ua.account.aor))
|
val sender = Utils.friendlyUri(this, Contact.contactName(peer), Utils.aorDomain(ua.account.aor))
|
||||||
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)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class CallListAdapter(private val ctx: Context, private val aor: String, private
|
|||||||
|
|
||||||
val contactName = Contact.contactName(callRow.peerUri)
|
val contactName = Contact.contactName(callRow.peerUri)
|
||||||
if (contactName.startsWith("sip:"))
|
if (contactName.startsWith("sip:"))
|
||||||
viewHolder.peerURIView.text = Utils.friendlyUri(contactName, Utils.aorDomain(callRow.aor))
|
viewHolder.peerURIView.text = Utils.friendlyUri(ctx, contactName, Utils.aorDomain(callRow.aor))
|
||||||
else
|
else
|
||||||
viewHolder.peerURIView.text = contactName
|
viewHolder.peerURIView.text = contactName
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
val peerUri = uaHistory[pos].peerUri
|
val peerUri = uaHistory[pos].peerUri
|
||||||
var peerName = Contact.contactName(peerUri)
|
var peerName = Contact.contactName(peerUri)
|
||||||
if (peerName.startsWith("sip:"))
|
if (peerName.startsWith("sip:"))
|
||||||
peerName = Utils.friendlyUri(peerName, Utils.aorDomain(aor))
|
peerName = Utils.friendlyUri(this, peerName, Utils.aorDomain(aor))
|
||||||
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
||||||
when (which) {
|
when (which) {
|
||||||
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE -> {
|
||||||
@@ -121,7 +121,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
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(peerName, Utils.aorDomain(aor)), callText))
|
Utils.friendlyUri(this@CallsActivity, peerName, Utils.aorDomain(aor)), 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)
|
||||||
@@ -131,7 +131,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(peerName, Utils.aorDomain(aor)), callText))
|
Utils.friendlyUri(this@CallsActivity, peerName, Utils.aorDomain(aor)), 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()
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
var chatPeer = Contact.contactName(peerUri)
|
var chatPeer = Contact.contactName(peerUri)
|
||||||
if (chatPeer.startsWith("sip:"))
|
if (chatPeer.startsWith("sip:"))
|
||||||
chatPeer = Utils.friendlyUri(chatPeer, Utils.aorDomain(aor))
|
chatPeer = Utils.friendlyUri(this, chatPeer, Utils.aorDomain(aor))
|
||||||
|
|
||||||
title = String.format(getString(R.string.chat_with), chatPeer)
|
title = String.format(getString(R.string.chat_with), chatPeer)
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ChatListAdapter(private val ctx: Context, private val rows: ArrayList<Mess
|
|||||||
viewHolder.peerView.text = if (peerName !=message.peerUri )
|
viewHolder.peerView.text = if (peerName !=message.peerUri )
|
||||||
peerName
|
peerName
|
||||||
else
|
else
|
||||||
Utils.friendlyUri(message.peerUri, message.aor)
|
Utils.friendlyUri(ctx, message.peerUri, message.aor)
|
||||||
|
|
||||||
val cal = GregorianCalendar()
|
val cal = GregorianCalendar()
|
||||||
cal.timeInMillis = message.timeStamp
|
cal.timeInMillis = message.timeStamp
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
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(peer, Utils.aorDomain(aor))))
|
Utils.friendlyUri(this@ChatsActivity, peer, Utils.aorDomain(aor))))
|
||||||
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)
|
||||||
|
|||||||
@@ -1090,7 +1090,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val call = Call.ofCallp(callp)!!
|
val call = Call.ofCallp(callp)!!
|
||||||
val target = Utils.friendlyUri(Contact.contactName(ev[1]), Utils.aorDomain(aor))
|
val target = Utils.friendlyUri(this, Contact.contactName(ev[1]), Utils.aorDomain(aor))
|
||||||
with(MaterialAlertDialogBuilder(this, R.style.AlertDialogTheme)) {
|
with(MaterialAlertDialogBuilder(this, R.style.AlertDialogTheme)) {
|
||||||
setTitle(R.string.transfer_request)
|
setTitle(R.string.transfer_request)
|
||||||
setMessage(String.format(getString(R.string.transfer_request_query),
|
setMessage(String.format(getString(R.string.transfer_request_query),
|
||||||
@@ -1774,7 +1774,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
} else {
|
} else {
|
||||||
val latest = NewCallHistory.aorLatestHistory(aor)
|
val latest = NewCallHistory.aorLatestHistory(aor)
|
||||||
if (latest != null)
|
if (latest != null)
|
||||||
callUri.setText(Utils.friendlyUri(Contact.contactName(latest.peerUri),
|
callUri.setText(Utils.friendlyUri(this, Contact.contactName(latest.peerUri),
|
||||||
Utils.aorDomain(aor)))
|
Utils.aorDomain(aor)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1819,7 +1819,7 @@ 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(Contact.contactName(call.peerUri),
|
callUri.setText(Utils.friendlyUri(this, Contact.contactName(call.peerUri),
|
||||||
Utils.aorDomain(ua.account.aor)))
|
Utils.aorDomain(ua.account.aor)))
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
callButton.visibility = View.INVISIBLE
|
callButton.visibility = View.INVISIBLE
|
||||||
@@ -1834,7 +1834,7 @@ 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(Contact.contactName(call.peerUri),
|
callUri.setText(Utils.friendlyUri(this, Contact.contactName(call.peerUri),
|
||||||
Utils.aorDomain(ua.account.aor)))
|
Utils.aorDomain(ua.account.aor)))
|
||||||
callUri.setAdapter(null)
|
callUri.setAdapter(null)
|
||||||
securityButton.visibility = View.INVISIBLE
|
securityButton.visibility = View.INVISIBLE
|
||||||
@@ -1854,7 +1854,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
if (call.referTo != "") {
|
if (call.referTo != "") {
|
||||||
callTitle.text = getString(R.string.transferring_call_to_dots)
|
callTitle.text = getString(R.string.transferring_call_to_dots)
|
||||||
callUri.setText(Utils.friendlyUri(Contact.contactName(call.referTo),
|
callUri.setText(Utils.friendlyUri(this, Contact.contactName(call.referTo),
|
||||||
Utils.aorDomain(ua.account.aor)))
|
Utils.aorDomain(ua.account.aor)))
|
||||||
transferButton.isEnabled = false
|
transferButton.isEnabled = false
|
||||||
} else {
|
} else {
|
||||||
@@ -1862,7 +1862,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
callTitle.text = getString(R.string.outgoing_call_to_dots)
|
callTitle.text = getString(R.string.outgoing_call_to_dots)
|
||||||
else
|
else
|
||||||
callTitle.text = getString(R.string.incoming_call_from_dots)
|
callTitle.text = getString(R.string.incoming_call_from_dots)
|
||||||
callUri.setText(Utils.friendlyUri(Contact.contactName(call.peerUri),
|
callUri.setText(Utils.friendlyUri(this, Contact.contactName(call.peerUri),
|
||||||
Utils.aorDomain(ua.account.aor)))
|
Utils.aorDomain(ua.account.aor)))
|
||||||
transferButton.isEnabled = true
|
transferButton.isEnabled = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,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(uri: String, domain: String): String {
|
fun friendlyUri(ctx: Context, uri: String, domain: String): String {
|
||||||
var u = uri
|
var u = uri
|
||||||
val params = uriParams(u)
|
val params = uriParams(u)
|
||||||
if (uri.startsWith("<") && (uri.endsWith(">")))
|
if (uri.startsWith("<") && (uri.endsWith(">")))
|
||||||
@@ -134,6 +134,11 @@ object Utils {
|
|||||||
val host = uriHostPart(u)
|
val host = uriHostPart(u)
|
||||||
if (isTelNumber(user) || host == domain)
|
if (isTelNumber(user) || host == domain)
|
||||||
user
|
user
|
||||||
|
else
|
||||||
|
if (host == "anonymous.invalid")
|
||||||
|
ctx.getString(R.string.anonymous)
|
||||||
|
else if (host == "unknown.invalid")
|
||||||
|
ctx.getString(R.string.unknown)
|
||||||
else
|
else
|
||||||
"$user@$host"
|
"$user@$host"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -426,6 +426,8 @@
|
|||||||
<string name="error">Virhe</string>
|
<string name="error">Virhe</string>
|
||||||
<string name="help">Apua</string>
|
<string name="help">Apua</string>
|
||||||
<string name="confirmation">Vahvistus</string>
|
<string name="confirmation">Vahvistus</string>
|
||||||
|
<string name="anonymous">Anonyymi</string>
|
||||||
|
<string name="unknown">Tuntematon</string>
|
||||||
<string name="invalid_sip_or_tel_uri">Invalid SIP or tel URI \'%1$s\'</string>
|
<string name="invalid_sip_or_tel_uri">Invalid SIP or tel URI \'%1$s\'</string>
|
||||||
<string name="baresip" translatable="false">baresip</string>
|
<string name="baresip" translatable="false">baresip</string>
|
||||||
<string name="android" translatable="false">Android</string>
|
<string name="android" translatable="false">Android</string>
|
||||||
|
|||||||
@@ -384,6 +384,8 @@
|
|||||||
<string name="error">Error</string>
|
<string name="error">Error</string>
|
||||||
<string name="help">Help</string>
|
<string name="help">Help</string>
|
||||||
<string name="confirmation">Confirmation</string>
|
<string name="confirmation">Confirmation</string>
|
||||||
|
<string name="anonymous">Anonymous</string>
|
||||||
|
<string name="unknown">Unknown</string>
|
||||||
<string name="dots" translatable="false">…</string>
|
<string name="dots" translatable="false">…</string>
|
||||||
<string name="bullet_item" translatable="false">\u2022 %1$s</string>
|
<string name="bullet_item" translatable="false">\u2022 %1$s</string>
|
||||||
<string name="invalid_sip_or_tel_uri">Invalid SIP or tel URI \'%1$s\'</string>
|
<string name="invalid_sip_or_tel_uri">Invalid SIP or tel URI \'%1$s\'</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user