protected override void OnResume() { base.OnResume(); _design.ReapplyTheme(); CheckIfUnloaded(); bool showKeyboard = ((!InitFingerprintUnlock()) || (Util.GetShowKeyboardDuringFingerprintUnlock(this))); EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); pwd.PostDelayed(() => { InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService); if (showKeyboard) { keyboard.ShowSoftInput(pwd, 0); } else { keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly); } }, 50); var btn = FindViewById <ImageButton>(Resource.Id.fingerprintbtn); btn.Click += (sender, args) => { if (_biometryIdentifier.HasUserInterface || string.IsNullOrEmpty((string)btn.Tag)) { _biometryIdentifier.StartListening(this); } else { AlertDialog.Builder b = new AlertDialog.Builder(this); b.SetTitle(Resource.String.fingerprint_prefs); b.SetMessage(btn.Tag.ToString()); b.SetPositiveButton(Android.Resource.String.Ok, (o, eventArgs) => ((Dialog)o).Dismiss()); if (_biometryIdentifier != null) { b.SetNegativeButton(Resource.String.disable_sensor, (senderAlert, alertArgs) => { btn.SetImageResource(Resource.Drawable.ic_fingerprint_error); _biometryIdentifier?.StopListening(); _biometryIdentifier = null; }); } else { b.SetNegativeButton(Resource.String.enable_sensor, (senderAlert, alertArgs) => { InitFingerprintUnlock(); }); } b.Show(); } }; }
protected override void OnResume() { base.OnResume(); _design.ReapplyTheme(); CheckIfUnloaded(); bool showKeyboard = ((!InitFingerprintUnlock()) || (Util.GetShowKeyboardDuringFingerprintUnlock(this))); EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); pwd.PostDelayed(() => { InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService); if (showKeyboard) { keyboard.ShowSoftInput(pwd, 0); } else { keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly); } }, 50); _onResumeDone = true; }
protected override void OnCreate(Bundle savedInstanceState) { _activityDesign.ApplyTheme(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.fingerprint_setup); Enum.TryParse( PreferenceManager.GetDefaultSharedPreferences(this).GetString(App.Kp2a.GetDb().CurrentFingerprintModePrefKey, ""), out _unlockMode); _fpIcon = FindViewById <ImageView>(Resource.Id.fingerprint_icon); _fpTextView = FindViewById <TextView>(Resource.Id.fingerprint_status); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); int[] radioButtonIds = { Resource.Id.radio_fingerprint_quickunlock, Resource.Id.radio_fingerprint_unlock, Resource.Id.radio_fingerprint_disabled }; _radioButtons = radioButtonIds.Select(FindViewById <RadioButton>).ToArray(); _radioButtons[0].Tag = FingerprintUnlockMode.QuickUnlock.ToString(); _radioButtons[1].Tag = FingerprintUnlockMode.FullUnlock.ToString(); _radioButtons[2].Tag = FingerprintUnlockMode.Disabled.ToString(); foreach (RadioButton r in _radioButtons) { r.CheckedChange += (sender, args) => { var rbSender = ((RadioButton)sender); if (!rbSender.Checked) { return; } foreach (RadioButton rOther in _radioButtons) { if (rOther == sender) { continue; } rOther.Checked = false; } FingerprintUnlockMode newMode; Enum.TryParse(rbSender.Tag.ToString(), out newMode); ChangeUnlockMode(_unlockMode, newMode); }; } CheckCurrentRadioButton(); int errorId = Resource.String.fingerprint_os_error; SetError(errorId); FindViewById(Resource.Id.cancel_button).Click += (sender, args) => { _enc.StopListening(); _unlockMode = FingerprintUnlockMode.Disabled; //cancelling a FingerprintEncryption means a new key has been created but not been authenticated to encrypt something. We can't keep the previous state. StoreUnlockMode(); FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone; _enc = null; CheckCurrentRadioButton(); }; FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone; FindViewById <CheckBox>(Resource.Id.show_keyboard_while_fingerprint).Checked = Util.GetShowKeyboardDuringFingerprintUnlock(this); FindViewById <CheckBox>(Resource.Id.show_keyboard_while_fingerprint).CheckedChange += (sender, args) => { PreferenceManager.GetDefaultSharedPreferences(this) .Edit() .PutBoolean(GetString(Resource.String.ShowKeyboardWhileFingerprint_key), args.IsChecked) .Commit(); }; if ((int)Build.VERSION.SdkInt >= 23) { RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode); } else { TrySetupSamsung(); } UpdateKeyboardCheckboxVisibility(); }