Skip to content

Commit 2032cdf

Browse files
authored
fix: call preloadedWebView in case of incomplete Bundle (#189) (#190)
* fix: re-init sPreloadWebView in preloadedWebView for incomplete Bundle (#189) * chore: bump to 4.2.1
1 parent 65b01ad commit 2032cdf

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# 4.2.1
4+
5+
- Fix: java.lang.NullPointerException: during WebView preparation (#189)
6+
37
# 4.2.0
48

59
- Fix: java.lang.IllegalStateException: The specified child already has a parent for reloadedWebView in compose-sdk

compose-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ android {
2020
// See https://developer.android.com/studio/publish/versioning
2121
// versionCode must be integer and be incremented by one for every new update
2222
// android system uses this to prevent downgrades
23-
versionCode 48
23+
versionCode 49
2424

2525
// version number visible to the user
2626
// should follow semantic versioning (See https://semver.org)
27-
versionName "4.2.0"
27+
versionName "4.2.1"
2828

2929
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3030
consumerProguardFiles "consumer-rules.pro"

sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ android {
2828
// See https://developer.android.com/studio/publish/versioning
2929
// versionCode must be integer and be incremented by one for every new update
3030
// android system uses this to prevent downgrades
31-
versionCode 48
31+
versionCode 49
3232

3333
// version number visible to the user
3434
// should follow semantic versioning (See https://semver.org)
35-
versionName "4.2.0"
35+
versionName "4.2.1"
3636

3737
buildConfigField 'String', 'VERSION_NAME', "\"${defaultConfig.versionName}_${defaultConfig.versionCode}\""
3838

sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void onCreate(Bundle savedInstanceState) {
124124
// According to Firebase Analytics, there are cases where Bundle args are empty.
125125
// > 90% of these cases occur on Android 6, and the count of crashes <<< the count of sessions.
126126
// This is a quick fix to prevent crashes in production
127+
HCaptchaLog.w("DialogFragment.onCreate getArguments is incomplete");
127128
if (listener != null) {
128129
listener.onFailure(new HCaptchaException(HCaptchaError.ERROR));
129130
}
@@ -362,6 +363,10 @@ private void prepareWebView(@NonNull View rootView, @NonNull HCaptchaConfig conf
362363
final ViewGroup parent = (ViewGroup) rootView;
363364
final int index = parent.indexOfChild(stub);
364365
parent.removeView(stub);
366+
if (sPreloadWebView == null) {
367+
HCaptchaLog.w("DialogFragment.prepareWebView: sPreloadWebView cold init");
368+
sPreloadWebView = new HCaptchaWebView(requireContext());
369+
}
365370
if (sPreloadWebView.getParent() != null) {
366371
((ViewGroup) sPreloadWebView.getParent()).removeView(sPreloadWebView);
367372
}
@@ -378,6 +383,8 @@ private void prepareWebView(@NonNull View rootView, @NonNull HCaptchaConfig conf
378383
return view.performClick();
379384
});
380385
}
386+
} else {
387+
HCaptchaLog.w("DialogFragment.prepareWebView invalid state " + stub.getClass());
381388
}
382389
}
383390
}

0 commit comments

Comments
 (0)