mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-25 15:10:47 +01:00
Added biometric authentication
This commit is contained in:
@@ -201,6 +201,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
||||
}
|
||||
}));
|
||||
|
||||
menus.add(new NavMenuItem(R.drawable.baseline_fingerprint_24, R.string.title_setup_biometrics, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
drawerLayout.closeDrawer(drawerContainer);
|
||||
onMenuBiometrics();
|
||||
}
|
||||
}));
|
||||
|
||||
menus.add(new NavMenuItem(R.drawable.baseline_person_24, R.string.menu_contacts, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -405,6 +413,29 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void onMenuBiometrics() {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivitySetup.this);
|
||||
final boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
final boolean pro = Helper.isPro(this);
|
||||
|
||||
Helper.authenticate(this, biometrics, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (pro)
|
||||
prefs.edit().putBoolean("biometrics", !biometrics).apply();
|
||||
|
||||
Toast.makeText(ActivitySetup.this,
|
||||
pro ? R.string.title_setup_done : R.string.title_pro_feature,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onMenuContacts() {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
getSupportFragmentManager().popBackStack("contacts", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
|
||||
Reference in New Issue
Block a user