Skip to content

feat: Make all file access permission optional on full builds - #21046

Open
Fandroid745 wants to merge 1 commit into
ankidroid:mainfrom
Fandroid745:feat/storage-permission-optional
Open

feat: Make all file access permission optional on full builds#21046
Fandroid745 wants to merge 1 commit into
ankidroid:mainfrom
Fandroid745:feat/storage-permission-optional

Conversation

@Fandroid745

@Fandroid745 Fandroid745 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Gemini 3.1 Pro - Research and Tests

Purpose / Description

AnkiDroid forces the users to grant the "All files access" permission on full builds(fdroid/github) with no way to opt out. The users who sync via AnkiWeb or manage their have no need to grant this permission.

Fixes

Approach

  1. Added a skip button on the permisssion screen (PermissionStartingAt30Fragment).
  2. When tapped, a dialog appears the tradeoff that the collection will be stored in app-private storage
    /storage/emulated/0/Android/data/com.ichi2.anki.debug/files/AnkiDroid and deleted on uninstall.
  3. If the user confirms Prefs.UsePrivateStorage is set to true and PREF_COLLECTION_PATH is written to the the app private directory.
  4. The selectAnkidroidFolder returns the AppPrivateFolder directly, matching the Play Store build behaviour

How Has This Been Tested?

Tested on Android 15 device (with the build variants fullDebug and fullRelease)

Screenshots

Skip button to skip all files permission

photo_2026-05-15_10-33-52

Dialog explaning the trade-offs
photo_2026-05-15_10-33-50 (2)

The app private storage being used
photo_2026-05-15_10-33-51

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@BrayanDSO BrayanDSO left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a skip button, simply don't disable the Continue button if the permission hasn't been allowed. If they tap the button, the dialog should be shown

Comment on lines +273 to +275
<string name="btn_skip_permission">Skip</string>
<string name="private_storage_warning_title"> Limited Storage access</string>
<string name="private_storage_warning">Without this permission, Your Ankidroid collection will be stored in app\'s private storage and will be permanently deleted if you uninstall Ankidroid.</string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file isn't translated, so those strings shouldn't be here

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels May 15, 2026
@david-allison

Copy link
Copy Markdown
Member

The title shouldn't include "needs"

AnkiDroid works better with these permissions

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of our really badly wanted fixes, thank you!!!!!!!!!!!!!

Initially this looks good to me. This will want a lower priority follow up issue to fix the AnkiDroid directory preference. Please don't fix it in this PR, as that dialog is being rewritten

  • change the button text to "skip", don't add another button
  • Fix the title, see my other comment
  • Use "app private", not "private"

<string name="use_private_storage_key">usePrivatestorage</string>
<string name="btn_skip_permission">Skip</string>
<string name="private_storage_warning_title"> Limited Storage access</string>
<string name="private_storage_warning">Without this permission, Your Ankidroid collection will be stored in app\'s private storage and will be permanently deleted if you uninstall Ankidroid.</string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnkiDroid


I don't like this warning, the UI should be a selection, rather than showing a user a scary dialog during the onboarding process

I'd block this if it weren't F-Droid only - users there are more understanding of privacy

Add an issue and a TODO to rethink the UI

@Fandroid745 Fandroid745 May 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnkiDroid

I don't like this warning, the UI should be a selection, rather than showing a user a scary dialog during the onboarding process

I'd block this if it weren't F-Droid only - users there are more understanding of privacy

Add an issue and a TODO to rethink the UI

Will do!
I had created that dialog as it was one of the comments on the issue


val externalFilesDir =
requireContext().getExternalFilesDir(null) ?: requireContext().filesDir
val privateDir = File(externalFilesDir, "AnkiDroid").apply { mkdirs() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: mkdirs() return value isn't checked. If it fails (disk full/corrupted), the pref gets set to a non existent path.

@github-actions

Copy link
Copy Markdown
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch 2 times, most recently from 51b427b to b73806c Compare May 16, 2026 13:50
@Fandroid745

Copy link
Copy Markdown
Contributor Author

I have addressed the review comments now,
could you please review

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests, this is a vital path to get correct

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label Jun 5, 2026
@github-actions github-actions Bot closed this Jun 12, 2026
@Fandroid745

Copy link
Copy Markdown
Contributor Author

@david-allison could you reopen this

@david-allison david-allison reopened this Jun 13, 2026
@david-allison

Copy link
Copy Markdown
Member

Done

@github-actions github-actions Bot removed the Stale label Jun 13, 2026
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch from b73806c to be365c4 Compare June 15, 2026 07:17
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Snapshot diff report vs main. Open screenshot-diff for diffs.

  • AllActivitiesScreenshotTest: 2 changes
All 2 changed screenshots

AllActivitiesScreenshotTest

  • PermissionsActivity_compare.png
  • PermissionsActivity_edgeToEdge_compare.png

@github-actions

Copy link
Copy Markdown
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label Jul 22, 2026
@Fandroid745
Fandroid745 marked this pull request as draft July 26, 2026 03:52
@github-actions github-actions Bot removed the Stale label Jul 26, 2026
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch from c9cc684 to 36ff6ee Compare July 27, 2026 14:39
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch 4 times, most recently from 1e44f97 to 1f295f1 Compare July 30, 2026 08:20
@Fandroid745
Fandroid745 marked this pull request as ready for review July 30, 2026 16:49
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch from 1f295f1 to 176087a Compare August 2, 2026 11:33
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch 2 times, most recently from 1aa77b8 to 37210be Compare August 13, 2026 15:42
@Fandroid745
Fandroid745 marked this pull request as draft August 13, 2026 15:53
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch 2 times, most recently from 9b6aadb to 97026bb Compare August 13, 2026 17:11
@Fandroid745
Fandroid745 force-pushed the feat/storage-permission-optional branch from 97026bb to d3727bd Compare August 14, 2026 10:19
@Fandroid745
Fandroid745 marked this pull request as ready for review August 14, 2026 11:13
@Fandroid745

Copy link
Copy Markdown
Contributor Author

@david-allison could you review this, I have handled the case where the user has given full storage access but revokes permission now

@david-allison

david-allison commented Aug 15, 2026

Copy link
Copy Markdown
Member

Bug: on a new install, "Skip" loops back to the permission screen (until they grant the permission)

Could you add a regression test for this?

This PR should be using the StorageDecision mechanism (which is now live), rather than directly modifying the collection path. We previously did not have a concept of "path chosen by the user", and StorageDecision was designed for this.


Sorry for the back & forth here, StorageDecision took time to merge, and I've had limited AnkiDroid time

Feel free to delegate a few PRs to me here to get this over the line sooner. This is our most requested feature and I've now got capacity to see it through:

https://github.com/ankidroid/Anki-Android/issues?q=is%3Aissue%20state%3Aopen%20sort%3Areactions-%2B1-desc

@Fandroid745

Copy link
Copy Markdown
Contributor Author

Thanks for the help! I have limited time currently, could you get this over the line.

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this from my review queue. Blocked on

@david-allison david-allison added the Blocked by dependency Currently blocked by some other dependent / related change label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked by dependency Currently blocked by some other dependent / related change Has Conflicts Needs Author Reply Waiting for a reply from the original author Strings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't force full (F-Droid/GitHub) releases users to grant the All files access permission

4 participants