-
Notifications
You must be signed in to change notification settings - Fork 233
Take screen density into account when requesting thumbnails #1262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take screen density into account when requesting thumbnails #1262
Conversation
Otherwise, we could be asking for images with N size while we needed images for N@2x or N@3x size i.e.
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #1262 +/- ##
===========================================
- Coverage 57.65% 57.64% -0.02%
===========================================
Files 1081 1081
Lines 28041 28046 +5
Branches 5777 5777
===========================================
Hits 16167 16167
- Misses 9350 9355 +5
Partials 2524 2524
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking at this.
Don't you think the fix should be located at the call site?
For instance here: https://github.com/vector-im/element-x-android/blob/develop/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/media/AvatatarDataExt.kt#L26
We should pass a pixel size instead of a DP size. Maybe more complicated though...
Yes, that was my first idea, but to add it there we'd either have to make that function Placing this calculation in the fetcher seemed like the best compromise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for explanation!
add(CoilMediaFetcher.AvatarFactory(matrixClient)) | ||
add(CoilMediaFetcher.MediaRequestDataFactory(matrixClient)) | ||
add(CoilMediaFetcher.AvatarFactory(context, matrixClient)) | ||
add(CoilMediaFetcher.MediaRequestDataFactory(context, matrixClient)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but instead of passing the whole context
, can we just pass the screen density here?
Not sure that this can change over time, but maybe (with battery saver mode which simulate low density screen).
Or maybe just context.resources.displayMetrics
.
I am definitely thinking out loud ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm wondering about what would happen if we passed it here and then changed the settings for display element scaling in the OS. Maybe we should pass a lambda or a wrapper DensityProvider
class that hides the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in e7e41b0.
Kudos, SonarCloud Quality Gate passed!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks!
Type of change
Content
Have
CoilMediaFetcher
calculate the right size to ask for thumbnails using the screen density.Motivation and context
Fixes issues seen with blurry avatars on some homeservers.
Screenshots / GIFs
Tests
element.io
.They should look a lot shaper.
Tested devices
Checklist