Commit 6bfbf2fd by zhangchengbo

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

parent fdb07b69
......@@ -590,20 +590,25 @@ class MainActivity : SimpleActivity() {
private fun handleConversationClick(any: Any) {
Intent(this, ThreadActivity::class.java).apply {
val conversation = any as Conversation
// Log.d(TAG, "handleConversationClick: conversation = ${conversation}")
Log.d(TAG, "handleConversationClick: snippet = ${conversation.snippet} threadId = ${conversation.threadId}")
Log.d(TAG, "handleConversationClick: conversation = ${Gson().toJson(conversation)}")
val userName = conversation.userName
Log.d(TAG, "handleConversationClick: 通讯录备注名称 = $userName 短信内容 = ${conversation.snippet} threadId = ${conversation.threadId}")
val listMessageData = getMessages(conversation.threadId, false)
Log.d(TAG, "handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}")
if (listMessageData.isNotEmpty()) {
val listContains: List<Message> = listMessageData.filter { msg -> msg.body.contains("\u200B") }
Log.d(TAG, "handleConversationClick: 是否包含零宽度字符 = ${listContains.isNotEmpty()}")
if (listContains.isNotEmpty() || conversation.isSFNumber) {
val phoneNumber = conversation.title
if (phoneNumber.contains("+86")) {
phoneNumber.replace("+86", "")
}
PhoneUtils.phoneNumberFormat(phoneNumber) { itNumber ->
putExtra(THREAD_TITLE, itNumber)
if(userName.isNotBlank()){
putExtra(THREAD_TITLE, userName)
}else {
val phoneNumber = conversation.title
if (phoneNumber.contains("+86")) {
phoneNumber.replace("+86", "")
}
PhoneUtils.phoneNumberFormat(phoneNumber) { itNumber ->
putExtra(THREAD_TITLE, itNumber)
}
}
}
} else {
......
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