Merge pull request #698 from esensar/feature/177-conversations-archive
Implement archive feature for conversations using system API
This commit is contained in:
commit
0c5242df2d
70 changed files with 1241 additions and 196 deletions
|
|
@ -250,6 +250,8 @@ class ThreadActivity : SimpleActivity() {
|
|||
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
||||
thread_toolbar.menu.apply {
|
||||
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
||||
findItem(R.id.archive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == false
|
||||
findItem(R.id.unarchive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == true
|
||||
findItem(R.id.rename_conversation).isVisible = participants.size > 1 && conversation != null
|
||||
findItem(R.id.conversation_details).isVisible = conversation != null
|
||||
findItem(R.id.block_number).title = addLockedLabelIfNeeded(R.string.block_number)
|
||||
|
|
@ -274,6 +276,8 @@ class ThreadActivity : SimpleActivity() {
|
|||
when (menuItem.itemId) {
|
||||
R.id.block_number -> tryBlocking()
|
||||
R.id.delete -> askConfirmDelete()
|
||||
R.id.archive -> archiveConversation()
|
||||
R.id.unarchive -> unarchiveConversation()
|
||||
R.id.rename_conversation -> renameConversation()
|
||||
R.id.conversation_details -> showConversationDetails()
|
||||
R.id.add_number_to_contact -> addNumberToContact()
|
||||
|
|
@ -913,7 +917,8 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(this, getString(R.string.delete_whole_conversation_confirmation)) {
|
||||
val confirmationMessage = R.string.delete_whole_conversation_confirmation
|
||||
ConfirmationDialog(this, getString(confirmationMessage)) {
|
||||
ensureBackgroundThread {
|
||||
deleteConversation(threadId)
|
||||
runOnUiThread {
|
||||
|
|
@ -924,6 +929,26 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun archiveConversation() {
|
||||
ensureBackgroundThread {
|
||||
updateConversationArchivedStatus(threadId, true)
|
||||
runOnUiThread {
|
||||
refreshMessages()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun unarchiveConversation() {
|
||||
ensureBackgroundThread {
|
||||
updateConversationArchivedStatus(threadId, false)
|
||||
runOnUiThread {
|
||||
refreshMessages()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialNumber() {
|
||||
val phoneNumber = participants.first().phoneNumbers.first().normalizedNumber
|
||||
dialNumber(phoneNumber)
|
||||
|
|
@ -1352,6 +1377,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
messagesDB.insertOrUpdate(message)
|
||||
updateConversationArchivedStatus(message.threadId, false)
|
||||
}
|
||||
|
||||
// show selected contacts, properly split to new lines when appropriate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue