Skip to content

Commit

Permalink
Merge pull request #11 from Anaxagor1987/cancelation_signal-fix-biome…
Browse files Browse the repository at this point in the history
…tric-prompt-23

Fixes the issue with dialog not dismissed by cancellation signal
  • Loading branch information
fython authored Sep 14, 2018
2 parents 9d0da44 + 90e9b18 commit 1a10f27
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ public void authenticate(
}
this.cancellationSignal = cancel;
this.callback = callback;
if (cancel == null) {
cancel = new CancellationSignal();
if (cancellationSignal == null) {
cancellationSignal = new CancellationSignal();
}
cancel.setOnCancelListener(dialog::cancel);
CancellationSignal innerCancel = new CancellationSignal();
cancellationSignal.setOnCancelListener(() -> {
innerCancel.cancel();
dialog.cancel();
});

dialog.setOnDismissListener(dialogInterface -> {
if (cancellationSignal != null && !cancellationSignal.isCanceled()) {
Expand All @@ -116,7 +120,7 @@ public void authenticate(
dialog.getFingerprintIcon().setState(
FingerprintIconView.State.ON, false);
fingerprintManager.authenticate(
toCryptoObjectApi23(crypto), cancellationSignal,
toCryptoObjectApi23(crypto), innerCancel,
0, fmAuthCallback, mainHandler);
});

Expand All @@ -133,16 +137,20 @@ BiometricPromptCompatDialog getAuthenticateDialogForFragment(
}
this.cancellationSignal = cancel;
this.callback = callback;
if (cancel == null) {
cancel = new CancellationSignal();
if (cancellationSignal == null) {
cancellationSignal = new CancellationSignal();
}
cancel.setOnCancelListener(dialog::cancel);
CancellationSignal innerCancel = new CancellationSignal();
cancellationSignal.setOnCancelListener(() -> {
innerCancel.cancel();
dialog.cancel();
});

dialog.setOnShowListener(d -> {
dialog.getFingerprintIcon().setState(
FingerprintIconView.State.ON, false);
fingerprintManager.authenticate(
toCryptoObjectApi23(crypto), cancellationSignal,
toCryptoObjectApi23(crypto), innerCancel,
0, fmAuthCallback, mainHandler);
});

Expand Down

0 comments on commit 1a10f27

Please sign in to comment.