Skip to content

Commit

Permalink
fix: show loading screen until the challenge is open (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdziamura committed Nov 1, 2022
1 parent 66a948b commit d61641d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 3.3.5

- Show loading screen until the challenge is open when size is `HCaptchaSize.INVISIBLE`

# 3.3.4

- Rename `ic_logo` drawable to avoid possible collisions with a host app's drawables
Expand Down
4 changes: 2 additions & 2 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,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 22
versionCode 23

// version number visible to the user
// should follow semantic versioning (See https://semver.org)
versionName "3.3.4"
versionName "3.3.5"

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

Expand Down
18 changes: 15 additions & 3 deletions sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ public void onCancel(@NonNull DialogInterface dialogInterface) {
this.onFailure(new HCaptchaException(HCaptchaError.CHALLENGE_CLOSED));
}

@Override
public void onLoaded() {
assert webViewHelper != null;
private void hideLoadingContainer() {
if (webViewHelper.getConfig().getLoading()) {
loadingContainer.animate().alpha(0.0f).setDuration(200).setListener(
new AnimatorListenerAdapter() {
Expand All @@ -166,9 +164,23 @@ public void onAnimationEnd(Animator animation) {
}
}

@Override
public void onLoaded() {
assert webViewHelper != null;

if (webViewHelper.getConfig().getSize() != HCaptchaSize.INVISIBLE) {
hideLoadingContainer();
}
}

@Override
public void onOpen() {
assert webViewHelper != null;

if (webViewHelper.getConfig().getSize() == HCaptchaSize.INVISIBLE) {
hideLoadingContainer();
}

webViewHelper.getListener().onOpen();
}

Expand Down

0 comments on commit d61641d

Please sign in to comment.