Skip to content
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

fixed placeholders load drawable resources with wrong context #4842

Merged
merged 1 commit into from
Oct 12, 2022
Merged

fixed placeholders load drawable resources with wrong context #4842

merged 1 commit into from
Oct 12, 2022

Conversation

shijiayao-main
Copy link

…t mode

Description

issues #3778 #3751

fix unable to find night resources when using night mode

Motivation and Context

when using 'AppCompatDelegate.seDefaultNightMode' change theme mode, glide will not use the right resources.

in ContextThemeWrapper if mOverrideConfiguration is null it will get resource by 'mBase.getResources()', in 'DrawableDecoderCompat' mBase is applicationContext, should use 'applyOverrideConfiguration' to get resource from current theme.

ResourcesCompat.getDrawable() resource should use 'theme.getResources' rather than 'context.getResources' because context is applicationContext

@google-cla
Copy link

google-cla bot commented Jul 20, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Haoxiqiang
Copy link

@sjudd this commit is necessary for us. would you release a version?

@sjudd sjudd added the import-ready Indicates the PR is ready to be imported to Google. label Jul 24, 2022
@kanelbulle
Copy link
Collaborator

Thank you for the fix! Would you be willing to add a test case for this?

@shijiayao-main shijiayao-main changed the title fixed bug where it was unable to find night resources when using nigh… fixed placeholders load drawable resources with wrong context Aug 19, 2022
@osfunapps
Copy link

What about merging this branch with the main? The whole library is unusable for us using the dark mode

sjudd added a commit to sjudd/glide that referenced this pull request Oct 11, 2022
Previously we'd use the application Context, which would not use the
Activity theme. That would in turn mean we would not customize Drawables
for light / dark mode.

I've also added a bunch of emulator tests. It turns out these changes
aren't quite sufficient, even with bumptech#4842, to get asynchronous loading
of resources passed to load() working. I've left a pretty extensive
comment in the new test along with ignored tests about what additional
changes we'd need.

Progress towards bumptech#3751.
sjudd added a commit to sjudd/glide that referenced this pull request Oct 11, 2022
Previously we'd use the application Context, which would not use the
Activity theme. That would in turn mean we would not customize Drawables
for light / dark mode.

I've also added a bunch of emulator tests. It turns out these changes
aren't quite sufficient, even with bumptech#4842, to get asynchronous loading
of resources passed to load() working. I've left a pretty extensive
comment in the new test along with ignored tests about what additional
changes we'd need.

Progress towards bumptech#3751.
@copybara-service copybara-service bot merged commit 08c9f72 into bumptech:master Oct 12, 2022
sjudd added a commit to sjudd/glide that referenced this pull request Oct 21, 2022
Previously we'd use the application Context, which would not use the
Activity theme. That would in turn mean we would not customize Drawables
for light / dark mode.

I've also added a bunch of emulator tests. It turns out these changes
aren't quite sufficient, even with bumptech#4842, to get asynchronous loading
of resources passed to load() working. I've left a pretty extensive
comment in the new test along with ignored tests about what additional
changes we'd need.

Progress towards bumptech#3751.
@shijiayao-main shijiayao-main deleted the fix/fix_resource_error_in_night_mode branch December 5, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import-ready Indicates the PR is ready to be imported to Google.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants