Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing the fetch library with Android's DownloadManager. #3935

Merged
merged 41 commits into from
Aug 12, 2024
Merged

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Jul 11, 2024

Fixes #3141
Fixes #3967

  • Moved the downloading functionality to Android's Download Manager.
  • Implemented the custom notification to show the download progress with pause/resume functionality since the default notification of DownloadManager does not have the pause/resume buttons.
  • Created the room database for managing the downloads state.
  • Removed the fetch library and all the code related to fetch to make it compatible with Android 14.

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

Attention: Patch coverage is 71.23098% with 208 lines in your changes missing coverage. Please review.

Project coverage is 53.69%. Comparing base (eff8321) to head (d34dd37).

Files Patch % Lines
...wnloader/downloadManager/DownloadManagerMonitor.kt 78.43% 46 Missing and 12 partials ⚠️
...loader/downloadManager/DownloadManagerRequester.kt 32.75% 36 Missing and 3 partials ⚠️
...der/downloadManager/DownloadNotificationManager.kt 75.38% 23 Missing and 9 partials ⚠️
...wixmobile/core/downloader/downloadManager/Error.kt 50.00% 20 Missing ⚠️
...ixmobile/core/downloader/downloadManager/Status.kt 50.00% 12 Missing ⚠️
...er/DownloadNotificationActionsBroadcastReceiver.kt 33.33% 8 Missing ⚠️
.../org/kiwix/kiwixmobile/core/dao/DownloadRoomDao.kt 81.08% 0 Missing and 7 partials ⚠️
...e/nav/destination/library/OnlineLibraryFragment.kt 14.28% 6 Missing ⚠️
...imManager/libraryView/adapter/LibraryViewHolder.kt 66.66% 2 Missing and 3 partials ⚠️
...x/kiwixmobile/core/extensions/ContextExtensions.kt 44.44% 4 Missing and 1 partial ⚠️
... and 7 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3935      +/-   ##
============================================
+ Coverage     53.09%   53.69%   +0.59%     
- Complexity     1417     1482      +65     
============================================
  Files           304      309       +5     
  Lines         11908    12271     +363     
  Branches       1588     1617      +29     
============================================
+ Hits           6323     6589     +266     
- Misses         4554     4628      +74     
- Partials       1031     1054      +23     

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

@MohitMaliFtechiz MohitMaliFtechiz force-pushed the Fixes#3141 branch 2 times, most recently from dad5762 to 4ac5ece Compare August 8, 2024 11:56
@kelson42
Copy link
Collaborator

kelson42 commented Aug 11, 2024

@MohitMaliFtechiz Whatbis the status here is this ready to merge/review? Don' forget to update the README.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review August 12, 2024 09:18
@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42 Yes this PR is ready for review, I have updated the README file as well.

@kelson42 kelson42 self-requested a review August 12, 2024 11:34
MohitMaliDeveloper and others added 25 commits August 12, 2024 17:14
* Improved the updating status functionality.
* Cancelling the notification if any running and download is completed.
* Fixed TestModelFunctions build failure.
…ecause two zim files can have the same title
* Improved variable naming and placed them in appropriate locations.
…no downloads are ongoing.

* This change ensures that the observable is only active when necessary, reducing unnecessary resource usage and avoiding redundant requests to the DownloadManager.
* Fixed the Downloading for Authentication URL.
…ssfully downloading.

* Improved the "DownloadTest".
…wnloads when the download is in a Queued state.
…aused state, as the pause state could occur if DownloadManager is waiting for WiFi.

* Fixed the user behavior when attempting to download the ZIM file only on WiFi, and added a proper message explaining why the download is paused.
* For Android 11 and above, we now download ZIM files to the app-specific directory because the download manager does not allow downloads to custom paths. Therefore, ZIM files are now downloaded inside the app-specific directory for these versions.
* Removed the folder selection dialog from the application for selecting the SD card in non-Play Store variants on Android 11 and Android 12.
* For Android 10 and below, ZIM files are now downloading to the public directory on the SD card. This ensures that the files are not lost when the application is uninstalled, as they are stored in a public directory similar to internal storage on these versions.
* Also improved the showing pause reason on download screen when downloadManager is paused due to "PAUSED_WAITING_TO_RETRY" error so that user can know about the downloading state.
…load failed. In such cases, the pause/resume functionality does not work, so we have disabled the button to prevent unexpected behavior.
* When there is no available connection that the user started the download with, the pause/resume button is disabled to prevent attempts to resume or pause the download, which would not work in this state.
* If the user attempts to resume the download but it does not resume due to some issue, the code will automatically try to resume the download. This ensures a smooth user experience.
*  Proper pause reasons are displayed to the user, keeping them informed about the current state of the download.
* If a download fails for any reason, the pause/resume button is disabled. At this point, the pause/resume functionality is unnecessary and would not work, so the button is disabled to avoid confusion.
* To ensure clarity and understanding, we have added necessary comments on the method and conditions.
* Also, now we are not using fetch library anymore so we have removed this from our credits files.
* Removed the unused code from detekt_baseline.xml file.
@kelson42 kelson42 merged commit 78e6349 into main Aug 12, 2024
10 checks passed
@kelson42 kelson42 deleted the Fixes#3141 branch August 12, 2024 16:08
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.

"Pause", not "pause" Alternative to Fetch library (not maintain repo on github)
4 participants