diff --git a/CHANGES.md b/CHANGES.md index 9ab21d6a..31d4bcef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Changelog +# 4.3.1 + +- Fix: enable incremental builds for HTML-to-Java generation tasks +- Fix: correct nullability annotation to prevent `NullPointerException` +- Docs: add note about `reset` call for updated HCaptchaVerifyParams on next verify call + # 4.3.0 - Feature: implement HCaptchaVerifyParams with phone prefix/number support diff --git a/README.md b/README.md index 988c3199..58811922 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,8 @@ You should use only one of `phonePrefix` or `phoneNumber`. If you pass both, `ph **Note**: The `rqdata` parameter has been moved from `HCaptchaConfig` to `HCaptchaVerifyParams` for better API consistency. The old `rqdata` property in `HCaptchaConfig` is now deprecated, and will be removed in a future major version. +**Note**: If you update verify parameters and call `validate` a second time, call `reset()` before the second validation to ensure updated parameters are recognized by hCaptcha. + ### For Jetpack Compose ```kotlin diff --git a/compose-sdk/build.gradle b/compose-sdk/build.gradle index ca64b19c..b24ab1e4 100644 --- a/compose-sdk/build.gradle +++ b/compose-sdk/build.gradle @@ -20,11 +20,11 @@ android { // See https://developer.android.com/studio/publish/versioning // versionCode must be integer and be incremented by one for every new update // android system uses this to prevent downgrades - versionCode 53 + versionCode 54 // version number visible to the user // should follow semantic versioning (See https://semver.org) - versionName "4.3.0" + versionName "4.3.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" diff --git a/gradle/shared/html-java-gen.gradle b/gradle/shared/html-java-gen.gradle index 26b81897..592a1aa0 100644 --- a/gradle/shared/html-java-gen.gradle +++ b/gradle/shared/html-java-gen.gradle @@ -6,6 +6,11 @@ android.libraryVariants.all { variant -> group 'Generate' description "Generate HTML java class" + // Declare inputs for proper incremental build support + inputs.file("$projectDir/src/main/html/hcaptcha.html") + inputs.file("$projectDir/src/main/html/HCaptchaHtml.java.tml") + outputs.file("$outputDir/HCaptchaHtml.java") + doFirst { def outputJavaClass = file("$outputDir/HCaptchaHtml.java") def template = file("$projectDir/src/main/html/HCaptchaHtml.java.tml").text @@ -26,6 +31,6 @@ android.libraryVariants.all { variant -> } } - // preBuild.dependsOn generateTask + // Ensure the generation task runs before compilation variant.registerJavaGeneratingTask(generateTask.get(), outputDir) } \ No newline at end of file diff --git a/sdk/build.gradle b/sdk/build.gradle index 2ea859a9..92fd2b86 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -28,11 +28,11 @@ android { // See https://developer.android.com/studio/publish/versioning // versionCode must be integer and be incremented by one for every new update // android system uses this to prevent downgrades - versionCode 53 + versionCode 54 // version number visible to the user // should follow semantic versioning (See https://semver.org) - versionName "4.3.0" + versionName "4.3.1" buildConfigField 'String', 'VERSION_NAME', "\"${defaultConfig.versionName}_${defaultConfig.versionCode}\"" diff --git a/sdk/src/main/html/hcaptcha.html b/sdk/src/main/html/hcaptcha.html index 24dfcfc4..e3990aa7 100644 --- a/sdk/src/main/html/hcaptcha.html +++ b/sdk/src/main/html/hcaptcha.html @@ -159,10 +159,7 @@ var renderConfig = getRenderConfig(); hCaptchaID = hcaptcha.render('hcaptcha-container', renderConfig); BridgeObject.onLoaded(); - var rqdata = bridgeConfig.rqdata; - if (rqdata) { - hcaptcha.setData(hCaptchaID, { rqdata: rqdata }); - } + if (renderConfig.size === 'invisible' && !bridgeConfig.hideDialog) { // We want to auto execute in case of `invisible` checkbox. // But not in case of `hideDialog` since verification process diff --git a/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java b/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java index 7ac1d12b..b2ac3566 100644 --- a/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java +++ b/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java @@ -30,8 +30,7 @@ /** * HCaptcha Dialog Fragment Class. - * - * Must have `public` modifier, so it can be properly recreated from instance state! + * Must have a `public` modifier, so it can be properly recreated from the instance state! */ public final class HCaptchaDialogFragment extends DialogFragment implements IHCaptchaVerifier { @@ -176,9 +175,9 @@ public View onCreateView(@Nullable LayoutInflater inflater, final HCaptchaTheme theme = config.getTheme(); final int backgroundColor = theme == HCaptchaTheme.DARK ? Color.BLACK : Color.WHITE; loadingContainer.setBackgroundColor(backgroundColor); + loadingContainer.setVisibility(Boolean.TRUE.equals(config.getLoading()) + && !readyForInteraction ? View.VISIBLE : View.GONE); } - loadingContainer.setVisibility(Boolean.TRUE.equals(config.getLoading()) - && !readyForInteraction ? View.VISIBLE : View.GONE); return rootView; } catch (AssertionError | BadParcelableException | InflateException | ClassCastException e) { @@ -256,10 +255,11 @@ public void onLoaded() { return; } + webViewHelper.setVerifyParams(verifyParams); + if (webViewHelper.getConfig().getSize() != HCaptchaSize.INVISIBLE) { // checkbox will be shown readyForInteraction = true; - webViewHelper.setVerifyParams(verifyParams); hideLoadingContainer(); } } @@ -320,7 +320,11 @@ public void startVerification(@NonNull Activity fragmentActivity, @Nullable HCap // Store the verify params for later use in webview if (params != null) { this.verifyParams = params; + if (readyForInteraction && webViewHelper != null) { + webViewHelper.setVerifyParams(params); + } } + final FragmentManager fragmentManager = ((FragmentActivity) fragmentActivity).getSupportFragmentManager(); final Fragment oldFragment = fragmentManager.findFragmentByTag(HCaptchaDialogFragment.TAG); if (oldFragment != null && oldFragment.isAdded()) { diff --git a/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java b/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java index 90792930..6de23fee 100644 --- a/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java +++ b/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java @@ -43,9 +43,6 @@ final class HCaptchaWebViewHelper { @NonNull private final IHCaptchaHtmlProvider htmlProvider; - @Nullable - private HCaptchaVerifyParams verifyParams; - HCaptchaWebViewHelper(@NonNull final Handler handler, @NonNull final Context context, @NonNull final HCaptchaConfig config,