Commit 6bfbf2fd by zhangchengbo

fix:优先展示通讯录备注名称,其次手机号

parent fdb07b69
...@@ -590,14 +590,18 @@ class MainActivity : SimpleActivity() { ...@@ -590,14 +590,18 @@ class MainActivity : SimpleActivity() {
private fun handleConversationClick(any: Any) { private fun handleConversationClick(any: Any) {
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
val conversation = any as Conversation val conversation = any as Conversation
// Log.d(TAG, "handleConversationClick: conversation = ${conversation}") Log.d(TAG, "handleConversationClick: conversation = ${Gson().toJson(conversation)}")
Log.d(TAG, "handleConversationClick: snippet = ${conversation.snippet} threadId = ${conversation.threadId}") val userName = conversation.userName
Log.d(TAG, "handleConversationClick: 通讯录备注名称 = $userName 短信内容 = ${conversation.snippet} threadId = ${conversation.threadId}")
val listMessageData = getMessages(conversation.threadId, false) val listMessageData = getMessages(conversation.threadId, false)
Log.d(TAG, "handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}") Log.d(TAG, "handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}")
if (listMessageData.isNotEmpty()) { if (listMessageData.isNotEmpty()) {
val listContains: List<Message> = listMessageData.filter { msg -> msg.body.contains("\u200B") } val listContains: List<Message> = listMessageData.filter { msg -> msg.body.contains("\u200B") }
Log.d(TAG, "handleConversationClick: 是否包含零宽度字符 = ${listContains.isNotEmpty()}") Log.d(TAG, "handleConversationClick: 是否包含零宽度字符 = ${listContains.isNotEmpty()}")
if (listContains.isNotEmpty() || conversation.isSFNumber) { if (listContains.isNotEmpty() || conversation.isSFNumber) {
if(userName.isNotBlank()){
putExtra(THREAD_TITLE, userName)
}else {
val phoneNumber = conversation.title val phoneNumber = conversation.title
if (phoneNumber.contains("+86")) { if (phoneNumber.contains("+86")) {
phoneNumber.replace("+86", "") phoneNumber.replace("+86", "")
...@@ -606,6 +610,7 @@ class MainActivity : SimpleActivity() { ...@@ -606,6 +610,7 @@ class MainActivity : SimpleActivity() {
putExtra(THREAD_TITLE, itNumber) putExtra(THREAD_TITLE, itNumber)
} }
} }
}
} else { } else {
putExtra(THREAD_TITLE, conversation.title) putExtra(THREAD_TITLE, conversation.title)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment