From 6e0ea16e53c77eb45635347c4384627b3eb59940 Mon Sep 17 00:00:00 2001 From: goforbg Date: Fri, 2 Oct 2020 15:14:57 +0530 Subject: [PATCH 1/5] Closes issue #1310 : Adds Select All Conversations Feature --- .../moez/QKSMS/common/base/QkRealmAdapter.kt | 2 +- .../conversations/ConversationsAdapter.kt | 18 ++++++++++++++++++ .../moez/QKSMS/feature/main/MainActivity.kt | 5 +++++ .../com/moez/QKSMS/feature/main/MainView.kt | 2 +- .../moez/QKSMS/feature/main/MainViewModel.kt | 8 ++++++++ .../drawable/ic_baseline_select_all_24dp.xml | 10 ++++++++++ presentation/src/main/res/menu/main.xml | 7 +++++++ .../src/main/res/values-ar/strings.xml | 1 + .../src/main/res/values-bn/strings.xml | 1 + .../src/main/res/values-cs/strings.xml | 1 + .../src/main/res/values-da/strings.xml | 1 + .../src/main/res/values-de/strings.xml | 1 + .../src/main/res/values-el/strings.xml | 1 + .../src/main/res/values-es/strings.xml | 1 + .../src/main/res/values-fa/strings.xml | 1 + .../src/main/res/values-fi/strings.xml | 1 + .../src/main/res/values-fr/strings.xml | 1 + .../src/main/res/values-hi/strings.xml | 1 + .../src/main/res/values-hr/strings.xml | 1 + .../src/main/res/values-hu/strings.xml | 1 + .../src/main/res/values-in/strings.xml | 1 + .../src/main/res/values-it/strings.xml | 1 + .../src/main/res/values-iw/strings.xml | 1 + .../src/main/res/values-ja/strings.xml | 1 + .../src/main/res/values-ko/strings.xml | 1 + .../src/main/res/values-lt/strings.xml | 1 + .../src/main/res/values-nb/strings.xml | 1 + .../src/main/res/values-ne/strings.xml | 1 + .../src/main/res/values-nl/strings.xml | 1 + .../src/main/res/values-pl/strings.xml | 1 + .../src/main/res/values-pt-rBR/strings.xml | 1 + .../src/main/res/values-pt/strings.xml | 1 + .../src/main/res/values-ro/strings.xml | 1 + .../src/main/res/values-ru/strings.xml | 1 + .../src/main/res/values-sk/strings.xml | 1 + .../src/main/res/values-sl/strings.xml | 1 + .../src/main/res/values-sr/strings.xml | 1 + .../src/main/res/values-sv/strings.xml | 1 + .../src/main/res/values-th/strings.xml | 1 + .../src/main/res/values-tl/strings.xml | 1 + .../src/main/res/values-tr/strings.xml | 1 + .../src/main/res/values-uk/strings.xml | 1 + .../src/main/res/values-ur/strings.xml | 1 + .../src/main/res/values-vi/strings.xml | 1 + .../src/main/res/values-zh-rCN/strings.xml | 1 + .../src/main/res/values-zh/strings.xml | 1 + presentation/src/main/res/values/strings.xml | 1 + 47 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml diff --git a/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt index 31fb5306d..bf083ea70 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt @@ -52,7 +52,7 @@ abstract class QkRealmAdapter val selectionChanges: Subject> = BehaviorSubject.create() - private var selection = listOf() + var selection = listOf() /** * Toggles the selected state for a particular view diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt index 370be6bce..25b1e7146 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt @@ -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).add(conversation.id) + } + selectionChanges.onNext(selection) + notifyDataSetChanged() + } + } + } + } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 088a8179f..d41e344e1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -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 @@ -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) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt index 47511e09f..c8a7b9f3b 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt @@ -52,7 +52,7 @@ interface MainView : QkView { fun showDeleteDialog(conversations: List) fun showChangelog(changelog: ChangelogManager.Changelog) fun showArchivedSnackbar() - + fun selectAllConversations() } enum class NavItem { BACK, INBOX, ARCHIVED, BACKUP, SCHEDULED, BLOCKING, SETTINGS, PLUS, HELP, INVITE } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index ac483a776..2c86c7a3b 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -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 { diff --git a/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml b/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml new file mode 100644 index 000000000..c997121c7 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/menu/main.xml b/presentation/src/main/res/menu/main.xml index 579d60abc..3602e3132 100644 --- a/presentation/src/main/res/menu/main.xml +++ b/presentation/src/main/res/menu/main.xml @@ -83,4 +83,11 @@ android:visible="false" app:showAsAction="ifRoom" /> + + \ No newline at end of file diff --git a/presentation/src/main/res/values-ar/strings.xml b/presentation/src/main/res/values-ar/strings.xml index 2fbeee309..7d076d334 100644 --- a/presentation/src/main/res/values-ar/strings.xml +++ b/presentation/src/main/res/values-ar/strings.xml @@ -415,4 +415,5 @@ ههههههه هذا مناسب + اختر الكل diff --git a/presentation/src/main/res/values-bn/strings.xml b/presentation/src/main/res/values-bn/strings.xml index f45596674..f66e855a4 100644 --- a/presentation/src/main/res/values-bn/strings.xml +++ b/presentation/src/main/res/values-bn/strings.xml @@ -394,4 +394,5 @@ হেহে তা ঠিক। + সমস্ত নির্বাচন করুন diff --git a/presentation/src/main/res/values-cs/strings.xml b/presentation/src/main/res/values-cs/strings.xml index 6ae6060a8..379cf7eae 100644 --- a/presentation/src/main/res/values-cs/strings.xml +++ b/presentation/src/main/res/values-cs/strings.xml @@ -404,4 +404,5 @@ LOL To je v pořádku + Vybrat vše diff --git a/presentation/src/main/res/values-da/strings.xml b/presentation/src/main/res/values-da/strings.xml index e2d01f787..63df790b5 100644 --- a/presentation/src/main/res/values-da/strings.xml +++ b/presentation/src/main/res/values-da/strings.xml @@ -394,4 +394,5 @@ LOL Det er OK + Vælg alle diff --git a/presentation/src/main/res/values-de/strings.xml b/presentation/src/main/res/values-de/strings.xml index 4ddd2bd70..ad8bc4dc0 100644 --- a/presentation/src/main/res/values-de/strings.xml +++ b/presentation/src/main/res/values-de/strings.xml @@ -394,4 +394,5 @@ LOL Das ist OK + Wählen Sie Alle diff --git a/presentation/src/main/res/values-el/strings.xml b/presentation/src/main/res/values-el/strings.xml index fa2df8978..9459de3cd 100644 --- a/presentation/src/main/res/values-el/strings.xml +++ b/presentation/src/main/res/values-el/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + Επιλογή όλων diff --git a/presentation/src/main/res/values-es/strings.xml b/presentation/src/main/res/values-es/strings.xml index b41dea7e4..8c444fa69 100644 --- a/presentation/src/main/res/values-es/strings.xml +++ b/presentation/src/main/res/values-es/strings.xml @@ -394,4 +394,5 @@ JAJAJA Está bien + Seleccionar todo diff --git a/presentation/src/main/res/values-fa/strings.xml b/presentation/src/main/res/values-fa/strings.xml index a4c94a066..cecb3cd4f 100644 --- a/presentation/src/main/res/values-fa/strings.xml +++ b/presentation/src/main/res/values-fa/strings.xml @@ -394,4 +394,5 @@ خخخخ درست است + انتخاب همه diff --git a/presentation/src/main/res/values-fi/strings.xml b/presentation/src/main/res/values-fi/strings.xml index 9446d4b9b..1f8849b6e 100644 --- a/presentation/src/main/res/values-fi/strings.xml +++ b/presentation/src/main/res/values-fi/strings.xml @@ -394,4 +394,5 @@ LOL Se on okei + Valitse kaikki diff --git a/presentation/src/main/res/values-fr/strings.xml b/presentation/src/main/res/values-fr/strings.xml index 96fbf8de6..2e69cc065 100644 --- a/presentation/src/main/res/values-fr/strings.xml +++ b/presentation/src/main/res/values-fr/strings.xml @@ -394,4 +394,5 @@ LOL C\'est d\'accord + Tout sélectionner diff --git a/presentation/src/main/res/values-hi/strings.xml b/presentation/src/main/res/values-hi/strings.xml index 7d0dcbf39..5deb86bf8 100644 --- a/presentation/src/main/res/values-hi/strings.xml +++ b/presentation/src/main/res/values-hi/strings.xml @@ -394,4 +394,5 @@ LOL ठीक है + सभी का चयन करे diff --git a/presentation/src/main/res/values-hr/strings.xml b/presentation/src/main/res/values-hr/strings.xml index 7ba312454..a4bf7721e 100644 --- a/presentation/src/main/res/values-hr/strings.xml +++ b/presentation/src/main/res/values-hr/strings.xml @@ -399,4 +399,5 @@ LOL That\'s okay + Odaberi sve diff --git a/presentation/src/main/res/values-hu/strings.xml b/presentation/src/main/res/values-hu/strings.xml index 78f78b584..c61e72cf9 100644 --- a/presentation/src/main/res/values-hu/strings.xml +++ b/presentation/src/main/res/values-hu/strings.xml @@ -394,4 +394,5 @@ LOL Semmi baj + Mindet kiválaszt diff --git a/presentation/src/main/res/values-in/strings.xml b/presentation/src/main/res/values-in/strings.xml index d3d82560d..6645397d9 100644 --- a/presentation/src/main/res/values-in/strings.xml +++ b/presentation/src/main/res/values-in/strings.xml @@ -389,4 +389,5 @@ LOL Tidak apa-apa + Pilih Semua diff --git a/presentation/src/main/res/values-it/strings.xml b/presentation/src/main/res/values-it/strings.xml index 9a898a3db..d741bd3af 100644 --- a/presentation/src/main/res/values-it/strings.xml +++ b/presentation/src/main/res/values-it/strings.xml @@ -394,4 +394,5 @@ LOL Va bene + Seleziona tutto diff --git a/presentation/src/main/res/values-iw/strings.xml b/presentation/src/main/res/values-iw/strings.xml index 2f0ef49e0..1eb412015 100644 --- a/presentation/src/main/res/values-iw/strings.xml +++ b/presentation/src/main/res/values-iw/strings.xml @@ -404,4 +404,5 @@ חחח הכול בסדר + בחר הכל diff --git a/presentation/src/main/res/values-ja/strings.xml b/presentation/src/main/res/values-ja/strings.xml index 0f8c83ede..060521d5b 100644 --- a/presentation/src/main/res/values-ja/strings.xml +++ b/presentation/src/main/res/values-ja/strings.xml @@ -389,4 +389,5 @@ 大爆笑です いいんだよ + すべて選択 diff --git a/presentation/src/main/res/values-ko/strings.xml b/presentation/src/main/res/values-ko/strings.xml index af4128d37..fe5d931f1 100644 --- a/presentation/src/main/res/values-ko/strings.xml +++ b/presentation/src/main/res/values-ko/strings.xml @@ -391,4 +391,5 @@ 웃음 괜찮아요 + 모두 선택 diff --git a/presentation/src/main/res/values-lt/strings.xml b/presentation/src/main/res/values-lt/strings.xml index 15332f97a..6593880f0 100644 --- a/presentation/src/main/res/values-lt/strings.xml +++ b/presentation/src/main/res/values-lt/strings.xml @@ -404,4 +404,5 @@ HAHA Viskas gerai + Pasirinkti viską diff --git a/presentation/src/main/res/values-nb/strings.xml b/presentation/src/main/res/values-nb/strings.xml index 54dafb565..de99a1fb6 100644 --- a/presentation/src/main/res/values-nb/strings.xml +++ b/presentation/src/main/res/values-nb/strings.xml @@ -394,4 +394,5 @@ LOL Det er greit + Velg alle diff --git a/presentation/src/main/res/values-ne/strings.xml b/presentation/src/main/res/values-ne/strings.xml index 7c86ccfc2..13796ee31 100644 --- a/presentation/src/main/res/values-ne/strings.xml +++ b/presentation/src/main/res/values-ne/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + सबै छान्नु diff --git a/presentation/src/main/res/values-nl/strings.xml b/presentation/src/main/res/values-nl/strings.xml index 8465731fd..8e914d2c5 100644 --- a/presentation/src/main/res/values-nl/strings.xml +++ b/presentation/src/main/res/values-nl/strings.xml @@ -394,4 +394,5 @@ LOL Dat is oke + Selecteer alles diff --git a/presentation/src/main/res/values-pl/strings.xml b/presentation/src/main/res/values-pl/strings.xml index 3d0c447c6..00c457bf6 100644 --- a/presentation/src/main/res/values-pl/strings.xml +++ b/presentation/src/main/res/values-pl/strings.xml @@ -404,4 +404,5 @@ LOL W porządku + Zaznacz wszystko diff --git a/presentation/src/main/res/values-pt-rBR/strings.xml b/presentation/src/main/res/values-pt-rBR/strings.xml index d9bd784c0..b8aeb8c71 100644 --- a/presentation/src/main/res/values-pt-rBR/strings.xml +++ b/presentation/src/main/res/values-pt-rBR/strings.xml @@ -394,4 +394,5 @@ KKK Está bem + Selecionar tudo diff --git a/presentation/src/main/res/values-pt/strings.xml b/presentation/src/main/res/values-pt/strings.xml index aa0b2dc2a..7bac62d5d 100644 --- a/presentation/src/main/res/values-pt/strings.xml +++ b/presentation/src/main/res/values-pt/strings.xml @@ -394,4 +394,5 @@ LOL Tudo bem + Selecionar tudo diff --git a/presentation/src/main/res/values-ro/strings.xml b/presentation/src/main/res/values-ro/strings.xml index 8c6e6ae86..c53224969 100644 --- a/presentation/src/main/res/values-ro/strings.xml +++ b/presentation/src/main/res/values-ro/strings.xml @@ -399,4 +399,5 @@ LOL That\'s okay + Selectează tot diff --git a/presentation/src/main/res/values-ru/strings.xml b/presentation/src/main/res/values-ru/strings.xml index 45c5717b3..e338e622d 100644 --- a/presentation/src/main/res/values-ru/strings.xml +++ b/presentation/src/main/res/values-ru/strings.xml @@ -404,4 +404,5 @@ LOL Это нормально + Выбрать все diff --git a/presentation/src/main/res/values-sk/strings.xml b/presentation/src/main/res/values-sk/strings.xml index ff0d89323..afbc47f56 100644 --- a/presentation/src/main/res/values-sk/strings.xml +++ b/presentation/src/main/res/values-sk/strings.xml @@ -404,4 +404,5 @@ LOL To je v poriadku + Vybrať všetko diff --git a/presentation/src/main/res/values-sl/strings.xml b/presentation/src/main/res/values-sl/strings.xml index eb4a56a04..d2dfd654d 100644 --- a/presentation/src/main/res/values-sl/strings.xml +++ b/presentation/src/main/res/values-sl/strings.xml @@ -404,4 +404,5 @@ LOL To je v redu + Izberi vse diff --git a/presentation/src/main/res/values-sr/strings.xml b/presentation/src/main/res/values-sr/strings.xml index c69447caa..8a2508935 100644 --- a/presentation/src/main/res/values-sr/strings.xml +++ b/presentation/src/main/res/values-sr/strings.xml @@ -399,4 +399,5 @@ Значи, ЛОЛ Добро онда + Изабери све diff --git a/presentation/src/main/res/values-sv/strings.xml b/presentation/src/main/res/values-sv/strings.xml index 30a8a5b13..ed49d9d14 100644 --- a/presentation/src/main/res/values-sv/strings.xml +++ b/presentation/src/main/res/values-sv/strings.xml @@ -394,4 +394,5 @@ LOL Det är okej + Välj alla diff --git a/presentation/src/main/res/values-th/strings.xml b/presentation/src/main/res/values-th/strings.xml index cb366da8d..635e5b84d 100644 --- a/presentation/src/main/res/values-th/strings.xml +++ b/presentation/src/main/res/values-th/strings.xml @@ -389,4 +389,5 @@ 555 ไม่เป็นไร + เลือกทั้งหมด diff --git a/presentation/src/main/res/values-tl/strings.xml b/presentation/src/main/res/values-tl/strings.xml index 187332d49..f82a7ca38 100644 --- a/presentation/src/main/res/values-tl/strings.xml +++ b/presentation/src/main/res/values-tl/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + Piliin lahat diff --git a/presentation/src/main/res/values-tr/strings.xml b/presentation/src/main/res/values-tr/strings.xml index 891dafb73..d7cf0ac4f 100644 --- a/presentation/src/main/res/values-tr/strings.xml +++ b/presentation/src/main/res/values-tr/strings.xml @@ -396,4 +396,5 @@ BAĞLAM İSTEĞİ He Tamam o zaman + Hepsini seç diff --git a/presentation/src/main/res/values-uk/strings.xml b/presentation/src/main/res/values-uk/strings.xml index d586fc98e..5441c2960 100644 --- a/presentation/src/main/res/values-uk/strings.xml +++ b/presentation/src/main/res/values-uk/strings.xml @@ -404,4 +404,5 @@ LOL Це нормально + Hepsini seç diff --git a/presentation/src/main/res/values-ur/strings.xml b/presentation/src/main/res/values-ur/strings.xml index 8833a810c..5fc2f9653 100644 --- a/presentation/src/main/res/values-ur/strings.xml +++ b/presentation/src/main/res/values-ur/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + تمام منتخب کریں diff --git a/presentation/src/main/res/values-vi/strings.xml b/presentation/src/main/res/values-vi/strings.xml index 24b7ee63c..227639f1f 100644 --- a/presentation/src/main/res/values-vi/strings.xml +++ b/presentation/src/main/res/values-vi/strings.xml @@ -389,4 +389,5 @@ LOL Không sao đâu + Chọn tất cả diff --git a/presentation/src/main/res/values-zh-rCN/strings.xml b/presentation/src/main/res/values-zh-rCN/strings.xml index a0e3ebece..334d2ef9a 100644 --- a/presentation/src/main/res/values-zh-rCN/strings.xml +++ b/presentation/src/main/res/values-zh-rCN/strings.xml @@ -389,4 +389,5 @@ 啊哈哈哈哈 好的 + 全选 diff --git a/presentation/src/main/res/values-zh/strings.xml b/presentation/src/main/res/values-zh/strings.xml index dde414220..9299ee596 100644 --- a/presentation/src/main/res/values-zh/strings.xml +++ b/presentation/src/main/res/values-zh/strings.xml @@ -389,4 +389,5 @@ 啊哈哈哈哈 好的 + 全选 diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 402826083..fe5c6f0f3 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -53,6 +53,7 @@ Mark read Mark unread Block + Select All Syncing messages… You: %s Draft From 9ea03efb68b68efe9d5fa155ce44f09437c1446d Mon Sep 17 00:00:00 2001 From: goforbg Date: Fri, 2 Oct 2020 16:18:33 +0530 Subject: [PATCH 2/5] Adds "Select All" Option in Main Menu --- .../com/moez/QKSMS/common/base/QkRealmAdapter.kt | 2 +- .../feature/conversations/ConversationsAdapter.kt | 14 ++++++++++++++ .../com/moez/QKSMS/feature/main/MainActivity.kt | 5 +++++ .../java/com/moez/QKSMS/feature/main/MainView.kt | 2 +- .../com/moez/QKSMS/feature/main/MainViewModel.kt | 8 ++++++++ .../res/drawable/ic_baseline_select_all_24dp.xml | 10 ++++++++++ presentation/src/main/res/menu/main.xml | 7 +++++++ presentation/src/main/res/values/strings.xml | 1 + 8 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml diff --git a/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt index 31fb5306d..bf083ea70 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt @@ -52,7 +52,7 @@ abstract class QkRealmAdapter val selectionChanges: Subject> = BehaviorSubject.create() - private var selection = listOf() + var selection = listOf() /** * Toggles the selected state for a particular view diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt index 370be6bce..22ab992eb 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt @@ -127,4 +127,18 @@ 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()) { + selection = mutableListOf() + for (conversation in adapterItems) { + (selection as MutableList).add(conversation.id) + } + selectionChanges.onNext(selection) + notifyDataSetChanged() + } + } + } + } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 088a8179f..7459d57c4 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -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 listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge -> badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded @@ -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) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt index 47511e09f..c8a7b9f3b 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt @@ -52,7 +52,7 @@ interface MainView : QkView { fun showDeleteDialog(conversations: List) fun showChangelog(changelog: ChangelogManager.Changelog) fun showArchivedSnackbar() - + fun selectAllConversations() } enum class NavItem { BACK, INBOX, ARCHIVED, BACKUP, SCHEDULED, BLOCKING, SETTINGS, PLUS, HELP, INVITE } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index ac483a776..2c86c7a3b 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -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 { diff --git a/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml b/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml new file mode 100644 index 000000000..c997121c7 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_baseline_select_all_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/menu/main.xml b/presentation/src/main/res/menu/main.xml index 579d60abc..3602e3132 100644 --- a/presentation/src/main/res/menu/main.xml +++ b/presentation/src/main/res/menu/main.xml @@ -83,4 +83,11 @@ android:visible="false" app:showAsAction="ifRoom" /> + + \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 402826083..fe5c6f0f3 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -53,6 +53,7 @@ Mark read Mark unread Block + Select All Syncing messages… You: %s Draft From 4192ab9ed1eb4436c86b53cb0f03aa5dccdac291 Mon Sep 17 00:00:00 2001 From: goforbg Date: Fri, 2 Oct 2020 16:19:23 +0530 Subject: [PATCH 3/5] Hides "Select All" Button when all items of list are already selected --- .../src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 7459d57c4..d41e344e1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -225,7 +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 + 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 From ed74e7600bd5c5597117b61ce249d1b25b017ae8 Mon Sep 17 00:00:00 2001 From: goforbg Date: Fri, 2 Oct 2020 16:19:54 +0530 Subject: [PATCH 4/5] Adds translations in all langauges for "Select All" feature --- presentation/src/main/res/values-ar/strings.xml | 1 + presentation/src/main/res/values-bn/strings.xml | 1 + presentation/src/main/res/values-cs/strings.xml | 1 + presentation/src/main/res/values-da/strings.xml | 1 + presentation/src/main/res/values-de/strings.xml | 1 + presentation/src/main/res/values-el/strings.xml | 1 + presentation/src/main/res/values-es/strings.xml | 1 + presentation/src/main/res/values-fa/strings.xml | 1 + presentation/src/main/res/values-fi/strings.xml | 1 + presentation/src/main/res/values-fr/strings.xml | 1 + presentation/src/main/res/values-hi/strings.xml | 1 + presentation/src/main/res/values-hr/strings.xml | 1 + presentation/src/main/res/values-hu/strings.xml | 1 + presentation/src/main/res/values-in/strings.xml | 1 + presentation/src/main/res/values-it/strings.xml | 1 + presentation/src/main/res/values-iw/strings.xml | 1 + presentation/src/main/res/values-ja/strings.xml | 1 + presentation/src/main/res/values-ko/strings.xml | 1 + presentation/src/main/res/values-lt/strings.xml | 1 + presentation/src/main/res/values-nb/strings.xml | 1 + presentation/src/main/res/values-ne/strings.xml | 1 + presentation/src/main/res/values-nl/strings.xml | 1 + presentation/src/main/res/values-pl/strings.xml | 1 + presentation/src/main/res/values-pt-rBR/strings.xml | 1 + presentation/src/main/res/values-pt/strings.xml | 1 + presentation/src/main/res/values-ro/strings.xml | 1 + presentation/src/main/res/values-ru/strings.xml | 1 + presentation/src/main/res/values-sk/strings.xml | 1 + presentation/src/main/res/values-sl/strings.xml | 1 + presentation/src/main/res/values-sr/strings.xml | 1 + presentation/src/main/res/values-sv/strings.xml | 1 + presentation/src/main/res/values-th/strings.xml | 1 + presentation/src/main/res/values-tl/strings.xml | 1 + presentation/src/main/res/values-tr/strings.xml | 1 + presentation/src/main/res/values-uk/strings.xml | 1 + presentation/src/main/res/values-ur/strings.xml | 1 + presentation/src/main/res/values-vi/strings.xml | 1 + presentation/src/main/res/values-zh-rCN/strings.xml | 1 + presentation/src/main/res/values-zh/strings.xml | 1 + 39 files changed, 39 insertions(+) diff --git a/presentation/src/main/res/values-ar/strings.xml b/presentation/src/main/res/values-ar/strings.xml index 2fbeee309..7d076d334 100644 --- a/presentation/src/main/res/values-ar/strings.xml +++ b/presentation/src/main/res/values-ar/strings.xml @@ -415,4 +415,5 @@ ههههههه هذا مناسب + اختر الكل diff --git a/presentation/src/main/res/values-bn/strings.xml b/presentation/src/main/res/values-bn/strings.xml index f45596674..f66e855a4 100644 --- a/presentation/src/main/res/values-bn/strings.xml +++ b/presentation/src/main/res/values-bn/strings.xml @@ -394,4 +394,5 @@ হেহে তা ঠিক। + সমস্ত নির্বাচন করুন diff --git a/presentation/src/main/res/values-cs/strings.xml b/presentation/src/main/res/values-cs/strings.xml index 6ae6060a8..379cf7eae 100644 --- a/presentation/src/main/res/values-cs/strings.xml +++ b/presentation/src/main/res/values-cs/strings.xml @@ -404,4 +404,5 @@ LOL To je v pořádku + Vybrat vše diff --git a/presentation/src/main/res/values-da/strings.xml b/presentation/src/main/res/values-da/strings.xml index e2d01f787..63df790b5 100644 --- a/presentation/src/main/res/values-da/strings.xml +++ b/presentation/src/main/res/values-da/strings.xml @@ -394,4 +394,5 @@ LOL Det er OK + Vælg alle diff --git a/presentation/src/main/res/values-de/strings.xml b/presentation/src/main/res/values-de/strings.xml index 4ddd2bd70..ad8bc4dc0 100644 --- a/presentation/src/main/res/values-de/strings.xml +++ b/presentation/src/main/res/values-de/strings.xml @@ -394,4 +394,5 @@ LOL Das ist OK + Wählen Sie Alle diff --git a/presentation/src/main/res/values-el/strings.xml b/presentation/src/main/res/values-el/strings.xml index fa2df8978..9459de3cd 100644 --- a/presentation/src/main/res/values-el/strings.xml +++ b/presentation/src/main/res/values-el/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + Επιλογή όλων diff --git a/presentation/src/main/res/values-es/strings.xml b/presentation/src/main/res/values-es/strings.xml index b41dea7e4..8c444fa69 100644 --- a/presentation/src/main/res/values-es/strings.xml +++ b/presentation/src/main/res/values-es/strings.xml @@ -394,4 +394,5 @@ JAJAJA Está bien + Seleccionar todo diff --git a/presentation/src/main/res/values-fa/strings.xml b/presentation/src/main/res/values-fa/strings.xml index a4c94a066..cecb3cd4f 100644 --- a/presentation/src/main/res/values-fa/strings.xml +++ b/presentation/src/main/res/values-fa/strings.xml @@ -394,4 +394,5 @@ خخخخ درست است + انتخاب همه diff --git a/presentation/src/main/res/values-fi/strings.xml b/presentation/src/main/res/values-fi/strings.xml index 9446d4b9b..1f8849b6e 100644 --- a/presentation/src/main/res/values-fi/strings.xml +++ b/presentation/src/main/res/values-fi/strings.xml @@ -394,4 +394,5 @@ LOL Se on okei + Valitse kaikki diff --git a/presentation/src/main/res/values-fr/strings.xml b/presentation/src/main/res/values-fr/strings.xml index 96fbf8de6..2e69cc065 100644 --- a/presentation/src/main/res/values-fr/strings.xml +++ b/presentation/src/main/res/values-fr/strings.xml @@ -394,4 +394,5 @@ LOL C\'est d\'accord + Tout sélectionner diff --git a/presentation/src/main/res/values-hi/strings.xml b/presentation/src/main/res/values-hi/strings.xml index 7d0dcbf39..5deb86bf8 100644 --- a/presentation/src/main/res/values-hi/strings.xml +++ b/presentation/src/main/res/values-hi/strings.xml @@ -394,4 +394,5 @@ LOL ठीक है + सभी का चयन करे diff --git a/presentation/src/main/res/values-hr/strings.xml b/presentation/src/main/res/values-hr/strings.xml index 7ba312454..a4bf7721e 100644 --- a/presentation/src/main/res/values-hr/strings.xml +++ b/presentation/src/main/res/values-hr/strings.xml @@ -399,4 +399,5 @@ LOL That\'s okay + Odaberi sve diff --git a/presentation/src/main/res/values-hu/strings.xml b/presentation/src/main/res/values-hu/strings.xml index 78f78b584..c61e72cf9 100644 --- a/presentation/src/main/res/values-hu/strings.xml +++ b/presentation/src/main/res/values-hu/strings.xml @@ -394,4 +394,5 @@ LOL Semmi baj + Mindet kiválaszt diff --git a/presentation/src/main/res/values-in/strings.xml b/presentation/src/main/res/values-in/strings.xml index d3d82560d..6645397d9 100644 --- a/presentation/src/main/res/values-in/strings.xml +++ b/presentation/src/main/res/values-in/strings.xml @@ -389,4 +389,5 @@ LOL Tidak apa-apa + Pilih Semua diff --git a/presentation/src/main/res/values-it/strings.xml b/presentation/src/main/res/values-it/strings.xml index 9a898a3db..d741bd3af 100644 --- a/presentation/src/main/res/values-it/strings.xml +++ b/presentation/src/main/res/values-it/strings.xml @@ -394,4 +394,5 @@ LOL Va bene + Seleziona tutto diff --git a/presentation/src/main/res/values-iw/strings.xml b/presentation/src/main/res/values-iw/strings.xml index 2f0ef49e0..1eb412015 100644 --- a/presentation/src/main/res/values-iw/strings.xml +++ b/presentation/src/main/res/values-iw/strings.xml @@ -404,4 +404,5 @@ חחח הכול בסדר + בחר הכל diff --git a/presentation/src/main/res/values-ja/strings.xml b/presentation/src/main/res/values-ja/strings.xml index 0f8c83ede..060521d5b 100644 --- a/presentation/src/main/res/values-ja/strings.xml +++ b/presentation/src/main/res/values-ja/strings.xml @@ -389,4 +389,5 @@ 大爆笑です いいんだよ + すべて選択 diff --git a/presentation/src/main/res/values-ko/strings.xml b/presentation/src/main/res/values-ko/strings.xml index af4128d37..fe5d931f1 100644 --- a/presentation/src/main/res/values-ko/strings.xml +++ b/presentation/src/main/res/values-ko/strings.xml @@ -391,4 +391,5 @@ 웃음 괜찮아요 + 모두 선택 diff --git a/presentation/src/main/res/values-lt/strings.xml b/presentation/src/main/res/values-lt/strings.xml index 15332f97a..6593880f0 100644 --- a/presentation/src/main/res/values-lt/strings.xml +++ b/presentation/src/main/res/values-lt/strings.xml @@ -404,4 +404,5 @@ HAHA Viskas gerai + Pasirinkti viską diff --git a/presentation/src/main/res/values-nb/strings.xml b/presentation/src/main/res/values-nb/strings.xml index 54dafb565..de99a1fb6 100644 --- a/presentation/src/main/res/values-nb/strings.xml +++ b/presentation/src/main/res/values-nb/strings.xml @@ -394,4 +394,5 @@ LOL Det er greit + Velg alle diff --git a/presentation/src/main/res/values-ne/strings.xml b/presentation/src/main/res/values-ne/strings.xml index 7c86ccfc2..13796ee31 100644 --- a/presentation/src/main/res/values-ne/strings.xml +++ b/presentation/src/main/res/values-ne/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + सबै छान्नु diff --git a/presentation/src/main/res/values-nl/strings.xml b/presentation/src/main/res/values-nl/strings.xml index 8465731fd..8e914d2c5 100644 --- a/presentation/src/main/res/values-nl/strings.xml +++ b/presentation/src/main/res/values-nl/strings.xml @@ -394,4 +394,5 @@ LOL Dat is oke + Selecteer alles diff --git a/presentation/src/main/res/values-pl/strings.xml b/presentation/src/main/res/values-pl/strings.xml index 3d0c447c6..00c457bf6 100644 --- a/presentation/src/main/res/values-pl/strings.xml +++ b/presentation/src/main/res/values-pl/strings.xml @@ -404,4 +404,5 @@ LOL W porządku + Zaznacz wszystko diff --git a/presentation/src/main/res/values-pt-rBR/strings.xml b/presentation/src/main/res/values-pt-rBR/strings.xml index d9bd784c0..b8aeb8c71 100644 --- a/presentation/src/main/res/values-pt-rBR/strings.xml +++ b/presentation/src/main/res/values-pt-rBR/strings.xml @@ -394,4 +394,5 @@ KKK Está bem + Selecionar tudo diff --git a/presentation/src/main/res/values-pt/strings.xml b/presentation/src/main/res/values-pt/strings.xml index aa0b2dc2a..7bac62d5d 100644 --- a/presentation/src/main/res/values-pt/strings.xml +++ b/presentation/src/main/res/values-pt/strings.xml @@ -394,4 +394,5 @@ LOL Tudo bem + Selecionar tudo diff --git a/presentation/src/main/res/values-ro/strings.xml b/presentation/src/main/res/values-ro/strings.xml index 8c6e6ae86..c53224969 100644 --- a/presentation/src/main/res/values-ro/strings.xml +++ b/presentation/src/main/res/values-ro/strings.xml @@ -399,4 +399,5 @@ LOL That\'s okay + Selectează tot diff --git a/presentation/src/main/res/values-ru/strings.xml b/presentation/src/main/res/values-ru/strings.xml index 45c5717b3..e338e622d 100644 --- a/presentation/src/main/res/values-ru/strings.xml +++ b/presentation/src/main/res/values-ru/strings.xml @@ -404,4 +404,5 @@ LOL Это нормально + Выбрать все diff --git a/presentation/src/main/res/values-sk/strings.xml b/presentation/src/main/res/values-sk/strings.xml index ff0d89323..afbc47f56 100644 --- a/presentation/src/main/res/values-sk/strings.xml +++ b/presentation/src/main/res/values-sk/strings.xml @@ -404,4 +404,5 @@ LOL To je v poriadku + Vybrať všetko diff --git a/presentation/src/main/res/values-sl/strings.xml b/presentation/src/main/res/values-sl/strings.xml index eb4a56a04..d2dfd654d 100644 --- a/presentation/src/main/res/values-sl/strings.xml +++ b/presentation/src/main/res/values-sl/strings.xml @@ -404,4 +404,5 @@ LOL To je v redu + Izberi vse diff --git a/presentation/src/main/res/values-sr/strings.xml b/presentation/src/main/res/values-sr/strings.xml index c69447caa..8a2508935 100644 --- a/presentation/src/main/res/values-sr/strings.xml +++ b/presentation/src/main/res/values-sr/strings.xml @@ -399,4 +399,5 @@ Значи, ЛОЛ Добро онда + Изабери све diff --git a/presentation/src/main/res/values-sv/strings.xml b/presentation/src/main/res/values-sv/strings.xml index 30a8a5b13..ed49d9d14 100644 --- a/presentation/src/main/res/values-sv/strings.xml +++ b/presentation/src/main/res/values-sv/strings.xml @@ -394,4 +394,5 @@ LOL Det är okej + Välj alla diff --git a/presentation/src/main/res/values-th/strings.xml b/presentation/src/main/res/values-th/strings.xml index cb366da8d..635e5b84d 100644 --- a/presentation/src/main/res/values-th/strings.xml +++ b/presentation/src/main/res/values-th/strings.xml @@ -389,4 +389,5 @@ 555 ไม่เป็นไร + เลือกทั้งหมด diff --git a/presentation/src/main/res/values-tl/strings.xml b/presentation/src/main/res/values-tl/strings.xml index 187332d49..f82a7ca38 100644 --- a/presentation/src/main/res/values-tl/strings.xml +++ b/presentation/src/main/res/values-tl/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + Piliin lahat diff --git a/presentation/src/main/res/values-tr/strings.xml b/presentation/src/main/res/values-tr/strings.xml index 891dafb73..d7cf0ac4f 100644 --- a/presentation/src/main/res/values-tr/strings.xml +++ b/presentation/src/main/res/values-tr/strings.xml @@ -396,4 +396,5 @@ BAĞLAM İSTEĞİ He Tamam o zaman + Hepsini seç diff --git a/presentation/src/main/res/values-uk/strings.xml b/presentation/src/main/res/values-uk/strings.xml index d586fc98e..5441c2960 100644 --- a/presentation/src/main/res/values-uk/strings.xml +++ b/presentation/src/main/res/values-uk/strings.xml @@ -404,4 +404,5 @@ LOL Це нормально + Hepsini seç diff --git a/presentation/src/main/res/values-ur/strings.xml b/presentation/src/main/res/values-ur/strings.xml index 8833a810c..5fc2f9653 100644 --- a/presentation/src/main/res/values-ur/strings.xml +++ b/presentation/src/main/res/values-ur/strings.xml @@ -394,4 +394,5 @@ LOL That\'s okay + تمام منتخب کریں diff --git a/presentation/src/main/res/values-vi/strings.xml b/presentation/src/main/res/values-vi/strings.xml index 24b7ee63c..227639f1f 100644 --- a/presentation/src/main/res/values-vi/strings.xml +++ b/presentation/src/main/res/values-vi/strings.xml @@ -389,4 +389,5 @@ LOL Không sao đâu + Chọn tất cả diff --git a/presentation/src/main/res/values-zh-rCN/strings.xml b/presentation/src/main/res/values-zh-rCN/strings.xml index a0e3ebece..334d2ef9a 100644 --- a/presentation/src/main/res/values-zh-rCN/strings.xml +++ b/presentation/src/main/res/values-zh-rCN/strings.xml @@ -389,4 +389,5 @@ 啊哈哈哈哈 好的 + 全选 diff --git a/presentation/src/main/res/values-zh/strings.xml b/presentation/src/main/res/values-zh/strings.xml index dde414220..9299ee596 100644 --- a/presentation/src/main/res/values-zh/strings.xml +++ b/presentation/src/main/res/values-zh/strings.xml @@ -389,4 +389,5 @@ 啊哈哈哈哈 好的 + 全选 From cf8cb5370cece85633a1696c8ffc1d18e6815317 Mon Sep 17 00:00:00 2001 From: goforbg Date: Fri, 2 Oct 2020 16:20:47 +0530 Subject: [PATCH 5/5] Provided comments on why "Select All Conversations" are implemented at child adapter-level. --- .../moez/QKSMS/feature/conversations/ConversationsAdapter.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt index 22ab992eb..25b1e7146 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt @@ -131,8 +131,12 @@ class ConversationsAdapter @Inject constructor( 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).add(conversation.id) } selectionChanges.onNext(selection)