use proper placeholder avatars at private contacts too
This commit is contained in:
parent
8760d85d2b
commit
83dcc7423c
|
@ -95,14 +95,22 @@ class ThreadActivity : SimpleActivity() {
|
||||||
messages.first().participants
|
messages.first().participants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val senderNumbersToReplace = HashMap<String, String>()
|
||||||
// check if no participant came from a privately stored contact in Simple Contacts
|
// check if no participant came from a privately stored contact in Simple Contacts
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
|
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
|
||||||
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
|
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
|
||||||
|
senderNumbersToReplace[participant.phoneNumber] = name
|
||||||
participant.name = name
|
participant.name = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
messages.forEach { message ->
|
||||||
|
if (senderNumbersToReplace.keys.contains(message.senderName)) {
|
||||||
|
message.senderName = senderNumbersToReplace[message.senderName]!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (participants.isEmpty()) {
|
if (participants.isEmpty()) {
|
||||||
val name = intent.getStringExtra(THREAD_TITLE) ?: ""
|
val name = intent.getStringExtra(THREAD_TITLE) ?: ""
|
||||||
val number = intent.getStringExtra(THREAD_NUMBER)
|
val number = intent.getStringExtra(THREAD_NUMBER)
|
||||||
|
|
|
@ -44,6 +44,7 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
|
||||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||||
|
|
||||||
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
|
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList?.size ?: 0 > 1
|
private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList?.size ?: 0 > 1
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ import com.simplemobiletools.commons.models.SimpleContact
|
||||||
|
|
||||||
data class Message(
|
data class Message(
|
||||||
val id: Int, val body: String, val type: Int, val participants: ArrayList<SimpleContact>, val date: Int, val read: Boolean, val thread: Int,
|
val id: Int, val body: String, val type: Int, val participants: ArrayList<SimpleContact>, val date: Int, val read: Boolean, val thread: Int,
|
||||||
val isMMS: Boolean, val attachment: MessageAttachment?, val senderName: String, val senderPhotoUri: String, val subscriptionId: Int) : ThreadItem() {
|
val isMMS: Boolean, val attachment: MessageAttachment?, var senderName: String, val senderPhotoUri: String, val subscriptionId: Int) : ThreadItem() {
|
||||||
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue