Skip to content

Add configurable download location via Storage Access Framework#8844

Open
sahilpatel2521 wants to merge 2 commits into
duckduckgo:developfrom
sahilpatel2521:feature/add-custom-download-location
Open

Add configurable download location via Storage Access Framework#8844
sahilpatel2521 wants to merge 2 commits into
duckduckgo:developfrom
sahilpatel2521:feature/add-custom-download-location

Conversation

@sahilpatel2521

@sahilpatel2521 sahilpatel2521 commented Jun 11, 2026

Copy link
Copy Markdown

Task/Issue URL: #8832

Description

Add configurable download location via Storage Access Framework.

  • Let users pick a custom download folder from Settings while preserving default Downloads behavior for existing users. Closes [Feature request] Include a setting that lets the user choose where they want to point their Downloads folder to #8832.
  • Declare DownloadLocationSettingsActivity in AndroidManifest.xml.
  • Reuse downloadsLocationSettingTitle for activity label to fix missing resource error and inherit translations.
  • Replace nonexistent OneLineSwitchItem with OneLineListItem using showSwitch in layout.
  • Pass correct buildTreeDocumentUri to folder picker initial URI.
  • Add fallback download location snackbar messaging in context/webview fragments.

Steps to test this PR

Download Settings Navigation

  • Open settings and verify that the Downloads option is visible under "Other Settings" (it was previously missing).
  • Tap Downloads and verify that the DownloadLocationSettingsActivity launches successfully without throwing an ActivityNotFoundException.

Custom Folder Selection (Storage Access Framework)

  • On the Downloads screen, tap Change Folder.
  • Verify that the system folder picker opens and starts inside the primary Download folder.
  • Create or select a custom folder (e.g. Sahil) and authorize access.
  • Verify that the selected folder name is displayed under the Selected Folder section.

Downloading Files

  • Default Location: Reset or keep the setting on "Default". Download a file from the browser and verify it saves to the default public Download folder.
  • Custom Location: Set a custom folder. Download a file and verify it is successfully saved to the custom folder.
  • Ask Every Time: Toggle Ask Every Time on. Attempt to download a file and verify the system asks for destination folder each time.

Fallback Verification (Folder Revoked/Unavailable)

  • Select a custom folder, then revoke its storage permission or delete the folder.
  • Download a file and verify that the fallback snackbar appears saying: "Selected download folder is unavailable. Downloads will be saved to the default Downloads folder."
  • Verify that the file is successfully downloaded and saved in the default Download folder.

Automated Tests

  • Run the tests:
    ./gradlew :downloads:downloads-impl:testDebugUnitTest
    

UI Changes

Before After
before change download_location_change change_download_location

Note

Medium Risk
Changes the core browser download write path and persisted storage permissions; fallback behavior limits data loss risk but regressions could affect where files land or whether open/share works.

Overview
Adds configurable download folders via Storage Access Framework: a new Downloads entry under Other Settings opens DownloadLocationSettingsActivity, where users can pick a custom tree URI (persisted in DataStore) or keep the default public Downloads directory.

The download stack is refactored around DownloadDestination and DownloadDestinationResolver: AndroidFileDownloader resolves the destination before enqueueing work, serializes it through FileDownloadWorker, and DownloadFileWriter writes either to disk or SAF content:// URIs. If the chosen folder is no longer accessible, downloads fall back to default and UI surfaces ShowDownloadLocationFallbackMessage snackbars (browser, Duck Chat, subscriptions).

DownloadFileAccessor and path-based openFileAtPath / shareFileAtPath replace direct File usage in the downloads list and notifications so finished items work for both filesystem paths and content URIs. A Maestro releaseTest flow covers navigating to download location settings.

Reviewed by Cursor Bugbot for commit d66b10a. Bugbot is set up for automated code reviews on this repo. Configure here.

@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from 35c9795 to ca74470 Compare June 11, 2026 07:13
Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from ca74470 to b9859db Compare June 11, 2026 07:17
@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from b9859db to 67a0a9b Compare June 11, 2026 09:23
@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from 67a0a9b to 01535d7 Compare June 11, 2026 09:30
@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from 01535d7 to 98ed8c7 Compare June 11, 2026 09:41
- Let users pick a custom download folder from Settings while preserving default Downloads behavior for existing users
- Declare DownloadLocationSettingsActivity in AndroidManifest.xml
- Reuse downloadsLocationSettingTitle for activity label
- Replace nonexistent OneLineSwitchItem with OneLineListItem using showSwitch in layout
- Pass correct buildTreeDocumentUri to folder picker initial URI
- Add fallback download location snackbar messaging
- Closes duckduckgo#8832
@sahilpatel2521 sahilpatel2521 force-pushed the feature/add-custom-download-location branch from 98ed8c7 to fc3c4e8 Compare June 11, 2026 09:53
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.

[Feature request] Include a setting that lets the user choose where they want to point their Downloads folder to

1 participant