properly set the thread title if it contains no messages
This commit is contained in:
parent
ef09a8871a
commit
fb45d68835
|
@ -60,11 +60,15 @@ class ThreadActivity : SimpleActivity() {
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
messages = getMessages(threadId)
|
messages = getMessages(threadId)
|
||||||
participants = messages.first().participants
|
participants = if (messages.isEmpty()) {
|
||||||
|
getThreadParticipants(threadId)
|
||||||
|
} else {
|
||||||
|
messages.first().participants
|
||||||
|
}
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
supportActionBar?.title = messages.first().getThreadTitle()
|
supportActionBar?.title = participants.getThreadTitle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupButtons()
|
setupButtons()
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.simplemobiletools.smsmessenger.extensions
|
||||||
|
|
||||||
|
import android.text.TextUtils
|
||||||
|
import com.simplemobiletools.smsmessenger.models.Contact
|
||||||
|
|
||||||
|
fun ArrayList<Contact>.getThreadTitle() = TextUtils.join(", ", map { it.name }.toTypedArray())
|
|
@ -1,12 +1,12 @@
|
||||||
package com.simplemobiletools.smsmessenger.models
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import android.text.TextUtils
|
import com.simplemobiletools.smsmessenger.extensions.getThreadTitle
|
||||||
|
|
||||||
data class Message(
|
data class Message(
|
||||||
val id: Int, val body: String, val type: Int, val participants: ArrayList<Contact>, 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() {
|
) : ThreadItem() {
|
||||||
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||||
|
|
||||||
fun getThreadTitle() = TextUtils.join(", ", participants.map { it.name }.toTypedArray())
|
fun getThreadTitle() = participants.getThreadTitle()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue