Commit 60bc5c42 by zhangchengbo

feat:修复通讯录跳转发送短信-手机号未展示问题

parent 9ae1dc6a
......@@ -7,6 +7,7 @@ import android.view.WindowManager
import android.widget.Toast
import com.google.gson.Gson
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.secspace.log.Log
import com.secspace.sms.R
import com.secspace.sms.adapters.ContactsAdapter
import com.secspace.sms.databinding.ActivityNewConversationBinding
......@@ -262,12 +263,13 @@ class NewConversationActivity : SimpleActivity() {
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: intent.getStringExtra("sms_body") ?: ""
val numbers = phoneNumber.split(";").toSet()
val number = if (numbers.size == 1) phoneNumber else Gson().toJson(numbers)
Log.d("shuju", "--NewConversationActivity--phoneNumber:$phoneNumber threadId:${getThreadId(numbers)} numbers:${numbers} text:$text ")
Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, getThreadId(numbers))
putExtra(THREAD_TITLE, name)
putExtra(THREAD_TEXT, text)
putExtra(THREAD_NUMBER, number)
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
val uri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
putExtra(THREAD_ATTACHMENT_URI, uri?.toString())
......
......@@ -43,6 +43,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.secspace.log.Log
import com.secspace.sms.R
import com.secspace.sms.adapters.AttachmentsAdapter
import com.secspace.sms.adapters.AutoCompleteTextViewAdapter
......@@ -64,6 +65,7 @@ import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.SimpleContact
import com.simplemobiletools.commons.util.GsonUtil
import com.simplemobiletools.commons.views.MyRecyclerView
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
......@@ -140,6 +142,7 @@ class ThreadActivity : SimpleActivity() {
isRecycleBin = intent.getBooleanExtra(IS_RECYCLE_BIN, false)
wasProtectionHandled = intent.getBooleanExtra(WAS_PROTECTION_HANDLED, false)
// Log.d("shuju","----收到跳转信息---threadId:$threadId THREAD_TITLE:${intent.getStringExtra(THREAD_TITLE)} isRecycleBin:$isRecycleBin wasProtectionHandled:$wasProtectionHandled number:$number")
bus = EventBus.getDefault()
bus!!.register(this)
......@@ -179,9 +182,12 @@ class ThreadActivity : SimpleActivity() {
notificationManager.cancel(threadId.hashCode())
ensureBackgroundThread {
val newConv = conversationsDB.getConversationWithThreadId(threadId)
val newConv: Conversation? = conversationsDB.getConversationWithThreadId(threadId)
if (newConv != null) {
conversation = newConv
runOnUiThread {
setupThreadTitle()
}
}
}
......@@ -336,7 +342,7 @@ class ThreadActivity : SimpleActivity() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
binding.messageHolder.threadTypeMessage.requestFocus()
}
setupThreadTitle()
setupSIMSelector()
updateMessageType()
callback()
......@@ -398,7 +404,6 @@ class ThreadActivity : SimpleActivity() {
finish()
return@ensureBackgroundThread
}
val phoneNumber = PhoneNumber(number, 0, "", number)
val contact = SimpleContact(0, 0, name, "", arrayListOf(phoneNumber), ArrayList(), ArrayList())
participants.add(contact)
......@@ -413,11 +418,28 @@ class ThreadActivity : SimpleActivity() {
setupAttachmentSizes()
setupAdapter()
runOnUiThread {
setupThreadTitle()
setupSIMSelector()
}
}
}
private fun setupThreadTitle() {
val title = conversation?.phoneNumber
binding.threadToolbar.title = if (!title.isNullOrEmpty()) {
Log.d("shuju","--ThreadActivity--setupThreadTitle---1 THREAD_NUMBER:$title")
title
} else {
Log.d("shuju","--ThreadActivity--setupThreadTitle---2 THREAD_NUMBER:${intent.getStringExtra(THREAD_NUMBER)}")
val phoneNUmber = intent.getStringExtra(THREAD_NUMBER)
phoneNUmber?.let {
binding.threadToolbar.title =it.replace(" ","")
}
// participants.getThreadTitle()
phoneNUmber?.replace(" ","")
}
}
private fun getOrCreateThreadAdapter(): ThreadAdapter {
var currAdapter = binding.threadMessagesList.adapter
if (currAdapter == null) {
......
......@@ -379,7 +379,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
}
}
fun updateRecentsAppIcon() {
private fun updateRecentsAppIcon() {
if (baseConfig.isUsingModifiedAppIcon) {
val appIconIDs = getAppIconIDs()
val currentAppIconColorIndex = getCurrentAppIconColorIndex()
......
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