diff --git a/FAQ.md b/FAQ.md
index 7e933acad9..c284b80c29 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -1695,7 +1695,7 @@ FairEmail will in most cases automatically recognize tracking images and replace
![External image](https://raw.githubusercontent.com/google/material-design-icons/master/maps/1x_web/ic_my_location_black_48dp.png)
-Automatic recognition of tracking images can be disabled in the behavior settings.
+Automatic recognition of tracking images can be disabled in the privacy settings.
diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java
index 5885596048..2bb0b613bd 100644
--- a/app/src/main/java/eu/faircode/email/ActivityBase.java
+++ b/app/src/main/java/eu/faircode/email/ActivityBase.java
@@ -205,7 +205,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override
public void startActivity(Intent intent) {
try {
- if (Helper.hasAuthentication(this))
+ if (Helper.noHistory(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivity(intent);
} catch (ActivityNotFoundException ex) {
@@ -217,7 +217,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override
public void startActivityForResult(Intent intent, int requestCode) {
try {
- if (Helper.hasAuthentication(this))
+ if (Helper.noHistory(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException ex) {
diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java
index 04ea8a4ca6..d06ef9f2ca 100644
--- a/app/src/main/java/eu/faircode/email/FragmentBase.java
+++ b/app/src/main/java/eu/faircode/email/FragmentBase.java
@@ -90,7 +90,7 @@ public class FragmentBase extends Fragment {
@Override
public void startActivity(Intent intent) {
try {
- if (Helper.hasAuthentication(getContext()))
+ if (Helper.noHistory(getContext()))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivity(intent);
} catch (ActivityNotFoundException ex) {
@@ -102,7 +102,7 @@ public class FragmentBase extends Fragment {
@Override
public void startActivityForResult(Intent intent, int requestCode) {
try {
- if (Helper.hasAuthentication(getContext()))
+ if (Helper.noHistory(getContext()))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException ex) {
diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogBase.java b/app/src/main/java/eu/faircode/email/FragmentDialogBase.java
index a67228a07c..4911a15f4d 100644
--- a/app/src/main/java/eu/faircode/email/FragmentDialogBase.java
+++ b/app/src/main/java/eu/faircode/email/FragmentDialogBase.java
@@ -136,14 +136,14 @@ public class FragmentDialogBase extends DialogFragment {
@Override
public void startActivity(Intent intent) {
- if (Helper.hasAuthentication(getContext()))
+ if (Helper.noHistory(getContext()))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivity(intent);
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
- if (Helper.hasAuthentication(getContext()))
+ if (Helper.noHistory(getContext()))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivityForResult(intent, requestCode);
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java
index 4a8d233bb5..f312e6d839 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptions.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java
@@ -84,7 +84,7 @@ public class FragmentOptions extends FragmentBase {
@Override
public int getCount() {
- return 8;
+ return 9;
}
@Override
@@ -103,8 +103,10 @@ public class FragmentOptions extends FragmentBase {
case 5:
return new FragmentOptionsBehavior();
case 6:
- return new FragmentOptionsNotifications();
+ return new FragmentOptionsPrivacy();
case 7:
+ return new FragmentOptionsNotifications();
+ case 8:
return new FragmentOptionsMisc();
default:
throw new IllegalArgumentException();
@@ -127,8 +129,10 @@ public class FragmentOptions extends FragmentBase {
case 5:
return getString(R.string.title_advanced_section_behavior);
case 6:
- return getString(R.string.title_advanced_section_notifications);
+ return getString(R.string.title_advanced_section_privacy);
case 7:
+ return getString(R.string.title_advanced_section_notifications);
+ case 8:
return getString(R.string.title_advanced_section_misc);
default:
throw new IllegalArgumentException();
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
index 5a66475fb0..321a0133d3 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
@@ -54,11 +54,10 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoUnflag;
private SwitchCompat swAutoMove;
private SwitchCompat swDiscardDelete;
- private SwitchCompat swDisableTracking;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "doubletap", "swipenav", "reversed", "autoexpand", "expand_one", "autoclose", "onclose",
- "collapse", "autoread", "autounflag", "automove", "discard_delete", "disable_tracking"
+ "collapse", "autoread", "autounflag", "automove", "discard_delete"
};
@Override
@@ -85,7 +84,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoUnflag = view.findViewById(R.id.swAutoUnflag);
swAutoMove = view.findViewById(R.id.swAutoMove);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
- swDisableTracking = view.findViewById(R.id.swDisableTracking);
setOptions();
@@ -202,13 +200,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
- swDisableTracking.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
- prefs.edit().putBoolean("disable_tracking", checked).apply();
- }
- });
-
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@@ -279,6 +270,5 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false));
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
- swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
}
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
new file mode 100644
index 0000000000..6aed861edd
--- /dev/null
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
@@ -0,0 +1,129 @@
+package eu.faircode.email;
+
+/*
+ This file is part of FairEmail.
+
+ FairEmail is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ FairEmail is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with FairEmail. If not, see .
+
+ Copyright 2018-2019 by Marcel Bokhorst (M66B)
+*/
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.SwitchCompat;
+import androidx.lifecycle.Lifecycle;
+import androidx.preference.PreferenceManager;
+
+public class FragmentOptionsPrivacy extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
+ private SwitchCompat swDisableTracking;
+ private SwitchCompat swNoHistory;
+
+ private final static String[] RESET_OPTIONS = new String[]{
+ "disable_tracking", "no_history"
+ };
+
+ @Override
+ @Nullable
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ setSubtitle(R.string.title_setup);
+ setHasOptionsMenu(true);
+
+ View view = inflater.inflate(R.layout.fragment_options_privacy, container, false);
+
+ // Get controls
+
+ swDisableTracking = view.findViewById(R.id.swDisableTracking);
+ swNoHistory = view.findViewById(R.id.swNoHistory);
+
+ setOptions();
+
+ // Wire controls
+
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+ swDisableTracking.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("disable_tracking", checked).apply();
+ }
+ });
+
+ swNoHistory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("no_history", checked).apply();
+ }
+ });
+
+ PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
+
+ return view;
+ }
+
+ @Override
+ public void onDestroyView() {
+ PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
+ super.onDestroyView();
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
+ if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
+ setOptions();
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.menu_options, menu);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_default:
+ onMenuDefault();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private void onMenuDefault() {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
+ SharedPreferences.Editor editor = prefs.edit();
+ for (String option : RESET_OPTIONS)
+ editor.remove(option);
+ editor.apply();
+ ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
+ }
+
+ private void setOptions() {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+ swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
+ swNoHistory.setChecked(prefs.getBoolean("no_history", false));
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java
index 6213aea3a4..26ca55445c 100644
--- a/app/src/main/java/eu/faircode/email/Helper.java
+++ b/app/src/main/java/eu/faircode/email/Helper.java
@@ -742,9 +742,11 @@ public class Helper {
}
}
- static boolean hasAuthentication(Context context) {
+ static boolean noHistory(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- return prefs.getBoolean("biometrics", false);
+ boolean biometrics = prefs.getBoolean("biometrics", false);
+ boolean no_history = prefs.getBoolean("no_history", false);
+ return (biometrics || no_history);
}
static boolean shouldAuthenticate(Context context) {
diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml
index 446e685ea4..a5c4edf280 100644
--- a/app/src/main/res/layout/fragment_options_behavior.xml
+++ b/app/src/main/res/layout/fragment_options_behavior.xml
@@ -216,17 +216,5 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
app:switchPadding="12dp" />
-
-
diff --git a/app/src/main/res/layout/fragment_options_privacy.xml b/app/src/main/res/layout/fragment_options_privacy.xml
new file mode 100644
index 0000000000..4b48d039d2
--- /dev/null
+++ b/app/src/main/res/layout/fragment_options_privacy.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+