mirror of https://github.com/M66B/FairEmail.git
Added no history option
This commit is contained in:
parent
40c93e6541
commit
2752f7435b
2
FAQ.md
2
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)
|
![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.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
try {
|
try {
|
||||||
if (Helper.hasAuthentication(this))
|
if (Helper.noHistory(this))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivity(intent);
|
super.startActivity(intent);
|
||||||
} catch (ActivityNotFoundException ex) {
|
} catch (ActivityNotFoundException ex) {
|
||||||
|
@ -217,7 +217,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
@Override
|
@Override
|
||||||
public void startActivityForResult(Intent intent, int requestCode) {
|
public void startActivityForResult(Intent intent, int requestCode) {
|
||||||
try {
|
try {
|
||||||
if (Helper.hasAuthentication(this))
|
if (Helper.noHistory(this))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivityForResult(intent, requestCode);
|
super.startActivityForResult(intent, requestCode);
|
||||||
} catch (ActivityNotFoundException ex) {
|
} catch (ActivityNotFoundException ex) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class FragmentBase extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
try {
|
try {
|
||||||
if (Helper.hasAuthentication(getContext()))
|
if (Helper.noHistory(getContext()))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivity(intent);
|
super.startActivity(intent);
|
||||||
} catch (ActivityNotFoundException ex) {
|
} catch (ActivityNotFoundException ex) {
|
||||||
|
@ -102,7 +102,7 @@ public class FragmentBase extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void startActivityForResult(Intent intent, int requestCode) {
|
public void startActivityForResult(Intent intent, int requestCode) {
|
||||||
try {
|
try {
|
||||||
if (Helper.hasAuthentication(getContext()))
|
if (Helper.noHistory(getContext()))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivityForResult(intent, requestCode);
|
super.startActivityForResult(intent, requestCode);
|
||||||
} catch (ActivityNotFoundException ex) {
|
} catch (ActivityNotFoundException ex) {
|
||||||
|
|
|
@ -136,14 +136,14 @@ public class FragmentDialogBase extends DialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
if (Helper.hasAuthentication(getContext()))
|
if (Helper.noHistory(getContext()))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivity(intent);
|
super.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivityForResult(Intent intent, int requestCode) {
|
public void startActivityForResult(Intent intent, int requestCode) {
|
||||||
if (Helper.hasAuthentication(getContext()))
|
if (Helper.noHistory(getContext()))
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||||
super.startActivityForResult(intent, requestCode);
|
super.startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class FragmentOptions extends FragmentBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 8;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,8 +103,10 @@ public class FragmentOptions extends FragmentBase {
|
||||||
case 5:
|
case 5:
|
||||||
return new FragmentOptionsBehavior();
|
return new FragmentOptionsBehavior();
|
||||||
case 6:
|
case 6:
|
||||||
return new FragmentOptionsNotifications();
|
return new FragmentOptionsPrivacy();
|
||||||
case 7:
|
case 7:
|
||||||
|
return new FragmentOptionsNotifications();
|
||||||
|
case 8:
|
||||||
return new FragmentOptionsMisc();
|
return new FragmentOptionsMisc();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
@ -127,8 +129,10 @@ public class FragmentOptions extends FragmentBase {
|
||||||
case 5:
|
case 5:
|
||||||
return getString(R.string.title_advanced_section_behavior);
|
return getString(R.string.title_advanced_section_behavior);
|
||||||
case 6:
|
case 6:
|
||||||
return getString(R.string.title_advanced_section_notifications);
|
return getString(R.string.title_advanced_section_privacy);
|
||||||
case 7:
|
case 7:
|
||||||
|
return getString(R.string.title_advanced_section_notifications);
|
||||||
|
case 8:
|
||||||
return getString(R.string.title_advanced_section_misc);
|
return getString(R.string.title_advanced_section_misc);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
|
@ -54,11 +54,10 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
private SwitchCompat swAutoUnflag;
|
private SwitchCompat swAutoUnflag;
|
||||||
private SwitchCompat swAutoMove;
|
private SwitchCompat swAutoMove;
|
||||||
private SwitchCompat swDiscardDelete;
|
private SwitchCompat swDiscardDelete;
|
||||||
private SwitchCompat swDisableTracking;
|
|
||||||
|
|
||||||
private final static String[] RESET_OPTIONS = new String[]{
|
private final static String[] RESET_OPTIONS = new String[]{
|
||||||
"pull", "autoscroll", "doubletap", "swipenav", "reversed", "autoexpand", "expand_one", "autoclose", "onclose",
|
"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
|
@Override
|
||||||
|
@ -85,7 +84,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
swAutoUnflag = view.findViewById(R.id.swAutoUnflag);
|
swAutoUnflag = view.findViewById(R.id.swAutoUnflag);
|
||||||
swAutoMove = view.findViewById(R.id.swAutoMove);
|
swAutoMove = view.findViewById(R.id.swAutoMove);
|
||||||
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
|
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
|
||||||
swDisableTracking = view.findViewById(R.id.swDisableTracking);
|
|
||||||
|
|
||||||
setOptions();
|
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);
|
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
@ -279,6 +270,5 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false));
|
swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false));
|
||||||
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
|
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
|
||||||
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
|
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
|
||||||
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -742,9 +742,11 @@ public class Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean hasAuthentication(Context context) {
|
static boolean noHistory(Context context) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(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) {
|
static boolean shouldAuthenticate(Context context) {
|
||||||
|
|
|
@ -216,17 +216,5 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
|
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
|
||||||
android:id="@+id/swDisableTracking"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:checked="true"
|
|
||||||
android:text="@string/title_advanced_tracking"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/swDiscardDelete"
|
|
||||||
app:switchPadding="12dp" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:scrollbarStyle="outsideOverlay"
|
||||||
|
tools:context=".ActivitySetup">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swDisableTracking"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/title_advanced_tracking"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swNoHistory"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_recents"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/swDisableTracking"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</ScrollView>
|
Loading…
Reference in New Issue