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 8 commits into
base: main
Choose a base branch
from

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Dec 10, 2024

Fixes #4106

  • Fixed: Downloads were not automatically starting or showing progress 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.
  • Fixed: IllegalStateException while setting the toolbar in SearchFragment which I accidentally saw while navigating very frequently to other screens.
  • Keeping the foreground service active when downloads are paused due to network errors (especially during network fluctuations), as the Download Manager will retry after some time once the connection is restored.
  • 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.
  • 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.

@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 50.56180% with 44 lines in your changes missing coverage. Please review.

Project coverage is 58.35%. Comparing base (5990291) to head (6bd519a).

Files with missing lines Patch % Lines
...wnloader/downloadManager/DownloadMonitorService.kt 52.50% 4 Missing and 15 partials ⚠️
...wnloader/downloadManager/DownloadManagerMonitor.kt 36.00% 13 Missing and 3 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 ⚠️
...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.44%   58.35%   -0.10%     
- Complexity     1561     1568       +7     
============================================
  Files           316      316              
  Lines         13541    13597      +56     
  Branches       1727     1744      +17     
============================================
+ Hits           7914     7934      +20     
- Misses         4490     4511      +21     
- Partials       1137     1152      +15     

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

@MohitMaliFtechiz MohitMaliFtechiz force-pushed the Issue#4106 branch 2 times, most recently from 4859313 to e8f0620 Compare December 11, 2024 11:33
…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.
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