From 1876dd76a2cfb0652fbf0e7904badaf53572d83c Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Wed, 20 Nov 2019 09:28:43 +0200 Subject: [PATCH] - 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. --- .../kotlin/com/tutpro/baresip/CallListAdapter.kt | 5 +---- .../main/kotlin/com/tutpro/baresip/ChatActivity.kt | 11 +++-------- .../kotlin/com/tutpro/baresip/ChatListAdapter.kt | 7 ++----- app/src/main/kotlin/com/tutpro/baresip/Utils.kt | 14 +++++++------- app/src/main/res/layout/chat_row.xml | 1 + 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt index e5ab0c53..ae83fa4b 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt @@ -27,10 +27,7 @@ class CallListAdapter(private val cxt: Context, private val rows: ArrayList"))) u = uri.substring(1).substringBeforeLast(">") @@ -79,7 +76,10 @@ object Utils { !u.contains(";")) { val user = uriUserPart(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 { return uri } @@ -104,8 +104,8 @@ object Utils { checkPort(parts[1]) } - fun checkTelNo(no: String): Boolean { - return Regex("^[+]?[0-9]{1,16}\$").matches(no) + fun checkE164Number(no: String): Boolean { + return Regex("^[+][1-9][0-9]{0,14}\$").matches(no) } fun checkIpV4(ip: String): Boolean { diff --git a/app/src/main/res/layout/chat_row.xml b/app/src/main/res/layout/chat_row.xml index c73a2277..472e027b 100644 --- a/app/src/main/res/layout/chat_row.xml +++ b/app/src/main/res/layout/chat_row.xml @@ -64,6 +64,7 @@ android:layout_marginEnd="5dp" android:layout_marginBottom="5dp" android:textSize="16sp" + android:singleLine="true" android:text="" >