Skip to content

feat: Show all selected languages and categories in online library#4705

Open
harshsomankar123-tech wants to merge 11 commits intokiwix:mainfrom
harshsomankar123-tech:language
Open

feat: Show all selected languages and categories in online library#4705
harshsomankar123-tech wants to merge 11 commits intokiwix:mainfrom
harshsomankar123-tech:language

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Contributor

@harshsomankar123-tech harshsomankar123-tech commented Feb 19, 2026

fixes #4624

Summary
Enabled multi-selection support for languages and categories in the online library, allowing users to filter content across multiple criteria simultaneously.

Key Changes
Filter Expansion: Updated the online library logic to process and display results for all selected languages and categories rather than a single selection.

UI/UX Updates:

  1. implemented HeaderText composable for improved layout consistency.
  2. Adjusted LanguageScreen.kt layout modifiers to correctly handle bottom bar padding.
  3. Added resetSearchState functionality to clear filters and search text efficiently.

Test & CI Fixes:

  1. Resolved failing testLanguageFragment and other UI test suites by restoring flow consumption bounds.
  2. Added automated clearing of language and category filters during download test setup to prevent cross-test interference.
  3. Static Analysis: Suppressed LongParameterList detekt warnings in ZimManageViewModel following the architectural changes.

Screenshots

Screen.Recording.2026-02-19.at.16.21.34.mov

@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft February 19, 2026 10:56
@harshsomankar123-tech harshsomankar123-tech force-pushed the language branch 5 times, most recently from fbb5f14 to e91837d Compare February 21, 2026 15:59
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review February 22, 2026 19:57
@MohitMaliFtechiz MohitMaliFtechiz self-requested a review February 23, 2026 10:32
Copy link
Copy Markdown
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshsomankar123-tech The testLanguageFragment is failing, please fix that one. Also see the review changes.

import org.kiwix.kiwixmobile.core.utils.ComposeDimens

