feat: Show all selected languages and categories in online library#4705
feat: Show all selected languages and categories in online library#4705harshsomankar123-tech wants to merge 11 commits intokiwix:mainfrom
Conversation
fbb5f14 to
e91837d
Compare
MohitMaliFtechiz
left a comment
There was a problem hiding this comment.
@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( |
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Do not remove the comments.
| Column( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| // setting bottom padding to zero to avoid accounting for Bottom bar |
There was a problem hiding this comment.
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 |
| import org.kiwix.kiwixmobile.core.ui.components.ONE | ||
|
|
||
| object OnlineLibraryHeaderHelper { | ||
| fun getOnlineLibrarySectionTitle( |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
@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() |
There was a problem hiding this comment.
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.
1eb04bf to
55e5046
Compare
|
@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
left a comment
There was a problem hiding this comment.
@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.
| import javax.inject.Inject | ||
|
|
||
| class LanguageViewModel @Inject constructor( | ||
| open class LanguageViewModel @Inject constructor( |
There was a problem hiding this comment.
We should keep this as a final class. We should not make it open just for setting isUnitTestCase.
There was a problem hiding this comment.
There is already a function for this.
| is Filter -> filter(action, currentState) | ||
| is Select -> select(action, currentState) | ||
| Save -> saveAction(currentState) | ||
| ClearAll -> clearAll(currentState) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Same for this class.
| is Filter -> filter(action, currentState) | ||
| is Select -> select(action, currentState) | ||
| Action.Save -> saveAction(currentState) | ||
| Action.ClearAll -> clearAll(currentState) |
There was a problem hiding this comment.
Same for these ones? Cancel, SelectAll, and ClearAll.
| title = stringResource(R.string.select_category), | ||
| navigationIcon = navigationIcon | ||
| navigationIcon = navigationIcon, | ||
| actionMenuItems = listOf( |
There was a problem hiding this comment.
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}" |
| import org.kiwix.kiwixmobile.core.entity.LibkiwixBook | ||
| import org.kiwix.kiwixmobile.zimManager.libraryView.LibraryListItem | ||
|
|
||
| data class OnlineLibraryRequest( |
There was a problem hiding this comment.
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.
9ddc7bf to
b8750fc
Compare
694e7c5 to
f8f1c71
Compare
f8f1c71 to
6fc36f1
Compare
|
@MohitMaliFtechiz PTAL |
ecfd8b6 to
861c2bd
Compare
0bd4be3 to
3c44629
Compare
3c44629 to
61ad15b
Compare
61ad15b to
f71fd75
Compare
edf3792 to
a9c1927
Compare
a9c1927 to
f58ad83
Compare
|
@MohitMaliFtechiz PTAL When u have some time |
Codecov Report❌ Patch coverage is ❌ 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. 🚀 New features to boost your workflow:
|
f58ad83 to
0be9fb3
Compare
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:
Test & CI Fixes:
Screenshots
Screen.Recording.2026-02-19.at.16.21.34.mov