Skip to content

Downloads: progress, cancel, retry, open and share - #16

Merged
GothwadTech merged 1 commit into
mainfrom
feat/downloads-management
Nov 28, 2026
Merged

GothwadTech merged 1 commit into
mainfrom
feat/downloads-management

Conversation

@GothwadTech

@GothwadTech GothwadTech commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Downloads was a list you could only delete from. It is now managed end to end.

What changed

Before Now
dm.enqueue(request) id thrown away id stored in DownloadEntity.managerId
Status hard-coded "Completed" at enqueue time "Downloading" until the manager reports success/failure
No progress anywhere watcher polls DownloadManager every 1.5s → % in the row + LinearProgressIndicator
Nothing to do about a stuck download Cancel removes the job and the row
A failed download stayed broken Retry re-enqueues the original URL
Tap opened the source page Tap opens the file once it is complete
"Share" sent the URL as text Share sends the real file as content:// via FileProvider

Notes

  • Room goes to version 2 with a proper MIGRATION_1_2 (ALTER TABLE downloads ADD COLUMN managerId), so existing bookmarks, history and downloads survive the update. fallbackToDestructiveMigration stays only as a last-resort guard.
  • res/xml/file_paths.xml exposes exactly Download/, the app's own download folder, saved pages and cache — nothing else.
  • The watcher only queries while a row is Downloading, so an idle app does no work.
  • A web archive saved from the page menu has no DownloadManager job (managerId = -1), so it records straight as completed.

Checks

The PR's own Quality Gate & Tests run compiles, unit-tests and lints it.

Summary by CodeRabbit

  • New Features
    • Download details now show live progress and clearly identify failed downloads.
    • Open completed files, cancel active downloads, and retry failed downloads from the downloads list.
    • Share downloaded files directly; if a file isn’t available, share its source link instead.

The Downloads screen could only list and delete. Now it manages the download.

- DownloadEntity keeps the DownloadManager id (Room v2 + a real 1->2 migration,
  no destructive drop), and a watcher polls it every 1.5s while anything is
  downloading
- Downloads show a percentage and a progress bar, and flip to Completed/Failed on
  their own with a snackbar
- Cancel removes the DownloadManager job and the row; Retry re-enqueues the
  original URL; tapping a finished row opens the file
- FileProvider (res/xml/file_paths.xml) so Open and Share pass a content:// URI
  for the real file instead of the URL text
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Changes: Download lifecycle and file actions

Layer / File(s) Summary
Persist download manager IDs
app/src/main/java/com/bansify/browser/data/BrowserEntities.kt, app/src/main/java/com/bansify/browser/data/BrowserDatabase.kt, app/src/main/java/com/bansify/browser/data/BrowserDao.kt, app/src/main/java/com/bansify/browser/data/BrowserRepository.kt
DownloadEntity stores a manager ID. The database migrates existing rows with -1 as the default. DAO and repository methods retrieve downloads, list active downloads, and update manager IDs and status.
Capture and track downloads
app/src/main/java/com/bansify/browser/browser/WebViewPool.kt, app/src/main/java/com/bansify/browser/viewmodel/BrowserViewModel.kt, app/src/main/java/com/bansify/browser/ui/BrowserApp.kt
Download callbacks pass manager IDs to the view model. The view model records status, polls progress and terminal results, and supports cancellation and retry.
Connect file actions to the downloads screen
app/src/main/AndroidManifest.xml, app/src/main/res/xml/file_paths.xml, app/src/main/java/com/bansify/browser/viewmodel/BrowserViewModel.kt, app/src/main/java/com/bansify/browser/ui/BrowserApp.kt, app/src/main/java/com/bansify/browser/ui/screens/DownloadsScreen.kt
The downloads screen displays progress and status and provides file and download actions. File opening and sharing use configured FileProvider paths; sharing falls back to the download URL when a file is unavailable.

Change: Feature

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@GothwadTech
GothwadTech merged commit abe6d43 into main Nov 28, 2026
4 of 5 checks passed
@GothwadTech
GothwadTech deleted the feat/downloads-management branch November 28, 2026 11:18
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.

1 participant