Skip to content

Conversation

@McBaumwolle
Copy link

Description
This PR updates the account avatar logic to support both .jpg and .png file extensions. Previously, all avatars were forced to use the .jpg extension, which caused issues when someone uploaded PNGs, especially those with transparency (I tried some for my main email and did not understand why it failed at first, or rather did not show the images in the picker).

Changes:
Dynamic extension: LocalAvatarImageDataSource now detects if the source image is a PNG and saves it with the correct .png extension.

  • Smart cleanup: the delete() function now checks for and removes both .jpg and .png files for the given account. This ensures that, when a user switches from a JPEG avatar to a PNG avatar (or vice versa), the old file is deleted and does not remain orphaned.
  • Tests: updated LocalAvatarImageDataSourceTest to verify PNG support and ensure the clean-up logic works for multiple file types.

Fixes:
#10501

@McBaumwolle McBaumwolle requested a review from a team as a code owner February 9, 2026 22:13
@McBaumwolle McBaumwolle requested a review from asoucar February 9, 2026 22:13
@wmontwe wmontwe requested review from wmontwe and removed request for asoucar February 10, 2026 08:00
@wmontwe wmontwe assigned wmontwe and unassigned asoucar Feb 10, 2026
Copy link
Member

@wmontwe wmontwe left a comment

Choose a reason for hiding this comment

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

Thank your for adding support for PNG avatars!

You also need to patch the UpdateAvatarImage use case as it checks the mime type and rejects non JPEG files. Additionally I would change the imagePicker to use OpenDocument to allow you to define a list of allowed file types.

@McBaumwolle
Copy link
Author

Thanks! Maybe I completely forgot about that. It should work now with ActivityResultContracts.OpenDocument() - however, as the name suggests it now opens the document picker and not the "fancy" new image picker. In my opinion it makes no difference tho. I tested it on my Pixel again and it works as expected, and rejects (or simply filters out) anything that is not .png or .jpg. I also adjusted the test (LocalAvatarImageDataSourceTest.kt) for these.

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.

3 participants