Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes issue #1310 : Adds Select All Conversations Feature #1652

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class QkRealmAdapter<T : RealmModel, Binding : ViewBinding>

val selectionChanges: Subject<List<Long>> = BehaviorSubject.create()

private var selection = listOf<Long>()
var selection = listOf<Long>()

/**
* Toggles the selected state for a particular view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,22 @@ class ConversationsAdapter @Inject constructor(
override fun getItemViewType(position: Int): Int {
return if (getItem(position)?.unread == false) 0 else 1
}

fun selectAllConversations() {
data?.let { adapterItems ->
if (adapterItems.isNotEmpty()) {
//If data is empty, does not get into the scope.
selection = mutableListOf()
for (conversation in adapterItems) {
// Writing the code at individual adapter levels,
// since data can be of different object types,
// and not at [QkRealmAdapter]
(selection as MutableList<Long>).add(conversation.id)
}
selectionChanges.onNext(selection)
notifyDataSetChanged()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class MainActivity : QkThemedActivity(), MainView {
binding.toolbar.menu.findItem(R.id.read)?.isVisible = markRead && selectedConversations != 0
binding.toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
binding.toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
binding.toolbar.menu.findItem(R.id.select_all)?.isVisible = selectedConversations != 0 && selectedConversations!=conversationsAdapter.itemCount

listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge ->
badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
Expand Down Expand Up @@ -386,6 +387,10 @@ class MainActivity : QkThemedActivity(), MainView {
}
}

override fun selectAllConversations() {
conversationsAdapter.selectAllConversations()
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.main, menu)
return super.onCreateOptionsMenu(menu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface MainView : QkView<MainState> {
fun showDeleteDialog(conversations: List<Long>)
fun showChangelog(changelog: ChangelogManager.Changelog)
fun showArchivedSnackbar()

fun selectAllConversations()
}

enum class NavItem { BACK, INBOX, ARCHIVED, BACKUP, SCHEDULED, BLOCKING, SETTINGS, PLUS, HELP, INVITE }
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,14 @@ class MainViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe()

view.optionsItemIntent
.filter { itemId -> itemId == R.id.select_all }
.withLatestFrom(view.conversationsSelectedIntent) { _, _ ->
view.selectAllConversations()
}
.autoDisposable(view.scope())
.subscribe()

view.plusBannerIntent
.autoDisposable(view.scope())
.subscribe {
Expand Down
10 changes: 10 additions & 0 deletions presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5h2L5,3c-1.1,0 -2,0.9 -2,2zM3,13h2v-2L3,11v2zM7,21h2v-2L7,19v2zM3,9h2L5,7L3,7v2zM13,3h-2v2h2L13,3zM19,3v2h2c0,-1.1 -0.9,-2 -2,-2zM5,21v-2L3,19c0,1.1 0.9,2 2,2zM3,17h2v-2L3,15v2zM9,3L7,3v2h2L9,3zM11,21h2v-2h-2v2zM19,13h2v-2h-2v2zM19,21c1.1,0 2,-0.9 2,-2h-2v2zM19,9h2L21,7h-2v2zM19,17h2v-2h-2v2zM15,21h2v-2h-2v2zM15,5h2L17,3h-2v2zM7,17h10L17,7L7,7v10zM9,9h6v6L9,15L9,9z"/>
</vector>
7 changes: 7 additions & 0 deletions presentation/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,11 @@
android:visible="false"
app:showAsAction="ifRoom" />

<item
android:id="@+id/select_all"
android:icon="@drawable/ic_baseline_select_all_24dp"
android:title="@string/main_menu_select_all"
android:visible="false"
app:showAsAction="ifRoom" />

</menu>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,5 @@
<item>ههههههه</item>
<item>هذا مناسب</item>
</string-array>
<string name="main_menu_select_all">اختر الكل</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>হেহে</item>
<item>তা ঠিক।</item>
</string-array>
<string name="main_menu_select_all">সমস্ত নির্বাচন করুন</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>To je v pořádku</item>
</string-array>
<string name="main_menu_select_all">Vybrat vše</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Det er OK</item>
</string-array>
<string name="main_menu_select_all">Vælg alle</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Das ist OK</item>
</string-array>
<string name="main_menu_select_all">Wählen Sie Alle</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">Επιλογή όλων</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>JAJAJA</item>
<item>Está bien</item>
</string-array>
<string name="main_menu_select_all">Seleccionar todo</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>خخخخ</item>
<item>درست است</item>
</string-array>
<string name="main_menu_select_all">انتخاب همه</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Se on okei</item>
</string-array>
<string name="main_menu_select_all">Valitse kaikki</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>C\'est d\'accord</item>
</string-array>
<string name="main_menu_select_all">Tout sélectionner</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>ठीक है</item>
</string-array>
<string name="main_menu_select_all">सभी का चयन करे</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">Odaberi sve</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Semmi baj</item>
</string-array>
<string name="main_menu_select_all">Mindet kiválaszt</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>LOL</item>
<item>Tidak apa-apa</item>
</string-array>
<string name="main_menu_select_all">Pilih Semua</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Va bene</item>
</string-array>
<string name="main_menu_select_all">Seleziona tutto</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>חחח</item>
<item>הכול בסדר</item>
</string-array>
<string name="main_menu_select_all">בחר הכל</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>大爆笑です</item>
<item>いいんだよ</item>
</string-array>
<string name="main_menu_select_all">すべて選択</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,5 @@
<item>웃음</item>
<item>괜찮아요</item>
</string-array>
<string name="main_menu_select_all">모두 선택</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>HAHA</item>
<item>Viskas gerai</item>
</string-array>
<string name="main_menu_select_all">Pasirinkti viską</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Det er greit</item>
</string-array>
<string name="main_menu_select_all">Velg alle</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">सबै छान्नु</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Dat is oke</item>
</string-array>
<string name="main_menu_select_all">Selecteer alles</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>W porządku</item>
</string-array>
<string name="main_menu_select_all">Zaznacz wszystko</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>KKK</item>
<item>Está bem</item>
</string-array>
<string name="main_menu_select_all">Selecionar tudo</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Tudo bem</item>
</string-array>
<string name="main_menu_select_all">Selecionar tudo</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">Selectează tot</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>Это нормально</item>
</string-array>
<string name="main_menu_select_all">Выбрать все</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>To je v poriadku</item>
</string-array>
<string name="main_menu_select_all">Vybrať všetko</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-sl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>To je v redu</item>
</string-array>
<string name="main_menu_select_all">Izberi vse</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-sr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,5 @@
<item>Значи, ЛОЛ</item>
<item>Добро онда</item>
</string-array>
<string name="main_menu_select_all">Изабери све</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>Det är okej</item>
</string-array>
<string name="main_menu_select_all">Välj alla</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-th/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>555</item>
<item>ไม่เป็นไร</item>
</string-array>
<string name="main_menu_select_all">เลือกทั้งหมด</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-tl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">Piliin lahat</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,5 @@ BAĞLAM İSTEĞİ</string>
<item>He</item>
<item>Tamam o zaman</item>
</string-array>
<string name="main_menu_select_all">Hepsini seç</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<item>LOL</item>
<item>Це нормально</item>
</string-array>
<string name="main_menu_select_all">Hepsini seç</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-ur/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,5 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="main_menu_select_all">تمام منتخب کریں</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>LOL</item>
<item>Không sao đâu</item>
</string-array>
<string name="main_menu_select_all">Chọn tất cả</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>啊哈哈哈哈</item>
<item>好的</item>
</string-array>
<string name="main_menu_select_all">全选</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,5 @@
<item>啊哈哈哈哈</item>
<item>好的</item>
</string-array>
<string name="main_menu_select_all">全选</string>
</resources>
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<string name="main_menu_read">Mark read</string>
<string name="main_menu_unread">Mark unread</string>
<string name="main_menu_block">Block</string>
<string name="main_menu_select_all">Select All</string>
<string name="main_syncing">Syncing messages…</string>
<string name="main_sender_you">You: %s</string>
<string name="main_draft">Draft</string>
Expand Down