Introduced the category filter on "Download" screen.
Fixes #4343
- Showing category in a dialog on the "Download" screen.
- Saving the selected category in shared preferences so that it will automatically be applied when the user comes back to the application, similar to the language filter.
- Fetched the category list from an online source.
- Applied the category filter while fetching the online content.
- Created
CategoryViewModelto manage UI-related data and user actions. - Implemented caching of the category list in the application to avoid unnecessary API calls.
- Created
OnlineCategoryDialogto separately handle the UI and all logic related to the category filter. - Added unit and UI test cases for this.
- Refactored
ZimManageViewModelTestto include category filter scenarios.
https://github.com/user-attachments/assets/02644996-7fe9-425a-84ec-53f252cca7c4
Codecov Report
:x: Patch coverage is 75.69620% with 96 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 58.75%. Comparing base (1da4c8a) to head (79a5d07).
Additional details and impacted files
@@ Coverage Diff @@
## main #4436 +/- ##
============================================
+ Coverage 58.42% 58.75% +0.33%
- Complexity 1455 1473 +18
============================================
Files 328 337 +9
Lines 17016 17405 +389
Branches 2101 2151 +50
============================================
+ Hits 9941 10227 +286
- Misses 5669 5730 +61
- Partials 1406 1448 +42
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
How does this filter behaves when device if offline? Where does the category list com from then? How work the caching (I wonder why you need one!)?
How does this filter behaves when device if offline? Where does the category list com from then? How work the caching (I wonder why you need one!)?
@kelson42 We have implemented the caching to store the category in sharedPreference so that the application does not need to fetch the category again and again from an online source(in a single app lifecycle).
Initially, it needs to fetch the category from an online source once, and then it will save that in shared preferences. After that, if there is no internet connection available or any error in fetching the category in the next app lifecycle, then it shows the cached category from the shared preferences. If in the next app lifecycle it fetches the category from an online source, then it saves the updated category in SharedPreferences.
We need the caching to avoid the unnecessary API calls. As it is a separate dialog screen with a viewmodel, in that viewmodel, we fetch the category, and the viewmodel keeps that category data until that screen(dialog) is dismissed. After dismissing the view model, it's clear when the screen is no longer available to free up the resource. If the user again opens this dialog for selecting a different category, then it again fetches the category, so to avoid this fetching, we need this caching. Since keeping this data on the activity level is not good.