Add ability to rename group conversations
This commit is contained in:
parent
75bbd5ea0e
commit
8d283858e1
10 changed files with 201 additions and 19 deletions
|
|
@ -51,6 +51,7 @@ import com.simplemobiletools.smsmessenger.R
|
|||
import com.simplemobiletools.smsmessenger.adapters.AttachmentsAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.ThreadAdapter
|
||||
import com.simplemobiletools.smsmessenger.dialogs.RenameConversationDialog
|
||||
import com.simplemobiletools.smsmessenger.dialogs.ScheduleMessageDialog
|
||||
import com.simplemobiletools.smsmessenger.extensions.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
|
|
@ -80,6 +81,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
private var refreshedSinceSent = false
|
||||
private var threadItems = ArrayList<ThreadItem>()
|
||||
private var bus: EventBus? = null
|
||||
private var conversation: Conversation? = null
|
||||
private var participants = ArrayList<SimpleContact>()
|
||||
private var privateContacts = ArrayList<SimpleContact>()
|
||||
private var messages = ArrayList<Message>()
|
||||
|
|
@ -120,6 +122,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
handlePermission(PERMISSION_READ_PHONE_STATE) { granted ->
|
||||
if (granted) {
|
||||
setupButtons()
|
||||
setupConversation()
|
||||
setupCachedMessages {
|
||||
val searchedMessageId = intent.getLongExtra(SEARCHED_MESSAGE_ID, -1L)
|
||||
intent.removeExtra(SEARCHED_MESSAGE_ID)
|
||||
|
|
@ -184,6 +187,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
||||
thread_toolbar.menu.apply {
|
||||
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
||||
findItem(R.id.rename_conversation).isVisible = participants.size > 1 && conversation != null
|
||||
findItem(R.id.block_number).title = addLockedLabelIfNeeded(R.string.block_number)
|
||||
findItem(R.id.block_number).isVisible = isNougatPlus()
|
||||
findItem(R.id.dial_number).isVisible = participants.size == 1
|
||||
|
|
@ -205,6 +209,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
when (menuItem.itemId) {
|
||||
R.id.block_number -> tryBlocking()
|
||||
R.id.delete -> askConfirmDelete()
|
||||
R.id.rename_conversation -> renameConversation()
|
||||
R.id.add_number_to_contact -> addNumberToContact()
|
||||
R.id.dial_number -> dialNumber()
|
||||
R.id.manage_people -> managePeople()
|
||||
|
|
@ -485,6 +490,12 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupConversation() {
|
||||
ensureBackgroundThread {
|
||||
conversation = conversationsDB.getConversationWithThreadId(threadId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupButtons() {
|
||||
updateTextColors(thread_holder)
|
||||
val textColor = getProperTextColor()
|
||||
|
|
@ -638,9 +649,11 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupThreadTitle() {
|
||||
val threadTitle = participants.getThreadTitle()
|
||||
if (threadTitle.isNotEmpty()) {
|
||||
thread_toolbar.title = participants.getThreadTitle()
|
||||
val title = conversation?.title
|
||||
thread_toolbar.title = if (!title.isNullOrEmpty()) {
|
||||
title
|
||||
} else {
|
||||
participants.getThreadTitle()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -827,6 +840,17 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun renameConversation() {
|
||||
RenameConversationDialog(this, conversation!!) { title ->
|
||||
ensureBackgroundThread {
|
||||
conversation = renameConversation(conversation!!, newTitle = title)
|
||||
runOnUiThread {
|
||||
setupThreadTitle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun getThreadItems(): ArrayList<ThreadItem> {
|
||||
val items = ArrayList<ThreadItem>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue