From c0b55ca376ed7ff9045662404a9ee4481dd81a6d Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Fri, 22 Nov 2024 15:48:54 +0100 Subject: [PATCH] fix: Display correct plural form for NoValidMailboxes strings --- .../noValidMailboxes/NoValidMailboxesFragment.kt | 15 ++------------- .../noValidMailboxes/NoValidMailboxesViewModel.kt | 2 -- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesFragment.kt b/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesFragment.kt index 3293f7bdeb..f619e0618c 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesFragment.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesFragment.kt @@ -61,7 +61,6 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment { setupAdapters() setupListeners() - observeMailboxesCount() observeMailboxesLive() } @@ -97,23 +96,13 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment { noValidMailboxesViewModel.invalidPasswordMailboxesLive.observe(viewLifecycleOwner) { invalidPasswordMailboxes -> invalidPasswordMailboxesAdapter.setMailboxes(invalidPasswordMailboxes) invalidPasswordMailboxesGroup.isVisible = invalidPasswordMailboxes.isNotEmpty() + invalidPasswordTitle.text = resources.getQuantityString(R.plurals.blockedPasswordTitle, invalidPasswordMailboxes.count()) } noValidMailboxesViewModel.lockedMailboxesLive.observe(viewLifecycleOwner) { lockedMailboxes -> mailboxesAdapter.setMailboxes(lockedMailboxes) lockedMailboxesGroup.isVisible = lockedMailboxes.isNotEmpty() + lockedMailboxTitle.text = resources.getQuantityString(R.plurals.lockedMailboxTitle, lockedMailboxes.count()) } } - - private fun observeMailboxesCount() { - noValidMailboxesViewModel.mailboxesCountLive.observe(viewLifecycleOwner, ::setQuantityTextTitle) - } - - private fun setQuantityTextTitle(mailboxCount: Long) = with(binding) { - val count = mailboxCount.toInt() - val lockedMailboxTitleString = resources.getQuantityString(R.plurals.lockedMailboxTitle, count) - - invalidPasswordTitle.text = resources.getQuantityString(R.plurals.blockedPasswordTitle, count) - lockedMailboxTitle.text = lockedMailboxTitleString - } } diff --git a/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesViewModel.kt index 5e26e26c31..608a9b7b19 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/noValidMailboxes/NoValidMailboxesViewModel.kt @@ -36,8 +36,6 @@ class NoValidMailboxesViewModel @Inject constructor( private val ioCoroutineContext = viewModelScope.coroutineContext(ioDispatcher) - val mailboxesCountLive = mailboxController.getMailboxesCount(AccountUtils.currentUserId).asLiveData(ioCoroutineContext) - val lockedMailboxesLive = mailboxController.getLockedMailboxes(AccountUtils.currentUserId).asLiveData(ioCoroutineContext) val invalidPasswordMailboxesLive = mailboxController.getInvalidPasswordMailboxes(AccountUtils.currentUserId)