Added option to enable Adguard filter list

pull/214/head
M66B 1 year ago
parent 36924773db
commit e5838618c2

File diff suppressed because it is too large Load Diff

@ -63,6 +63,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private ImageButton ibHelp;
private SwitchCompat swConfirmLinks;
private SwitchCompat swSanitizeLinks;
private SwitchCompat swAdguard;
private SwitchCompat swCheckLinksDbl;
private SwitchCompat swConfirmFiles;
private SwitchCompat swConfirmImages;
@ -108,7 +109,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private final static int BIP39_WORDS = 6;
private final static String[] RESET_OPTIONS = new String[]{
"confirm_links", "sanitize_links", "check_links_dbl", "confirm_files",
"confirm_links", "sanitize_links", "adguard", "check_links_dbl", "confirm_files",
"confirm_images", "ask_images", "html_always_images", "confirm_html", "ask_html",
"disable_tracking",
"pin", "biometrics", "biometrics_timeout", "autolock", "autolock_nav",
@ -132,6 +133,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
ibHelp = view.findViewById(R.id.ibHelp);
swConfirmLinks = view.findViewById(R.id.swConfirmLinks);
swSanitizeLinks = view.findViewById(R.id.swSanitizeLinks);
swAdguard = view.findViewById(R.id.swAdguard);
swCheckLinksDbl = view.findViewById(R.id.swCheckLinksDbl);
swConfirmFiles = view.findViewById(R.id.swConfirmFiles);
swConfirmImages = view.findViewById(R.id.swConfirmImages);
@ -197,6 +199,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
editor.remove(key);
editor.apply();
swSanitizeLinks.setEnabled(checked);
swAdguard.setEnabled(checked);
swCheckLinksDbl.setEnabled(checked);
}
});
@ -208,6 +211,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
swAdguard.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("adguard", checked).apply();
}
});
swCheckLinksDbl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -604,6 +614,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swConfirmLinks.setChecked(prefs.getBoolean("confirm_links", true));
swSanitizeLinks.setChecked(prefs.getBoolean("sanitize_links", false));
swSanitizeLinks.setEnabled(swConfirmLinks.isChecked());
swAdguard.setChecked(prefs.getBoolean("adguard", false));
swAdguard.setEnabled(swConfirmLinks.isChecked());
swCheckLinksDbl.setChecked(prefs.getBoolean("check_links_dbl", BuildConfig.PLAY_STORE_RELEASE));
swCheckLinksDbl.setEnabled(swConfirmLinks.isChecked());
swConfirmFiles.setChecked(prefs.getBoolean("confirm_files", true));

@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
@ -29,6 +30,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.net.MailTo;
import androidx.core.util.PatternsCompat;
import androidx.preference.PreferenceManager;
import org.json.JSONArray;
import org.json.JSONObject;
@ -400,7 +402,9 @@ public class UriHelper {
if (url.isOpaque() || !isHyperLink(url))
return uri;
if (BuildConfig.DEBUG) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean adguard = prefs.getBoolean("adguard", false);
if (adguard) {
Uri result = Adguard.filter(context, url);
return (result == null ? url : result);
}

@ -126,6 +126,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSanitizeLinks" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAdguard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_adguard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSanitizeLinksHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckLinksDbl"
android:layout_width="0dp"
@ -135,7 +148,7 @@
android:text="@string/title_advanced_check_links_dbl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSanitizeLinksHint"
app:layout_constraintTop_toBottomOf="@id/swAdguard"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -763,6 +763,7 @@
<string name="title_advanced_confirm_files">Confirm viewing files</string>
<string name="title_advanced_sanitize_links">Remove tracking parameters by default</string>
<string name="title_advanced_sanitize_links_hint">Only when confirming links</string>
<string name="title_advanced_adguard">Use Adguard filter list</string>
<string name="title_advanced_check_links_dbl">Check domain block lists for suspicious links</string>
<string name="title_advanced_confirm_images">Show no images by default</string>
<string name="title_advanced_ask_images">Confirm showing images</string>

Loading…
Cancel
Save