protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activityUnlock); Window.SetSoftInputMode(SoftInput.AdjustPan); _preferences = new PreferenceWrapper(this); SetResult(Result.Canceled); _passwordLayout = FindViewById <TextInputLayout>(Resource.Id.editPasswordLayout); _passwordText = FindViewById <TextInputEditText>(Resource.Id.editPassword); TextInputUtil.EnableAutoErrorClear(_passwordLayout); _passwordText.EditorAction += (_, e) => { if (e.ActionId == ImeAction.Done) { OnUnlockButtonClick(null, null); } }; _passwordText.TextChanged += delegate { _unlockButton.Enabled = _passwordText.Text != ""; }; _unlockButton = FindViewById <MaterialButton>(Resource.Id.buttonUnlock); _unlockButton.Click += OnUnlockButtonClick; var canUseBiometrics = false; if (_preferences.AllowBiometrics) { var biometricManager = BiometricManager.From(this); canUseBiometrics = biometricManager.CanAuthenticate() == BiometricManager.BiometricSuccess; } _useBiometricsButton = FindViewById <MaterialButton>(Resource.Id.buttonUseBiometrics); _useBiometricsButton.Enabled = canUseBiometrics; _useBiometricsButton.Click += delegate { ShowBiometricPrompt(); }; if (canUseBiometrics) { ShowBiometricPrompt(); } else { await FocusPasswordText(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.SetSoftInputMode(SoftInput.AdjustResize); SetResult(Result.Canceled); _preferences = new PreferenceWrapper(this); _unlockLayout = FindViewById <LinearLayout>(Resource.Id.layoutUnlock); _progressIndicator = FindViewById <LinearProgressIndicator>(Resource.Id.progressIndicator); _passwordLayout = FindViewById <TextInputLayout>(Resource.Id.editPasswordLayout); _passwordText = FindViewById <TextInputEditText>(Resource.Id.editPassword); TextInputUtil.EnableAutoErrorClear(_passwordLayout); _passwordText.EditorAction += (_, e) => { if (e.ActionId == ImeAction.Done) { OnUnlockButtonClick(null, null); } }; _unlockButton = FindViewById <MaterialButton>(Resource.Id.buttonUnlock); _unlockButton.Click += OnUnlockButtonClick; if (_preferences.AllowBiometrics) { var biometricManager = BiometricManager.From(this); _canUseBiometrics = biometricManager.CanAuthenticate(BiometricManager.Authenticators.BiometricStrong) == BiometricManager.BiometricSuccess; } _useBiometricsButton = FindViewById <MaterialButton>(Resource.Id.buttonUseBiometrics); _useBiometricsButton.Enabled = _canUseBiometrics; _useBiometricsButton.Click += delegate { ShowBiometricPrompt(); }; if (_canUseBiometrics) { ShowBiometricPrompt(); } else { FocusPasswordText(); } }