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

Fixed: Downloads were not automatically starting showing progress when reopening the app(If downloads paused due to any network error). #4130

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Dec 10, 2024

Fixes #4106

  • Reenabled the DownloadManager's notification, and configured it to show the ZIM file title instead of filePath.
  • Removed the DownloadMonitorService foreground service from the project since now the notification is handled by the DownloadManager which handles it in its own thread. So we don't need to track progress when the app is closed.
  • Downloads paused due to network errors like "Waiting to Retry" are now resumed automatically when the network becomes available.
  • For downloads configured to only proceed on Wi-Fi, the application will resume progress when a Wi-Fi connection is re-established. Similarly, downloads queued for mobile networks will resume when the mobile network reconnects.
  • Fixed: IllegalStateException while setting the toolbar in SearchFragment which I accidentally saw while navigating very frequently to other screens.
  • Improved handling of scenarios where download progress was interrupted due to network errors (e.g., network fluctuations). The application now correctly retrieves download progress from the DownloadManager and, if necessary, automatically resumes paused downloads without requiring user intervention.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft December 10, 2024 11:30
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 77.89855% with 61 lines in your changes missing coverage. Please review.

Project coverage is 57.59%. Comparing base (cae22c8) to head (a1bbd1e).

Files with missing lines Patch % Lines
...wnloader/downloadManager/DownloadManagerMonitor.kt 80.00% 39 Missing and 10 partials ⚠️
...e/nav/destination/library/OnlineLibraryFragment.kt 0.00% 2 Missing and 1 partial ⚠️
...g/kiwix/kiwixmobile/core/data/KiwixRoomDatabase.kt 70.00% 3 Missing ⚠️
...loader/downloadManager/DownloadManagerRequester.kt 40.00% 3 Missing ⚠️
...rg/kiwix/kiwixmobile/core/search/SearchFragment.kt 0.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4130      +/-   ##
============================================
- Coverage     58.10%   57.59%   -0.52%     
+ Complexity     1554     1489      -65     
============================================
  Files           316      313       -3     
  Lines         13543    13306     -237     
  Branches       1727     1704      -23     
============================================
- Hits           7869     7663     -206     
+ Misses         4542     4523      -19     
+ Partials       1132     1120      -12     

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

@MohitMaliFtechiz MohitMaliFtechiz force-pushed the Issue#4106 branch 4 times, most recently from 6bd519a to ec480ff Compare December 13, 2024 11:46
…when reopening the app.

* Previously, if a download was stopped due to a network error and the Download Manager was waiting to retry, we were not receiving updates from the Download Manager. As a result, the download progress was not being displayed when the app was reopened.
* Improved the service start mechanism: If the application is in the background, we now avoid starting the service because foreground services cannot be started when the application is not in the foreground.
…agment` which i accidentally faced while navigating very frequently to other screens.
…o network errors (especially during network fluctuations), as the Download Manager will retry after some time once the connection is restored.
…d due to network errors (e.g., network fluctuations). The application now correctly retrieves download progress from the DownloadManager and, if necessary, automatically resumes paused downloads without requiring user intervention.

* Downloads paused due to network errors like "Waiting to Retry" are now resumed automatically when the network becomes available.
* For downloads configured to only proceed on Wi-Fi, the application will resume progress when a Wi-Fi connection is re-established. Similarly, downloads queued for mobile networks will resume when the mobile network reconnects.
* After implementing the previous approach to track download progress during network fluctuations, a new issue occurred. Sometimes, when the user pauses a download, it resumes immediately without any user interaction. To address this, we introduced a new field to track the paused status, distinguishing whether the pause was initiated by the user or caused by the DownloadManager due to network fluctuations.
…even when they were paused due to no internet connection. We have added a check before pausing or resuming the download. If there is no internet connection, we now display the same "No Internet connection" snackbar message that is shown when attempting to download a book without an internet connection.
* Removed the foreground service from application since now download manager handles the notification so we don't need the foreground service.
* Removed the all code related to notification management.
* Removed the unnecessary query to download manager for previous downloads. Now we are only making request to active downloads which are in our download DAO.
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.

Download stops when the app is backgrounded
2 participants