diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt index 87623261..a975e180 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt @@ -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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/MessagesAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/MessagesAdapter.kt index 12b6c7b4..4447d8a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/MessagesAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/MessagesAdapter.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index 104f8b8c..31111df4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -63,7 +63,8 @@ fun Context.getMessages(threadId: Int? = null): ArrayList { 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 { messages = messages.distinctBy { it.thread }.toMutableList() as ArrayList } - messages = messages.filter { !isNumberBlocked(it.senderNumber) }.toMutableList() as ArrayList + messages = messages.filter { !isNumberBlocked(it.participants.first().phoneNumber) }.toMutableList() as ArrayList return messages } @@ -109,7 +110,8 @@ fun Context.getMMS(threadId: Int? = null): ArrayList { 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 diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/Message.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/Message.kt index 7083008b..800c7ae3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/Message.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/Message.kt @@ -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, val date: Int, val read: Boolean, val thread: Int ) : ThreadItem() { fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX }