fix: preserve hCaptcha logo when using vector drawable support#245
Open
e271828- wants to merge 1 commit intofix/233-eliminate-png-density-variantsfrom
Open
fix: preserve hCaptcha logo when using vector drawable support#245e271828- wants to merge 1 commit intofix/233-eliminate-png-density-variantsfrom
e271828- wants to merge 1 commit intofix/233-eliminate-png-density-variantsfrom
Conversation
The PNG density-variant optimization switched the loading logo from android:src to app:srcCompat and enabled vectorDrawables.useSupportLibrary. That removed the generated PNG fallbacks, but it also introduced a runtime regression in the current DialogFragment code path. HCaptchaDialogFragment inflates hcaptcha_fragment.xml through the plain DialogFragment/android.app.Dialog inflater path. In that path, the logo view remained a framework ImageView, which does not consume the app:srcCompat attribute. The result was that the loading logo drawable was left unset at runtime. Fix this by changing the XML tag to androidx.appcompat.widget.AppCompatImageView while keeping app:srcCompat. This preserves the size reduction from using vector support while making drawable inflation work correctly on the existing production path without changing dialog construction or theming. Add a Robolectric regression test that inflates the layout through the same plain Dialog context used by the fragment and verifies that the logo view is an AppCompatImageView with a non-null drawable.
|
Diffuse report: AAR |
|
Benchmark report:
|
CAMOBAP
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes a regression introduced by the PNG density-variant optimization in
1d4778969f6feba5d0f6ec9923ac0efbeb37c88a.That change correctly enabled
vectorDrawables.useSupportLibraryand replacedandroid:srcwithapp:srcCompatto avoid generating density-specific PNG fallbacks. The problem is thatHCaptchaDialogFragmentstill inflateshcaptcha_fragment.xmlthrough the plainDialogFragment/android.app.Dialogpath. With a frameworkImageView,app:srcCompatis ignored, so the loading logo drawable is never set at runtime.Fix
androidx.appcompat.widget.AppCompatImageViewapp:srcCompatandvectorDrawables.useSupportLibrary = trueUsing the explicit AppCompat widget is the narrowest and most compatible fix because it preserves the size reduction goal while making vector inflation work on the existing production path down to the module's supported API levels.
Test coverage
Dialogcontext used by the fragmentAppCompatImageViewVerification
./gradlew :sdk:testDebugUnitTest --tests '*HCaptchaFragmentLayoutTest'./gradlew :sdk:testDebugUnitTest