Skip to content

feat: update system favorites on Android 11+ when favoriting media#872

Open
terofeev wants to merge 9 commits intoFossifyOrg:mainfrom
terofeev:update-favorites-using-system-api
Open

feat: update system favorites on Android 11+ when favoriting media#872
terofeev wants to merge 9 commits intoFossifyOrg:mainfrom
terofeev:update-favorites-using-system-api

Conversation

@terofeev
Copy link
Contributor

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  • On Android 11+, favorited media is now added to the system's favorites collection, making it available in other apps that use the standard media picker.

Tests performed

  • Tested on Nothing Phone (1) Android 15

Before & after preview

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • All checks are passing.

@terofeev terofeev requested a review from naveensingh as a code owner January 17, 2026 16:52
@naveensingh naveensingh changed the title Update system favorites collection on Android 11+ when favoriting media feat: update system favorites on Android 11+ when favoriting media Jan 30, 2026
Copy link
Member

@naveensingh naveensingh left a comment

Choose a reason for hiding this comment

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

I found two issues:

  • The app shows Unknown error occurred when removing items from favorites without "All files access".
  • The app shows Unknown error occurred when removing/adding items to/from favorites without "All files access" and "Media management" permissions.

We should fallback to MediaStore.createFavoriteRequest() and friends when only limited permissions are available.

@naveensingh naveensingh added the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Feb 3, 2026
@terofeev
Copy link
Contributor Author

terofeev commented Feb 4, 2026

@naveensingh applied suggested changes, thank you! Also fixed case without "All files access".

Could you help me with the case without "Media management" permissions? I see a dialog stating that Gallery needs full access to display all your photos and videos and that the app can't be used without it.

@terofeev terofeev requested a review from naveensingh February 4, 2026 18:28
@naveensingh
Copy link
Member

Could you help me with the case without "Media management" permissions? I see a dialog stating that Gallery needs full access to display all your photos and videos and that the app can't be used without it.

Sorry, my bad. I thought the error happened when I skipped granting both "Media only" and "All files access" by clicking outside the permission dialog, but no, it's happening with SVG files regardless of permission status. I can provide a stacktrace later.

PS: Detekt check is failing :)

@terofeev terofeev marked this pull request as draft February 5, 2026 19:04
@terofeev terofeev marked this pull request as ready for review February 6, 2026 18:55
@naveensingh naveensingh removed the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Feb 7, 2026
"image/gif",
"image/bmp",
"image/x-ms-bmp"
)
Copy link
Member

Choose a reason for hiding this comment

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

What about other formats such as avif, JXL, etc? Are those failing too?

// Update media in favorites collection for Android 11+ (API level 30)
if (isRPlus()) {
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID)
if (isMedia(contentResolver, uri)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not reuse helpers from the commons lib here?

Suggested change
if (isMedia(contentResolver, uri)) {
if (path.isImageFast() && !path.isSvg()) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Using path.isImageFast() would throw exceptions for AVIF, JXL, etc. (fails on my Android 15 test device).

Given Android's scoped storage restrictions, when users grant "media only" access they only see specific MIME types - which is exactly what we should check for in the isMedia function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested many formats but only image/jpeg consistently works with the media picker. Propose reducing supportedImageTypes to just image/jpeg. What do you think?

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.

Use system API for favorites

2 participants