diff --git a/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java index 344f625..89c244d 100644 --- a/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java +++ b/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java @@ -204,7 +204,7 @@ public void run() { } private void updateFingerprintDialog(DialogState state, String message) { - if (cancellationSignal.isCanceled() || !fingerprintDialog.isShowing()) { + if (cancellationSignal.isCanceled() || (fingerprintDialog != null && !fingerprintDialog.isShowing())) { return; } // TextView resultInfo = (TextView) fingerprintDialog.findViewById(R.id.fingerprint_status); @@ -225,13 +225,13 @@ private void updateFingerprintDialog(DialogState state, String message) { // Suppress inflateParams lint because dialogs do not need to attach to a parent view. @SuppressLint("InflateParams") private void showFingerprintDialog() { - // View view = LayoutInflater.from(activity).inflate(R.layout.scan_fp, null, false); - // TextView fpDescription = (TextView) view.findViewById(R.id.fingerprint_description); - // TextView title = (TextView) view.findViewById(R.id.fingerprint_signin); - // TextView status = (TextView) view.findViewById(R.id.fingerprint_status); - // fpDescription.setText((String) call.argument("localizedReason")); - // title.setText((String) call.argument("signInTitle")); - // status.setText((String) call.argument("fingerprintHint")); + View view = LayoutInflater.from(activity).inflate(R.layout.scan_fp, null, false); + TextView fpDescription = (TextView) view.findViewById(R.id.fingerprint_description); + TextView title = (TextView) view.findViewById(R.id.fingerprint_signin); + TextView status = (TextView) view.findViewById(R.id.fingerprint_status); + fpDescription.setText((String) call.argument("localizedReason")); + title.setText((String) call.argument("signInTitle")); + status.setText((String) call.argument("fingerprintHint")); Context context = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); OnClickListener cancelHandler = new OnClickListener() { @@ -240,13 +240,13 @@ public void onClick(DialogInterface dialog, int which) { stop(false); } }; - fingerprintDialog = - new AlertDialog.Builder(context) - // .setView(view) - // .setNegativeButton((String) call.argument(CANCEL_BUTTON), cancelHandler) - // .setCancelable(false) - .show(); - fingerprintDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND‌​); + if (call.argument("showFPDialog")) + fingerprintDialog = + new AlertDialog.Builder(context) + .setView(view) + .setNegativeButton((String) call.argument(CANCEL_BUTTON), cancelHandler) + .setCancelable(false).show(); + //fingerprintDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } // Suppress inflateParams lint because dialogs do not need to attach to a parent view. diff --git a/lib/flutter_local_auth_invisible.dart b/lib/flutter_local_auth_invisible.dart index ca86b54..f25daf5 100644 --- a/lib/flutter_local_auth_invisible.dart +++ b/lib/flutter_local_auth_invisible.dart @@ -48,6 +48,10 @@ class LocalAuthentication { /// back to Dart and it is up to the client app to restart authentication or /// do something else. /// + /// [showFPDialog] is used to show fingerprint dialog. If showFPDialog is set + /// to true, authentication dialog is shown. If it is set to + /// false (default), then authentication dialog is not shown + /// /// Construct [AndroidAuthStrings] and [IOSAuthStrings] if you want to /// customize messages in the dialogs. /// @@ -64,6 +68,7 @@ class LocalAuthentication { @required String localizedReason, bool useErrorDialogs = true, bool stickyAuth = false, + bool showFPDialog = false, AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), bool sensitiveTransaction = true, @@ -73,6 +78,7 @@ class LocalAuthentication { 'localizedReason': localizedReason, 'useErrorDialogs': useErrorDialogs, 'stickyAuth': stickyAuth, + 'showFPDialog': showFPDialog, 'sensitiveTransaction': sensitiveTransaction, }; if (_platform.isIOS) {