Skip to content

feat(account): add support for PNG avatars#10506

Merged
wmontwe merged 1 commit intothunderbird:mainfrom
McBaumwolle:main
Feb 12, 2026
Merged

feat(account): add support for PNG avatars#10506
wmontwe merged 1 commit intothunderbird:mainfrom
McBaumwolle:main

Conversation

@McBaumwolle
Copy link

@McBaumwolle McBaumwolle commented Feb 9, 2026

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.

@wmontwe
Copy link
Member

wmontwe commented Feb 11, 2026

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.

Thanks, sadly all the fancy image selection supports either a single MIME type or applies no limit. I had a look at the PickVisualMedia to check if we could patch it, but it looks like a major effort.

There are some conflicts with a fix I had to do for our beta #10500.

Could you also squash the two refactor: use OpenDocument picker and support PNG mime types commits into one?

When all checks pass, this is ready to be merged.

@McBaumwolle
Copy link
Author

I'm working on this, however it's quite overwhelming as I am new to Kotlin, but it should work by noon (hopefully).

@wmontwe
Copy link
Member

wmontwe commented Feb 11, 2026

@McBaumwolle no problem, we know that this is not a simple project and if something doesn't work, I could have a look.

@McBaumwolle McBaumwolle force-pushed the main branch 2 times, most recently from 52121c0 to d6f4e35 Compare February 11, 2026 13:28
@McBaumwolle
Copy link
Author

Soo I think I got it now, and it also seems to work with your changes (#10500) and updates as it should. On my phone it also once again only allowed for .png and .jpg files. I had to adjust the test but all of them (in LocalAvatarImageDataSourceTest.kt) passed. Just to make sure I tested some local quality checks (spotless, detekt, :check) and they pass as well. Thanks!

@McBaumwolle McBaumwolle force-pushed the main branch 6 times, most recently from 569cb44 to fea5dcc Compare February 11, 2026 15:57
@McBaumwolle

This comment was marked as resolved.

@wmontwe
Copy link
Member

wmontwe commented Feb 12, 2026

I usally run ./gradlew spotlessApply detekt to check if everything is fine. spotlessApply will automatically fix most issues.

@McBaumwolle
Copy link
Author

Thank you for all your help, @wmontwe - it should all work now (and I completely forgot about the documentation)!

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.

Thanks for the effort!

@wmontwe wmontwe merged commit f7e9c42 into thunderbird:main Feb 12, 2026
13 checks passed
@thunderbird-botmobile
Copy link
Contributor

Thanks for your contribution! Your pull request has been merged and will be part of Thunderbird 17. We appreciate the time and effort you put into improving Thunderbird. If you haven’t already, you’re welcome to join our Matrix chat for contributors. It’s where we discuss development and help each other out. https://matrix.to/#/#tb-android-dev:mozilla.org
Hope to see you there! 🚀📱🐦

@thunderbird-botmobile thunderbird-botmobile bot added this to the Thunderbird 17 milestone Feb 12, 2026
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