mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
Use flag secure to hide from recents
This commit is contained in:
@@ -28,6 +28,7 @@ import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -72,6 +73,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
this.contacts = hasPermission(Manifest.permission.READ_CONTACTS);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean no_history = prefs.getBoolean("no_history", false);
|
||||
if (no_history)
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
|
||||
if (!this.getClass().equals(ActivityMain.class)) {
|
||||
String theme = prefs.getString("theme", "light");
|
||||
@@ -205,8 +209,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
try {
|
||||
if (Helper.noHistory(this))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
@@ -217,8 +219,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
try {
|
||||
if (Helper.noHistory(this))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
|
||||
@@ -90,8 +90,6 @@ public class FragmentBase extends Fragment {
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
try {
|
||||
if (Helper.noHistory(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
@@ -102,8 +100,6 @@ public class FragmentBase extends Fragment {
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
try {
|
||||
if (Helper.noHistory(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package eu.faircode.email;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -136,15 +138,21 @@ public class FragmentDialogBase extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (Helper.noHistory(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivity(intent);
|
||||
try {
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(getContext(), getString(R.string.title_no_viewer, intent.getAction()), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
if (Helper.noHistory(getContext()))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
try {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(getContext(), getString(R.string.title_no_viewer, intent.getAction()), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
swNoHistory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("no_history", checked).apply();
|
||||
prefs.edit().putBoolean("no_history", checked).commit(); // apply won't work here
|
||||
restart();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -742,13 +742,6 @@ public class Helper {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean noHistory(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
boolean no_history = prefs.getBoolean("no_history", false);
|
||||
return (biometrics || no_history);
|
||||
}
|
||||
|
||||
static boolean shouldAuthenticate(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
|
||||
Reference in New Issue
Block a user