mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-19 11:51:40 +01:00
Merge branch 'master' into add-sms-draft
This commit is contained in:
commit
df8759e00a
@ -24,10 +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.markThreadMessagesRead
|
||||
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(
|
||||
@ -62,8 +62,9 @@ class ConversationsAdapter(
|
||||
R.id.cab_dial_number -> dialNumber()
|
||||
R.id.cab_copy_number -> copyNumberToClipboard()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
R.id.cab_mark_as_read -> markAsRead()
|
||||
R.id.cab_mark_as_unread -> markAsUnread()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,14 +189,15 @@ class ConversationsAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
private fun markAsUnread() {
|
||||
private fun markAsRead() {
|
||||
if (selectedKeys.isEmpty()) {
|
||||
return
|
||||
}
|
||||
val conversationsMarkedAsUnread = conversations.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<Conversation>
|
||||
|
||||
val conversationsMarkedAsRead = conversations.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<Conversation>
|
||||
ensureBackgroundThread {
|
||||
conversationsMarkedAsUnread.filter { conversation -> conversation.read }.forEach {
|
||||
activity.markThreadMessagesUnread(it.threadId)
|
||||
conversationsMarkedAsRead.filter { conversation -> !conversation.read }.forEach {
|
||||
activity.markThreadMessagesRead(it.threadId)
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
@ -205,6 +207,19 @@ 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addNumberToContact() {
|
||||
val conversation = getSelectedItems().firstOrNull() ?: return
|
||||
Intent().apply {
|
||||
|
@ -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_read"
|
||||
android:title="@string/mark_as_read"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/cab_mark_as_unread"
|
||||
android:title="@string/mark_as_unread"
|
||||
|
Loading…
Reference in New Issue
Block a user