mirror of https://github.com/M66B/FairEmail.git
Exclude from recents when using biometric authentication
This commit is contained in:
parent
7d60483274
commit
c758723855
|
@ -156,6 +156,20 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (Helper.hasAuthentication(this))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
if (Helper.hasAuthentication(this))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||
Log.i("Preference " + key + "=" + prefs.getAll().get(key));
|
||||
|
|
|
@ -27,14 +27,13 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityMain extends AppCompatActivity implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class ActivityMain extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
|
|
|
@ -39,4 +39,18 @@ public class DialogFragmentEx extends DialogFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (Helper.hasAuthentication(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
if (Helper.hasAuthentication(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,20 @@ public class FragmentBase extends Fragment {
|
|||
updateSubtitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (Helper.hasAuthentication(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
if (Helper.hasAuthentication(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
protected void finish() {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
getFragmentManager().popBackStack();
|
||||
|
|
|
@ -655,6 +655,11 @@ public class Helper {
|
|||
return Objects.equals(signed, expected);
|
||||
}
|
||||
|
||||
static boolean hasAuthentication(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return prefs.getBoolean("biometrics", false);
|
||||
}
|
||||
|
||||
static boolean shouldAuthenticate(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
|
|
Loading…
Reference in New Issue