lets add a Participants field into Message
This commit is contained in:
parent
424b77577c
commit
8b37aab610
|
@ -140,8 +140,8 @@ class MainActivity : SimpleActivity() {
|
|||
MessagesAdapter(this, messages, messages_list, messages_fastscroller) {
|
||||
Intent(this, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, (it as Message).thread)
|
||||
putExtra(THREAD_NAME, it.senderName)
|
||||
putExtra(THREAD_NUMBER, it.senderNumber)
|
||||
putExtra(THREAD_NAME, it.participants.first().name)
|
||||
putExtra(THREAD_NUMBER, it.participants.first().phoneNumber)
|
||||
startActivity(this)
|
||||
}
|
||||
}.apply {
|
||||
|
|
|
@ -108,7 +108,7 @@ class MessagesAdapter(
|
|||
view.apply {
|
||||
message_frame.isSelected = selectedKeys.contains(message.id)
|
||||
|
||||
message_address.text = message.senderName
|
||||
message_address.text = message.participants.first().name
|
||||
message_body_short.text = message.body
|
||||
message_date.text = message.date.formatDateOrTime(context, true)
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ fun Context.getMessages(threadId: Int? = null): ArrayList<Message> {
|
|||
val date = (cursor.getLongValue(Sms.DATE) / 1000).toInt()
|
||||
val read = cursor.getIntValue(Sms.READ) == 1
|
||||
val thread = cursor.getIntValue(Sms.THREAD_ID)
|
||||
val message = Message(id, body, type, senderName, senderNumber, date, read, thread)
|
||||
val participant = Contact(0, senderName, "", senderNumber, false)
|
||||
val message = Message(id, body, type, arrayListOf(participant), date, read, thread)
|
||||
messages.add(message)
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ fun Context.getMessages(threadId: Int? = null): ArrayList<Message> {
|
|||
messages = messages.distinctBy { it.thread }.toMutableList() as ArrayList<Message>
|
||||
}
|
||||
|
||||
messages = messages.filter { !isNumberBlocked(it.senderNumber) }.toMutableList() as ArrayList<Message>
|
||||
messages = messages.filter { !isNumberBlocked(it.participants.first().phoneNumber) }.toMutableList() as ArrayList<Message>
|
||||
return messages
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,8 @@ fun Context.getMMS(threadId: Int? = null): ArrayList<Message> {
|
|||
val senderName = getThreadRecipients(thread)
|
||||
val senderNumber = senderName
|
||||
val mms = getMmsContent(id)
|
||||
val message = Message(id, mms?.text ?: "", type, senderName, senderNumber, date, read, thread)
|
||||
val participant = Contact(0, senderName, "", senderNumber, false)
|
||||
val message = Message(id, mms?.text ?: "", type, arrayListOf(participant), date, read, thread)
|
||||
messages.add(message)
|
||||
}
|
||||
return messages
|
||||
|
|
|
@ -3,8 +3,7 @@ package com.simplemobiletools.smsmessenger.models
|
|||
import android.provider.Telephony
|
||||
|
||||
data class Message(
|
||||
val id: Int, val body: String, val type: Int, val senderName: String, val senderNumber: String, val date: Int, val read: Boolean,
|
||||
val thread: Int
|
||||
val id: Int, val body: String, val type: Int, val participants: ArrayList<Contact>, val date: Int, val read: Boolean, val thread: Int
|
||||
) : ThreadItem() {
|
||||
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue