Merge branch 'master' into add-sms-draft

This commit is contained in:
Agnieszka C 2021-09-08 15:10:07 +02:00 committed by GitHub
commit 14b7526ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -24,8 +24,10 @@ import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
import com.simplemobiletools.smsmessenger.extensions.deleteConversation
import com.simplemobiletools.smsmessenger.extensions.getSmsDraft
import com.simplemobiletools.smsmessenger.extensions.markThreadMessagesUnread
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
import com.simplemobiletools.smsmessenger.models.Conversation
import com.simplemobiletools.smsmessenger.models.Events
import kotlinx.android.synthetic.main.item_conversation.view.*
class ConversationsAdapter(
@ -61,6 +63,7 @@ class ConversationsAdapter(
R.id.cab_copy_number -> copyNumberToClipboard()
R.id.cab_delete -> askConfirmDelete()
R.id.cab_select_all -> selectAll()
R.id.cab_mark_as_unread -> markAsUnread()
}
}
@ -185,6 +188,23 @@ class ConversationsAdapter(
}
}
private fun markAsUnread() {
if (selectedKeys.isEmpty()) {
return
}
val conversationsMarkedAsUnread = conversations.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<Conversation>
ensureBackgroundThread {
conversationsMarkedAsUnread.filter { conversation -> conversation.read }.forEach {
activity.markThreadMessagesUnread(it.threadId)
}
activity.runOnUiThread {
refreshMessages()
finishActMode()
}
}
}
private fun addNumberToContact() {
val conversation = getSelectedItems().firstOrNull() ?: return
Intent().apply {

View File

@ -25,6 +25,10 @@
android:id="@+id/cab_copy_number"
android:title="@string/copy_number_to_clipboard"
app:showAsAction="never" />
<item
android:id="@+id/cab_mark_as_unread"
android:title="@string/mark_as_unread"
app:showAsAction="never" />
<item
android:id="@+id/cab_select_all"
android:title="@string/select_all"