forked from upstream-mirrors/quik
added select all actionbar item on main (inc archived) and compose activities. item becomes available when first item selected. menu item toggles select all/select none.
added indefinite timeout to archive snackbar on conversations activity when >= 10 conversations are archived at once. in case of accidental mass archive gives user more time to undo. added 'show status' menu item on compose activity that does the same as short touching on an item (exapnds it to show time, etc) but cn be applied to multiple selected items at once.
This commit is contained in:
+24
@@ -130,4 +130,28 @@ class ConversationsAdapter @Inject constructor(
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (getItem(position)?.unread == false) 0 else 1
|
||||
}
|
||||
|
||||
fun toggleSelectAll() {
|
||||
var needToSelectAll = false
|
||||
|
||||
// if a non-selected item is found, then we need to select all, otherwise deselect all
|
||||
for (position in 0 until itemCount)
|
||||
if (!isSelected(getItemId(position))) {
|
||||
needToSelectAll = true
|
||||
break
|
||||
}
|
||||
|
||||
// select or deselect item based on if toggling all selected of deselected
|
||||
for (position in 0 until itemCount) {
|
||||
val threadId = getItemId(position)
|
||||
// if deselecting all then toggle selection (we know all items are selected)
|
||||
if (!needToSelectAll)
|
||||
toggleSelection(threadId)
|
||||
// else, selecting all, toggle if not already selected
|
||||
else if (!isSelected(threadId))
|
||||
toggleSelection(threadId)
|
||||
}
|
||||
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user