@Composable
fun HeaderText(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove this. We should show the selected languages in a section as it was showing previously. Don't change the UI. If you see in the current video you have uploaded in the PR description, it does not look good.

.padding(ComposeDimens.SIXTEEN_DP)
.semantics {
testTag = "$LANGUAGE_ITEM_RADIO_BUTTON_TESTING_TAG${language.language}"
testTag = "languageItemCheckboxTestingTag${language.language}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hardcode the tags. It should be used from the constant as it was before.

var isSearchActive by rememberSaveable { mutableStateOf(false) }

fun resetSearchState() {
// clears the search text and resets the filter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove the comments.

Column(
modifier = Modifier
.fillMaxSize()
// setting bottom padding to zero to avoid accounting for Bottom bar
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too. It helps us understand why we have added the code.

else -> null // Handle the case when both conditions are false
else -> null
},
// Second item: always included
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

import org.kiwix.kiwixmobile.core.ui.components.ONE

object OnlineLibraryHeaderHelper {
fun getOnlineLibrarySectionTitle(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be placed in the viewModel. It does not need to be written in a separate class.

import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.zimManager.libraryView.LibraryListItem

sealed class FileSelectActions {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be separate. Because now we are splitting things into dedicated viewModels. E.g., LibraryViewModel, OnlineViewModel, so these will be automatically split into those view models and reduce the size of the viewModel.

val kiwixService: KiwixService
)

object OnlineLibraryServiceFactory {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshsomankar123-tech I appreciate your thinking of splitting this one. But this should be a class, not an object, and it should be injected into the viewModel, then we should use it. It would be easy for testing as well.

originalResponse
}
private fun createBaseOkHttpClient(): OkHttpClient =
OkHttpClient().newBuilder()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are creating this OkHttpClient here and updating this in OnlineLibraryServiceFactory, which is not a good idea. Because this OkHttpClient is only used for getting the online books, and it should be prepared in one place. So we should move this to OnlineLibraryServiceFactory.

We need the baseClient in getContentLengthOfLibraryXmlFile so it can be easily accessible from that class.

@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft February 23, 2026 13:58
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Feb 25, 2026
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Feb 25, 2026
@harshsomankar123-tech harshsomankar123-tech force-pushed the language branch 2 times, most recently from 1eb04bf to 55e5046 Compare February 25, 2026 21:13
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review February 26, 2026 19:14
@harshsomankar123-tech
Copy link
Copy Markdown
Contributor Author

@MohitMaliFtechiz I’ve pushed the latest updates. Please review when you get a chance. If the changes look fine, I’ll move ahead with resolving the CI failures.

@MohitMaliFtechiz MohitMaliFtechiz self-requested a review February 27, 2026 07:08
Copy link
Copy Markdown
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshsomankar123-tech There are some issues and improvements. See the video below.

  • When we select the "All category" or "All language" and come back again to the category or language screen, they are not selected.
  • The second thing is if the user selects the "All category" then all other categories should be deselected. Or if the "All category" is selected and the user selects another category, then "All category" should be deselected. Because it does not make sense when a user wants to get books of a category, and also the "All category" is selected. Same for language as well.
screen-20260227-145906-1772184476548.mp4
  • The second thing is where we are selecting multiple languages. The text does not look good.
  • Also, there is no text to show which categories are selected. We should show that also as we are showing the languages.
Image

import javax.inject.Inject

class LanguageViewModel @Inject constructor(
open class LanguageViewModel @Inject constructor(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this as a final class. We should not make it open just for setting isUnitTestCase.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a function for this.

is Filter -> filter(action, currentState)
is Select -> select(action, currentState)
Save -> saveAction(currentState)
ClearAll -> clearAll(currentState)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From where this ClearAll is emitting. I am not seeing any usage of it in the real codebase.

Same for SelectAll, and Cancel.

import javax.inject.Inject

class CategoryViewModel @Inject constructor(
open class CategoryViewModel @Inject constructor(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this class.

is Filter -> filter(action, currentState)
is Select -> select(action, currentState)
Action.Save -> saveAction(currentState)
Action.ClearAll -> clearAll(currentState)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for these ones? Cancel, SelectAll, and ClearAll.

title = stringResource(R.string.select_category),
navigationIcon = navigationIcon
navigationIcon = navigationIcon,
actionMenuItems = listOf(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should split this into a function to improve readability and future improvements.

when (item) {
is HeaderItem -> "header_${item.id}"
is CategoryItem -> "language_${item.category.id}"
is CategoryItem -> "category_${item.category.id}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!!

import org.kiwix.kiwixmobile.core.entity.LibkiwixBook
import org.kiwix.kiwixmobile.zimManager.libraryView.LibraryListItem

data class OnlineLibraryRequest(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this ZimManageModels class. We will now move it to the OnlineLibraryViewModel so the name of this class should be more familiar with that. Also, ZimManageModels does not justify its class responsibility. Because it only contains the onlineLibrary models. So the class name should be improved here.

@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft February 27, 2026 10:20
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 1, 2026
@harshsomankar123-tech harshsomankar123-tech force-pushed the language branch 2 times, most recently from 9ddc7bf to b8750fc Compare March 2, 2026 22:52
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review March 3, 2026 06:24
@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft March 6, 2026 16:57
@harshsomankar123-tech harshsomankar123-tech force-pushed the language branch 2 times, most recently from 694e7c5 to f8f1c71 Compare March 6, 2026 17:35
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 15, 2026
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review March 15, 2026 23:30
@harshsomankar123-tech
Copy link
Copy Markdown
Contributor Author

@MohitMaliFtechiz PTAL

@MohitMaliFtechiz MohitMaliFtechiz self-requested a review March 16, 2026 12:53
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 16, 2026
@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft March 18, 2026 18:37
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 22, 2026
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 25, 2026
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Mar 25, 2026
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Apr 7, 2026
harshsomankar123-tech added a commit to harshsomankar123-tech/kiwix-android that referenced this pull request Apr 8, 2026
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review April 8, 2026 10:01
@harshsomankar123-tech
Copy link
Copy Markdown
Contributor Author

@MohitMaliFtechiz PTAL When u have some time
Thanks!

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 60.47431% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.40%. Comparing base (59f114c) to head (0be9fb3).

Files with missing lines Patch % Lines
...kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt 57.14% 25 Missing and 5 partials ⚠️
...tion/library/online/viewmodel/CategoryViewModel.kt 17.64% 21 Missing and 7 partials ⚠️
...iwixmobile/language/viewmodel/LanguageViewModel.kt 35.00% 20 Missing and 6 partials ⚠️
...ixmobile/zimManager/OnlineLibraryServiceFactory.kt 82.92% 3 Missing and 4 partials ⚠️
...iwix/kiwixmobile/zimManager/OnlineLibraryModels.kt 81.81% 4 Missing ⚠️
.../nav/destination/library/online/viewmodel/State.kt 77.77% 0 Missing and 2 partials ⚠️
...org/kiwix/kiwixmobile/language/viewmodel/Action.kt 0.00% 1 Missing ⚠️
.../org/kiwix/kiwixmobile/language/viewmodel/State.kt 88.88% 0 Missing and 1 partial ⚠️
...nav/destination/library/online/viewmodel/Action.kt 50.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (60.47%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4705      +/-   ##
============================================
- Coverage     60.61%   60.40%   -0.21%     
- Complexity     1674     1679       +5     
============================================
  Files           333      335       +2     
  Lines         16020    16112      +92     
  Branches       2224     2237      +13     
============================================
+ Hits           9711     9733      +22     
- Misses         4834     4911      +77     
+ Partials       1475     1468       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple language and category doesn't support

2 participants