- In chat and call lists, if userpart of peer URI is an E.164 number,
show only the userpart. - In chat list, show only the first line of the message.
This commit is contained in:
@@ -27,10 +27,7 @@ class CallListAdapter(private val cxt: Context, private val rows: ArrayList<Call
|
|||||||
peer = contact.name
|
peer = contact.name
|
||||||
avatarBackground.setColor(contact.color)
|
avatarBackground.setColor(contact.color)
|
||||||
} else {
|
} else {
|
||||||
if (Utils.uriHostPart(callRow.peerUri) == Utils.uriHostPart(callRow.aor))
|
peer = Utils.friendlyUri(callRow.peerUri, callRow.aor)
|
||||||
peer = Utils.uriUserPart(callRow.peerUri)
|
|
||||||
else
|
|
||||||
peer = Utils.uriAor(callRow.peerUri)
|
|
||||||
avatarBackground.setColor(Utils.randomColor())
|
avatarBackground.setColor(Utils.randomColor())
|
||||||
}
|
}
|
||||||
avatarView.text = "${peer[0]}"
|
avatarView.text = "${peer[0]}"
|
||||||
|
|||||||
@@ -56,15 +56,10 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
this@ChatActivity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
this@ChatActivity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
||||||
|
|
||||||
var chatPeer = ContactsActivity.contactName(peerUri)
|
var chatPeer = ContactsActivity.contactName(peerUri)
|
||||||
if (chatPeer.startsWith("sip:")) {
|
if (chatPeer.startsWith("sip:"))
|
||||||
if (Utils.checkTelNo(Utils.uriUserPart(peerUri)) ||
|
chatPeer = Utils.friendlyUri(chatPeer, Utils.aorDomain(aor))
|
||||||
(Utils.uriHostPart(peerUri) == Utils.aorDomain(aor)))
|
|
||||||
chatPeer = Utils.uriUserPart(peerUri)
|
|
||||||
else
|
|
||||||
chatPeer = chatPeer.substring(4)
|
|
||||||
}
|
|
||||||
|
|
||||||
setTitle(String.format(getString(R.string.chat_with), chatPeer))
|
title = String.format(getString(R.string.chat_with), chatPeer)
|
||||||
|
|
||||||
val headerView = findViewById(R.id.account) as TextView
|
val headerView = findViewById(R.id.account) as TextView
|
||||||
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
||||||
|
|||||||
@@ -35,11 +35,8 @@ class ChatListAdapter(private val cxt: Context, private var rows: ArrayList<Mess
|
|||||||
peer = contact.name
|
peer = contact.name
|
||||||
avatarBackground.setColor(contact.color)
|
avatarBackground.setColor(contact.color)
|
||||||
} else {
|
} else {
|
||||||
if (Utils.uriHostPart(message.peerUri) == Utils.uriHostPart(message.aor))
|
peer = Utils.friendlyUri(message.peerUri, message.aor)
|
||||||
peer = Utils.uriUserPart(message.peerUri)
|
avatarBackground.setColor(Utils.randomColor())
|
||||||
else
|
|
||||||
peer = Utils.uriAor(message.peerUri)
|
|
||||||
avatarBackground.setColor(Color.RED)
|
|
||||||
}
|
}
|
||||||
avatarView.text = "${peer[0]}"
|
avatarView.text = "${peer[0]}"
|
||||||
if (message.direction == R.drawable.arrow_down_green) {
|
if (message.direction == R.drawable.arrow_down_green) {
|
||||||
|
|||||||
@@ -67,11 +67,8 @@ object Utils {
|
|||||||
return uri.substringAfter(":").substringBefore("@")
|
return uri.substringAfter(":").substringBefore("@")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uriAor(uri: String): String {
|
|
||||||
return uriUserPart(uri) + "@" + uriHostPart(uri)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun friendlyUri(uri: String, domain: String): String {
|
fun friendlyUri(uri: String, domain: String): String {
|
||||||
|
Log.d("Baresip", "Checking uri $uri and domain $domain")
|
||||||
var u = uri
|
var u = uri
|
||||||
if (uri.startsWith("<") && (uri.endsWith(">")))
|
if (uri.startsWith("<") && (uri.endsWith(">")))
|
||||||
u = uri.substring(1).substringBeforeLast(">")
|
u = uri.substring(1).substringBeforeLast(">")
|
||||||
@@ -79,7 +76,10 @@ object Utils {
|
|||||||
!u.contains(";")) {
|
!u.contains(";")) {
|
||||||
val user = uriUserPart(u)
|
val user = uriUserPart(u)
|
||||||
val host = uriHostPart(u)
|
val host = uriHostPart(u)
|
||||||
if (host == domain) return user else return "$user@$host"
|
if (checkE164Number(user) || (host == domain))
|
||||||
|
return user
|
||||||
|
else
|
||||||
|
return "$user@$host"
|
||||||
} else {
|
} else {
|
||||||
return uri
|
return uri
|
||||||
}
|
}
|
||||||
@@ -104,8 +104,8 @@ object Utils {
|
|||||||
checkPort(parts[1])
|
checkPort(parts[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkTelNo(no: String): Boolean {
|
fun checkE164Number(no: String): Boolean {
|
||||||
return Regex("^[+]?[0-9]{1,16}\$").matches(no)
|
return Regex("^[+][1-9][0-9]{0,14}\$").matches(no)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkIpV4(ip: String): Boolean {
|
fun checkIpV4(ip: String): Boolean {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
|
android:singleLine="true"
|
||||||
android:text="" >
|
android:text="" >
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user