Skip to content
Merged
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compose-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion gradle/shared/html-java-gen.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +31,6 @@ android.libraryVariants.all { variant ->
}
}

// preBuild.dependsOn generateTask
// Ensure the generation task runs before compilation
variant.registerJavaGeneratingTask(generateTask.get(), outputDir)
}
4 changes: 2 additions & 2 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}\""

Expand Down
5 changes: 1 addition & 4 deletions sdk/src/main/html/hcaptcha.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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()) {
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading