mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
Added support for Disconnect's tracker protection lists
This commit is contained in:
@@ -20,10 +20,10 @@ package eu.faircode.email;
|
||||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -55,6 +55,9 @@ import androidx.constraintlayout.widget.Group;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class FragmentOptionsPrivacy extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swConfirmLinks;
|
||||
private SwitchCompat swBrowseLinks;
|
||||
@@ -69,6 +72,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
private SwitchCompat swSecure;
|
||||
private SwitchCompat swSafeBrowsing;
|
||||
private ImageButton ibSafeBrowsing;
|
||||
private ImageButton ibDisconnectBlacklist;
|
||||
private Button btnDisconnectBlacklist;
|
||||
private TextView tvDisconnectBlacklistTime;
|
||||
|
||||
private Group grpSafeBrowsing;
|
||||
|
||||
@@ -85,7 +91,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
setSubtitle(R.string.title_setup);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
View view = inflater.inflate(R.layout.fragment_options_privacy, container, false);
|
||||
|
||||
// Get controls
|
||||
@@ -103,6 +108,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
swSecure = view.findViewById(R.id.swSecure);
|
||||
swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing);
|
||||
ibSafeBrowsing = view.findViewById(R.id.ibSafeBrowsing);
|
||||
ibDisconnectBlacklist = view.findViewById(R.id.ibDisconnectBlacklist);
|
||||
btnDisconnectBlacklist = view.findViewById(R.id.btnDisconnectBlacklist);
|
||||
tvDisconnectBlacklistTime = view.findViewById(R.id.tvDisconnectBlacklistTime);
|
||||
|
||||
grpSafeBrowsing = view.findViewById(R.id.grpSafeBrowsing);
|
||||
|
||||
@@ -237,6 +245,46 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
|
||||
grpSafeBrowsing.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE);
|
||||
|
||||
ibDisconnectBlacklist.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Helper.view(getContext(), Uri.parse("https://github.com/disconnectme/disconnect-tracking-protection"), true);
|
||||
}
|
||||
});
|
||||
|
||||
btnDisconnectBlacklist.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
btnDisconnectBlacklist.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bundle args) {
|
||||
btnDisconnectBlacklist.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
||||
DisconnectBlacklist.download(context);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
setOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentOptionsPrivacy.this, new Bundle(), "disconnect");
|
||||
}
|
||||
});
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
return view;
|
||||
@@ -308,6 +356,10 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||
swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));
|
||||
swSecure.setChecked(prefs.getBoolean("secure", false));
|
||||
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", false));
|
||||
|
||||
Long time = DisconnectBlacklist.getTime(getContext());
|
||||
DateFormat DF = SimpleDateFormat.getDateTimeInstance();
|
||||
tvDisconnectBlacklistTime.setText(time == null ? null : DF.format(time));
|
||||
}
|
||||
|
||||
public static class FragmentDialogPin extends FragmentDialogBase {
|
||||
|
||||
Reference in New Issue
Block a user